/* ==========================================================================
   Game Boy theme: DMG shell, 4-shade palette (--gb0 darkest .. --gb3 lightest),
   pixel font, hard borders, classic double-line text boxes.
   ========================================================================== */
[data-theme="gameboy"] {
  --font: 'Press Start 2P', 'Courier New', monospace;
  --fs: 10px; --fs-sm: 9px; --fs-xs: 8px; --fs-lg: 11px; --fs-xl: 14px;
  --text: var(--gb0); --muted: var(--gb1);
  --accent: var(--gb0); --accent-2: var(--gb0); --good: var(--gb0); --warn: var(--gb1);
  --glow: var(--gb1);
  --page-bg: #2b2b2e;
  --device-w: 760px; --device-h: 1040px; --device-aspect: 0.82;

  --btn-bg: var(--gb3); --btn-border: 2px solid var(--gb0); --btn-text: var(--gb0); --btn-radius: 0;
  --btn-shadow: 2px 2px 0 var(--gb1); --btn-shadow-active: 0 0 0 var(--gb1); --btn-hover: none;
  --btn-primary-bg: var(--gb0); --btn-primary-text: var(--gb3); --btn-primary-border: 2px solid var(--gb0);
  --btn-danger-bg: var(--gb1); --btn-danger-text: var(--gb3); --btn-danger-border: 2px solid var(--gb0);
  --btn-ghost-bg: transparent; --btn-ghost-text: var(--gb0);
  --focus-ring: 2px dashed var(--gb0);

  --input-bg: var(--gb3); --input-border: 2px solid var(--gb0); --input-radius: 0; --input-focus: 0 0 0 2px var(--gb1);
  --toggle-off: var(--gb2); --toggle-on: var(--gb0); --toggle-knob: var(--gb3); --toggle-border: 2px solid var(--gb0);
  --chip-bg: var(--gb3); --chip-border: 2px solid var(--gb0); --chip-radius: 0; --chip-on-bg: var(--gb0); --chip-on-text: var(--gb3);
  --badge-radius: 0; --badge-border: 2px solid var(--gb0); --badge-bg: var(--gb3); --badge-text: var(--gb0);
  --bar-bg: var(--gb3); --bar-border: 2px solid var(--gb0); --bar-fill: var(--gb0);
  --rage-fill: var(--gb1); --rage-warn: var(--gb1); --rage-hot: var(--gb0);

  --textbox-bg: var(--gb3); --textbox-border: 4px double var(--gb0); --textbox-border-danger: 4px double var(--gb0); --textbox-border-good: 4px double var(--gb0);
  --textbox-radius: 0; --textbox-shadow: inset 0 0 0 2px var(--gb3), inset 0 0 0 4px var(--gb2); --textbox-text: var(--gb0);
  --speaker-bg: var(--gb0); --speaker-text: var(--gb3);
  --choices-scrim: var(--gb2);
  --sheet-bg: var(--gb3); --sheet-border: 0; --sheet-radius: 0;
  --sheet-head-bg: var(--gb0); --sheet-head-text: var(--gb3); --sheet-head-border: 2px solid var(--gb0); --sheet-close-bg: var(--gb1);
  --card-bg: var(--gb3); --card-border: 4px double var(--gb0); --card-radius: 0; --card-shadow: none;
  --panel-bg: var(--gb3); --panel-border: 2px solid var(--gb0); --panel-radius: 0; --panel-shadow: none; --panel-title: var(--gb0);
  --item-bg: var(--gb3); --item-border: 2px solid var(--gb0); --item-radius: 0; --item-hover: var(--gb2);
  --tab-bg: var(--gb3); --tab-border: 2px solid var(--gb0); --tab-text: var(--gb0); --tab-active-bg: var(--gb0); --tab-active-text: var(--gb3);
  --toast-bg: var(--gb0); --toast-text: var(--gb3); --toast-border: 2px solid var(--gb3);
  --scroll-thumb: var(--gb1);
  --icon-a: var(--gb2); --icon-line: var(--gb0);
}
[data-theme="gameboy"] body { line-height: 1.55; -webkit-font-smoothing: none; font-smooth: never; }
[data-theme="gameboy"] .btn, [data-theme="gameboy"] .tab, [data-theme="gameboy"] .chip, [data-theme="gameboy"] .type-badge { text-transform: uppercase; font-weight: 400; letter-spacing: 0; }
[data-theme="gameboy"] .btn { padding: 8px 10px; position: relative; }
[data-theme="gameboy"] .btn:focus-visible, [data-theme="gameboy"] .btn:hover:not([disabled]) { outline: none; background: var(--gb2); }
[data-theme="gameboy"] .btn.primary:hover:not([disabled]), [data-theme="gameboy"] .btn.primary:focus-visible { background: var(--gb1); }
[data-theme="gameboy"] .choices .choice:focus-visible::before, [data-theme="gameboy"] .choices .choice:hover:not([disabled])::before,
[data-theme="gameboy"] .menu-tile:focus-visible::before, [data-theme="gameboy"] .menu-tile:hover:not([disabled])::before {
  content: '▶'; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 9px; animation: blink 1s steps(2, start) infinite;
}
[data-theme="gameboy"] .toggle .track { border-radius: 0; }
[data-theme="gameboy"] .toggle .track::after { border-radius: 0; box-shadow: none; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--gb3); border: 2px solid var(--gb0); }
[data-theme="gameboy"] .toggle input:checked + .track::after { transform: translateX(20px); }
[data-theme="gameboy"] .sheet-title, [data-theme="gameboy"] .panel-title { text-transform: uppercase; letter-spacing: 0; font-weight: 400; }
[data-theme="gameboy"] .textbox { font-weight: 400; line-height: 1.8; }
[data-theme="gameboy"] .textbox-arrow { color: var(--gb0); font-size: 10px; }
[data-theme="gameboy"] .bar { height: 8px; border-radius: 0; }
[data-theme="gameboy"] .bar > i { border-radius: 0; }
[data-theme="gameboy"] .item-icon { filter: none; }
[data-theme="gameboy"] .chip, [data-theme="gameboy"] .tab { border-radius: 0; }
[data-theme="gameboy"] .sheet-close { border-radius: 0; }

