/* Mario Kart Wii cheat cards — all rules scoped to .mkw-cheat.
   Header/footer are divs in the shortcode to avoid themes with global
   `header { height: ... }` and `footer { margin-top: auto }` rules. */
.mkw-cheat {
  --mkw-surface: var(--color-surface);
  --mkw-toolbar: var(--color-surface);
  --mkw-settings: var(--color-surface);
  --mkw-border: var(--color-border);
  --mkw-fg: var(--color-text);
  --mkw-subtle: var(--color-text);
  --mkw-accent: var(--color-accent);
  --mkw-input-bg: var(--color-control);
  --mkw-input-border: var(--color-border);
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 1.1rem 0;
  color: var(--mkw-fg);
  background: var(--mkw-surface);
  border: 1px solid var(--mkw-border);
  border-radius: 4px;
  overflow: hidden;
  isolation: isolate;
  hyphens: none;
}
.mkw-cheat *,
.mkw-cheat *::before,
.mkw-cheat *::after { box-sizing: border-box; }
.mkw-cheat [hidden] { display: none !important; }

/* Title and description are in a regular div — no global header collisions. */
.mkw-cheat .mkw-cheat-heading {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: .7rem .85rem .6rem;
  margin: 0;
  line-height: normal;
  background: var(--mkw-surface);
}
.mkw-cheat .mkw-cheat-heading h2 {
  font: 700 1.05rem/1.4 var(--font-ui);
  color: var(--color-heading);
  margin: 0 0 .4rem;
  padding: 0;
}
.mkw-cheat .mkw-cheat-heading p {
  color: var(--mkw-subtle);
  font: 400 .9rem/1.5 var(--font-ui);
  margin: 0;
  padding: 0;
}
.mkw-cheat .mkw-cheat-heading a {
  color: var(--color-link);
  font: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: .13em;
}
.mkw-cheat .mkw-cheat-heading a:hover { color: var(--color-accent); }

/* Region picker and copy button. Controls are always shown below this bar. */
.mkw-cheat .mkw-cheat-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .45rem .65rem;
  margin: 0;
  background: var(--mkw-toolbar);
  border-block: 1px solid var(--mkw-border);
}
.mkw-cheat .mkw-region-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  min-width: 0;
  margin-right: auto;
}
.mkw-cheat button,
.mkw-cheat input,
.mkw-cheat select {
  font: 500 .87rem/1.25 var(--font-ui);
}
.mkw-cheat button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 2.1rem;
  margin: 0;
  padding: .35rem .6rem;
  color: var(--mkw-fg);
  background: var(--color-control);
  border: 1px solid var(--mkw-border);
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.25;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}
.mkw-cheat button:hover { background: var(--color-control-hover); }
.mkw-cheat button:focus-visible,
.mkw-cheat select:focus-visible,
.mkw-cheat input:focus-visible {
  outline: 2px solid var(--mkw-accent);
  outline-offset: 3px;
}
.mkw-cheat button.is-selected,
.mkw-cheat button[aria-pressed="true"] {
  background: var(--color-control);
  border-color: var(--mkw-accent);
  color: var(--mkw-accent);
  font-weight: 700;
}
.mkw-cheat button.is-selected:hover,
.mkw-cheat button[aria-pressed="true"]:hover {
  background: var(--color-control-hover);
}
.mkw-cheat button:disabled { opacity: .5; cursor: not-allowed; }
.mkw-cheat button[data-copy] {
  margin-left: auto;
  background: var(--color-control);
  border-color: var(--mkw-border);
  color: var(--color-link);
}
.mkw-cheat button[data-copy]:hover { background: var(--color-control-hover); }

/* Customisation is permanently open; only conditionally applicable fields hide. */
.mkw-cheat .mkw-cheat-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr));
  gap: .65rem .8rem;
  margin: 0;
  padding: .7rem .85rem;
  background: var(--mkw-settings);
  border-bottom: 1px solid var(--mkw-border);
}
.mkw-cheat .mkw-cheat-control {
  display: grid;
  align-content: start;
  gap: .35rem;
  min-width: 0;
  margin: 0;
}
.mkw-cheat .mkw-cheat-control label {
  color: var(--mkw-fg);
  font: 600 .85rem/1.35 var(--font-ui);
}
/* Shared dark controls; native select menus and number spinners use dark mode. */
.mkw-cheat .mkw-cheat-control select,
.mkw-cheat .mkw-cheat-control input {
  width: 100%;
  min-width: 0;
  min-height: 2.3rem;
  margin: 0;
  padding: .3rem .5rem;
  border: 1px solid var(--mkw-input-border);
  border-radius: 4px;
  background-color: var(--mkw-input-bg);
  color: var(--mkw-fg);
  color-scheme: dark;
}
.mkw-cheat .mkw-cheat-control select option,
.mkw-cheat .mkw-cheat-control select optgroup {
  background-color: var(--mkw-input-bg);
  color: var(--mkw-fg);
}
.mkw-cheat .mkw-cheat-control input[type="color"] {
  padding: .13rem;
  cursor: pointer;
}
.mkw-cheat .mkw-cheat-help {
  font: 400 .75rem/1.35 var(--font-ui);
  color: var(--mkw-subtle);
}

