/* GBA-inspired chrome — original styling, no Nintendo assets */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --gba-bg: #0c1410;
  --gba-shell: #1a2820;
  --gba-panel: #f8f8f0;
  --gba-panel-inner: #fffef5;
  --gba-border: #48a0c8;
  --gba-border-dark: #186088;
  --gba-border-outer: #0a3048;
  --gba-text: #202018;
  --gba-name: #2868a8;
  --gba-accent: #40a050;
  --gba-warn: #d04040;
  --gba-blue: #3878c0;
  --hud: #e8f8e0;
  --hud-edge: #78c8f0;
  --pixel: 'Press Start 2P', 'Courier New', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background:
    radial-gradient(ellipse at 50% 0%, #1a3024 0%, var(--gba-bg) 55%);
  color: var(--hud);
  font-family: var(--pixel);
  overflow: hidden;
  user-select: none;
}

#app {
  display: flex; flex-direction: column;
  height: 100%; max-width: 1000px; margin: 0 auto;
  position: relative;
  background: var(--gba-shell);
  box-shadow: 0 0 0 4px #0a100c, inset 0 0 40px rgba(0,0,0,0.35);
}

/* Compact GBA-style HUD bars */
#topbar .brand {
  color: #f0e878; font-size: 8px; letter-spacing: 1px;
  padding: 5px 8px 4px; border: 2px solid #f0e878;
  background: #0e1c14; box-shadow: 2px 2px 0 #061008;
}
#topbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px 6px;
  background:
    linear-gradient(#243830, #15241c);
  border-bottom: 3px solid #3a6850;
  box-shadow: inset 0 -2px 0 #0c1810;
  font-size: 8px; line-height: 1.4; z-index: 5;
}
#topbar .stat {
  background: #0e1c14;
  padding: 5px 8px 4px;
  border: 2px solid var(--hud-edge);
  box-shadow: inset 0 0 0 1px #184060, 2px 2px 0 #061008;
  border-radius: 2px;
  color: #c8e8d0;
}
#topbar .stat b { color: #f0e878; }
#topbar .stat.karma b { color: #78e0a8; }
#topbar button {
  margin-left: auto;
  background: linear-gradient(#5090d0, #2860a0);
  color: #fff;
  border: 2px solid #183868;
  box-shadow: 2px 2px 0 #0a1830, inset 0 1px 0 #88c0f0;
  padding: 6px 10px 5px;
  font-family: inherit; cursor: pointer; font-size: 8px;
}
#topbar button:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 #0a1830; }

#stage-wrap {
  /* Letterboxing: center the integer-scaled LCD; leftover area = bezel */
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; min-height: 0;
  background:
    repeating-linear-gradient(0deg, #0a100c 0 2px, #0e1610 2px 4px);
  padding: 10px;
}

/* Hardware LCD bezel — canvas inside is always 240×160, CSS integer-scaled */
#gba-screen {
  position: relative;
  display: inline-block;
  line-height: 0;
  border: 4px solid #2a4a38;
  box-shadow:
    0 0 0 2px #0a1810,
    0 0 0 6px #3a6850,
    0 0 0 8px #183028,
    4px 6px 0 rgba(0,0,0,0.45);
  background: #000;
}

#game {
  display: block;
  /* Exact integer CSS size set by GW.GBA.applyCssScale() — never auto-fit */
  width: 720px;
  height: 480px;
  max-width: none;
  max-height: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  background: #000;
}

#zone-label {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  background: #f8f8f0;
  color: #202818;
  border: 3px solid var(--gba-border);
  outline: 2px solid var(--gba-border-outer);
  padding: 5px 12px 4px;
  font-size: 8px;
  pointer-events: none; z-index: 3;
  line-height: 1.4;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.35);
  white-space: nowrap;
}

/* Title splash over LCD */
#title-splash.splash {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 16, 24, 0.82);
  line-height: 1.4;
}
#title-splash.hidden { display: none; }
.splash-inner { text-align: center; padding: 16px; }
.splash-title {
  font-size: 12px; color: #f8f8f0; margin-bottom: 10px;
  text-shadow: 2px 2px 0 #186088;
}
.splash-short {
  font-size: 10px; color: #f0e878; margin-bottom: 18px;
  letter-spacing: 2px;
}
.splash-hint {
  font-size: 8px; color: #78c8f0;
  animation: blink 1s step-end infinite;
}

#ctrl-hint {
  text-align: center; font-size: 7px; opacity: 0.55;
  margin: 0; padding: 4px 8px 8px; color: #a8c8b0;
}