/* ----------------------------------------------------------------- shell -- */
[data-theme="gameboy"] .device {
  background: linear-gradient(180deg, #d4d2cc, #bfbcb4);
  border-radius: 14px 14px 64px 14px;
  padding: 18px 22px 18px;
  box-shadow: inset -4px -6px 0 rgba(0,0,0,.12), inset 3px 3px 0 rgba(255,255,255,.6), 0 18px 40px rgba(0,0,0,.6);
}
[data-theme="gameboy"] .device::before { content: ''; position: absolute; left: 30px; right: 30px; top: 8px; height: 3px; border-top: 2px solid rgba(0,0,0,.12); border-bottom: 2px solid rgba(255,255,255,.4); }
[data-theme="gameboy"] .lid { flex: 0 0 40%; padding: 0; background: none; min-height: 220px; }
[data-theme="gameboy"] .lid-strip, [data-theme="gameboy"] .hinge, [data-theme="gameboy"] .base-strip, [data-theme="gameboy"] .speaker { display: none; }
[data-theme="gameboy"] .bezel-top {
  background: #5f6176;
  border-radius: 10px 10px 0 0;
  padding: 26px 38px 0;
}
[data-theme="gameboy"] .bezel-top::before {
  content: 'DOT MATRIX WITH STEREO SOUND'; position: absolute; top: 8px; left: 38px; right: 38px; text-align: center;
  font: 7px 'Press Start 2P', monospace; color: #bfc0d2; letter-spacing: 1px;
  background: linear-gradient(#8b2a52, #8b2a52) left center / 18% 2px no-repeat, linear-gradient(#25397a, #25397a) left calc(50% + 4px) / 18% 2px no-repeat,
    linear-gradient(#8b2a52, #8b2a52) right center / 18% 2px no-repeat, linear-gradient(#25397a, #25397a) right calc(50% + 4px) / 18% 2px no-repeat;
}
[data-theme="gameboy"] .bezel-top::after { content: ''; position: absolute; left: 13px; top: 46%; width: 9px; height: 9px; border-radius: 50%; background: #ff2a3a; box-shadow: 0 0 6px #ff2a3a; }
[data-theme="gameboy"] .lid-label { display: none; }
[data-theme="gameboy"] .base {
  background: none; padding: 0;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "screen screen" "left right";
  column-gap: 0;
}
[data-theme="gameboy"] .bezel-bottom {
  background: #5f6176;
  border-radius: 0 0 36px 10px;
  padding: 0 38px 30px;
  position: relative;
}
[data-theme="gameboy"] .bezel-bottom::after {
  content: 'RIVALS'; position: absolute; left: 0; right: 0; bottom: -30px; text-align: left; padding-left: 4px;
  font: italic 900 20px 'Nunito', sans-serif; color: #2c3a8c; letter-spacing: .02em;
}
[data-theme="gameboy"] .screen { border-radius: 0; }
[data-theme="gameboy"] .screen-top { border-bottom: 2px dashed var(--gb1); }
[data-theme="gameboy"] .deco { display: flex !important; align-items: center; padding: 34px 0 12px; min-height: 118px; }
[data-theme="gameboy"] .deco-left { justify-content: flex-start; padding-left: 18px; }
[data-theme="gameboy"] .deco-right { justify-content: flex-end; align-items: flex-start; padding-right: 92px; padding-top: 18px; }
[data-theme="gameboy"] .circle-pad, [data-theme="gameboy"] .abxy { display: none; }
[data-theme="gameboy"] .dpad { position: relative; width: 72px; height: 72px; }
[data-theme="gameboy"] .dpad span { position: absolute; background: #222; border-radius: 3px; box-shadow: 2px 3px 0 rgba(0,0,0,.25); }
[data-theme="gameboy"] .dpad span:first-child { left: 24px; top: 0; width: 24px; height: 72px; }
[data-theme="gameboy"] .dpad span:last-child { top: 24px; left: 0; width: 72px; height: 24px; }
[data-theme="gameboy"] .ab { display: flex; gap: 14px; transform: rotate(-25deg); margin-top: -12px; }
[data-theme="gameboy"] .ab span { width: 40px; height: 40px; border-radius: 50%; background: #9a2257; box-shadow: 2px 3px 0 rgba(0,0,0,.3); color: transparent; position: relative; }
[data-theme="gameboy"] .ab span::after { content: attr(class); position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font: 9px 'Press Start 2P', monospace; color: #2c3a8c; text-transform: uppercase; }
[data-theme="gameboy"] .ab .b { margin-top: 22px; }
[data-theme="gameboy"] .gb-grille { position: absolute; right: 22px; bottom: 18px; display: flex; gap: 9px; transform: rotate(-25deg); transform-origin: right bottom; height: 40px; pointer-events: none; }
[data-theme="gameboy"] .gb-grille span { width: 6px; height: 40px; border-radius: 4px; background: #a09d95; box-shadow: inset 1px 1px 0 rgba(0,0,0,.35); }

[data-theme="gameboy"] .screen-top, [data-theme="gameboy"] .screen-bottom { background: var(--gb3); }
[data-theme="gameboy"][data-scanlines="on"] .screen-wrap::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 60;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.07) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.04) 0 1px, transparent 1px 3px);
}

/* Scenes become simple 4-shade patterns */
[data-theme="gameboy"] .scene-bg { background: linear-gradient(180deg, var(--gb3) 0 52%, var(--gb2) 52% 100%); }
[data-theme="gameboy"] .scene-bg::after {
  content: ''; position: absolute; left: 0; right: 0; top: 52%; bottom: 0;
  background-image: radial-gradient(var(--gb1) 1px, transparent 1.5px); background-size: 8px 8px;
}
[data-theme="gameboy"] [data-scene="cave"] .scene-bg, [data-theme="gameboy"] [data-scene="night"] .scene-bg,
[data-theme="gameboy"] [data-scene="deepsea"] .scene-bg, [data-theme="gameboy"] [data-scene="space"] .scene-bg,
[data-theme="gameboy"] [data-scene="haunted"] .scene-bg { background: linear-gradient(180deg, var(--gb1) 0 52%, var(--gb2) 52% 100%); }
[data-theme="gameboy"] [data-scene="sea"] .scene-bg::after, [data-theme="gameboy"] [data-scene="lake"] .scene-bg::after {
  background-image: repeating-linear-gradient(0deg, transparent 0 6px, var(--gb1) 6px 8px);
}

/* Titles */
[data-theme="gameboy"] .logo-main { font-size: clamp(22px, 5vw, 34px); color: var(--gb0); text-shadow: 3px 3px 0 var(--gb2); line-height: 1.2; }
[data-theme="gameboy"] .logo-sub { margin-top: 12px; font-size: 9px; color: var(--gb1); letter-spacing: 2px; }
[data-theme="gameboy"] .press-start { color: var(--gb0); animation: blink 1s steps(2, start) infinite; font-size: 10px; }

@media (max-width: 640px), (max-height: 560px) {
  [data-theme="gameboy"] .device { border-radius: 0; padding: 8px; }
  [data-theme="gameboy"] .bezel-top { padding: 22px 10px 0; }
  [data-theme="gameboy"] .bezel-bottom { padding: 0 10px 10px; border-radius: 0 0 20px 10px; }
  [data-theme="gameboy"] .bezel-bottom::after, [data-theme="gameboy"] .deco, [data-theme="gameboy"] .gb-grille { display: none !important; }
}

[data-theme="gameboy"] .bs-wins .ico, [data-theme="gameboy"] .score-wins .ico, [data-theme="gameboy"] .rare-star, [data-theme="gameboy"] .win-trophy, [data-theme="gameboy"] .recap .ico { color: var(--gb0); }
[data-theme="gameboy"] .device { overflow: hidden; }

/* Pixel icons: every drawn color carries a shade (data-g); map it onto the 4-shade palette. */
[data-theme="gameboy"] .pxi rect[data-g="0"] { fill: var(--gb0); }
[data-theme="gameboy"] .pxi rect[data-g="1"] { fill: var(--gb1); }
[data-theme="gameboy"] .pxi rect[data-g="2"] { fill: var(--gb2); }
[data-theme="gameboy"] .pxi rect[data-g="3"] { fill: var(--gb3); }