/* Override the global `pre { border: 2px solid ... }` from your site CSS. */
.mkw-cheat pre.mkw-cheat-code {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: .7rem .85rem;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: var(--mkw-surface);
  color: var(--mkw-fg);
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  tab-size: 2;
  font: 400 .88rem/1.65 var(--font-mono);
}
.mkw-cheat pre.mkw-cheat-code code {
  font: inherit;
  white-space: inherit;
  background: transparent;
  color: inherit;
  margin: 0;
  padding: 0;
}

/* Temporary copy/error feedback appears in the toolbar, never a footer bar. */
.mkw-cheat .mkw-cheat-feedback {
  display: block;
  flex-basis: 100%;
  color: var(--mkw-subtle);
  font: 400 .79rem/1.5 var(--font-ui);
  margin: 0;
}
.mkw-cheat .mkw-cheat-feedback:empty { display: none; }

/* Text-only expansion control, visually part of the code area. */
.mkw-cheat .mkw-code-expand {
  margin: 0;
  padding: 0 .85rem .7rem;
  background: var(--mkw-surface);
}
.mkw-cheat button.mkw-code-toggle {
  display: inline-block;
  width: auto;
  min-height: 1.5rem;
  margin: 0;
  padding: 0;
  color: var(--color-link);
  background: transparent;
  border: 0;
  border-radius: 0;
  font: 500 .86rem/1.5 var(--font-ui);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: .14em;
  cursor: pointer;
}
.mkw-cheat button.mkw-code-toggle:hover {
  color: var(--color-accent);
  background: transparent;
}

@media (max-width: 500px) {
  .mkw-cheat .mkw-cheat-toolbar { gap: .45rem; }
  .mkw-cheat .mkw-region-group { display: contents; }
  .mkw-cheat pre.mkw-cheat-code { font-size: .78rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .mkw-cheat button { transition: background-color .12s ease; }
}

/* Variable-length GameCube controller remapper. Kept inside the existing
   control panel, using exactly the same native dark dropdown styling. */
.mkw-cheat .mkw-remap-builder {
  grid-column: 1 / -1;
  display: grid;
  gap: .65rem;
  min-width: 0;
}
.mkw-cheat .mkw-remap-rows {
  display: grid;
  gap: .5rem;
}
.mkw-cheat .mkw-remap-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: end;
  gap: .45rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--mkw-border);
  min-width: 0;
}
.mkw-cheat .mkw-remap-field {
  display: grid;
  gap: .3rem;
  min-width: 0;
}
.mkw-cheat .mkw-remap-field label {
  color: var(--mkw-fg);
  font: 600 .85rem/1.35 var(--font-ui);
}
.mkw-cheat .mkw-remap-field select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.3rem;
  padding: .3rem .5rem;
  border: 1px solid var(--mkw-input-border);
  border-radius: 4px;
  background: var(--mkw-input-bg);
  color: var(--mkw-fg);
  color-scheme: dark;
}
.mkw-cheat .mkw-remap-field select option {
  background: var(--mkw-input-bg);
  color: var(--mkw-fg);
}
.mkw-cheat .mkw-remap-arrow {
  align-self: end;
  line-height: 2.3rem;
  font-size: 1.1rem;
  color: var(--mkw-subtle);
}
.mkw-cheat .mkw-remap-actions {
  display: flex;
  gap: .2rem;
}
.mkw-cheat .mkw-remap-actions button {
  min-width: 2rem;
  min-height: 2.3rem;
  padding: .25rem .35rem;
}
.mkw-cheat .mkw-remap-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem;
}
.mkw-cheat .mkw-remap-warning {
  flex: 1 1 220px;
  color: #ffd294;
  font: 400 .82rem/1.4 var(--font-ui);
}
.mkw-cheat .mkw-remap-warning:empty { display: none; }
.mkw-cheat .mkw-remap-help {
  color: var(--mkw-subtle);
  margin: 0;
  font: 400 .8rem/1.5 var(--font-ui);
}
@media (max-width: 680px) {
  .mkw-cheat .mkw-remap-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: .4rem;
  }
  .mkw-cheat .mkw-remap-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .mkw-cheat .mkw-remap-actions button { min-height: 1.9rem; }
}