/* Dialogue — cream panel, teal/blue border, blink arrow (scaled with LCD) */
#dialogue {
  display: none; position: absolute; left: 4%; right: 4%; bottom: 4%;
  background: var(--gba-panel);
  color: var(--gba-text);
  border: 4px solid var(--gba-border);
  outline: 3px solid var(--gba-border-outer);
  padding: 14px 16px 18px;
  min-height: 96px; z-index: 20;
  font-size: 10px; line-height: 1.65;
  box-shadow:
    inset 0 0 0 3px var(--gba-panel-inner),
    inset 0 0 0 5px #d0e8f0,
    0 4px 0 rgba(0,0,0,0.35);
}
#dialogue .name {
  color: var(--gba-name);
  font-size: 9px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #c8dce8;
}
#dialogue .body { letter-spacing: 0.5px; }
#dialogue .hint {
  position: absolute; right: 12px; bottom: 8px;
  font-size: 10px; color: var(--gba-border-dark);
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.overlay {
  display: none; position: absolute; inset: 0; background: rgba(8,16,12,0.72);
  z-index: 30; align-items: center; justify-content: center; padding: 12px;
}
.overlay.open { display: flex; }
.panel {
  background: var(--gba-panel); color: var(--gba-text);
  border: 4px solid var(--gba-border);
  outline: 3px solid var(--gba-border-outer);
  max-width: 440px; width: 100%; max-height: 90%; overflow: auto;
  padding: 14px; font-size: 9px; line-height: 1.55;
  box-shadow: inset 0 0 0 3px #d8e8f0, 0 6px 0 rgba(0,0,0,0.35);
}
.panel h2 {
  margin: 0 0 10px; font-size: 11px; color: var(--gba-name);
  border-bottom: 2px solid #c8dce8; padding-bottom: 6px;
}
.panel h3 { margin: 14px 0 6px; font-size: 9px; color: #286040; }
.panel .row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 8px 0; border-bottom: 1px dashed #c0c8b0;
}
.panel button, .btn {
  background: linear-gradient(#58b868, #308848);
  color: #fff; border: 2px solid #184828;
  box-shadow: 2px 2px 0 #0c2010, inset 0 1px 0 #98e0a0;
  padding: 7px 10px 6px; font-family: inherit; cursor: pointer; font-size: 8px;
}
.panel button.secondary {
  background: linear-gradient(#5890d0, #2868a8);
  border-color: #183868;
  box-shadow: 2px 2px 0 #0a1830, inset 0 1px 0 #98c8f0;
}
.panel button.danger {
  background: linear-gradient(#e06060, #a02828);
  border-color: #601010;
}
.panel button:disabled { opacity: 0.4; cursor: not-allowed; }
.panel .close-x {
  float: right; background: #687878 !important; border-color: #303838 !important;
  box-shadow: none !important; padding: 4px 8px !important;
}
.panel .note { font-size: 7px; opacity: 0.75; margin-top: 10px; line-height: 1.5; }
.panel .warn { color: var(--gba-warn); font-size: 8px; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.choices button { text-align: left; }

/* GBA chrome D-pad + A/B */
#controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 10px 14px 18px;
  background: linear-gradient(#1e2e26, #121c18);
  border-top: 3px solid #3a6850;
}
.dpad {
  width: 132px; height: 132px;
  position: relative;
  background:
    radial-gradient(circle at 50% 50%, #2a3830 0 28%, transparent 29%),
    #1a2420;
  border: 3px solid #4a6858;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px #0c1410, 3px 3px 0 #0a100c;
}
.dpad button {
  position: absolute;
  width: 40px; height: 40px;
  background: linear-gradient(#3a4a42, #222e28);
  color: #b8d8c0;
  border: 2px solid #586860;
  box-shadow: inset 0 1px 0 #687870, 2px 2px 0 #0a100c;
  font-size: 12px; font-family: inherit; border-radius: 4px;
  padding: 0;
}
.dpad button:active { background: #1a2820; color: #78f0a0; }
.dpad .u { left: 46px; top: 6px; }
.dpad .d { left: 46px; bottom: 6px; }
.dpad .l { left: 6px; top: 46px; }
.dpad .r { right: 6px; top: 46px; }

.ab {
  display: flex; gap: 16px; align-items: center; justify-content: flex-end;
  padding-right: 4px;
}
.ab button {
  width: 62px; height: 62px; border-radius: 50%;
  font-family: inherit; font-size: 12px; font-weight: normal;
  color: #fff;
  border: 3px solid #501020;
  background: radial-gradient(circle at 35% 30%, #f08090, #c03050 55%, #801828);
  box-shadow: 3px 3px 0 #200810, inset 0 2px 0 rgba(255,255,255,0.25);
}
.ab .b-btn {
  width: 54px; height: 54px; margin-top: 18px;
  border-color: #182860;
  background: radial-gradient(circle at 35% 30%, #80a8f0, #3868c0 55%, #183878);
  box-shadow: 3px 3px 0 #081028, inset 0 2px 0 rgba(255,255,255,0.25);
}
.ab button:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 #200810; }

#toast {
  display: none; position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  background: #f8f8f0; color: #202018;
  border: 3px solid var(--gba-border);
  outline: 2px solid var(--gba-border-outer);
  padding: 8px 12px; z-index: 40; font-size: 8px; max-width: 90%;
  line-height: 1.5; box-shadow: 2px 2px 0 rgba(0,0,0,0.4);
}

#age-gate .panel { text-align: center; }
#age-gate .big { font-size: 11px; margin: 12px 0; }

.casino-game { margin-top: 8px; }
.casino-game .cards { font-size: 12px; letter-spacing: 2px; margin: 8px 0; }
.bet-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.bet-row button.active { outline: 2px solid #183018; }

#selfie-preview {
  width: 128px; height: 128px; image-rendering: pixelated;
  border: 3px solid var(--gba-border); outline: 2px solid var(--gba-border-outer);
  background: #000; display: block; margin: 8px auto;
}

@media (min-width: 720px) {
  #controls { display: none; }
  #topbar { font-size: 9px; }
  #topbar .stat { font-size: 8px; }
}
