/* oxGBC web front — ch8go's polish (VT323, control bars, dark LCD, overlays,
   GitHub corner) wrapped in a Game Boy Color ("Grape" purple) body. */

:root {
  --terminal-color: #ffffff;
  --shell: #8a5fc4;
  --shell-2: #6b3fa8;
  --shell-edge: #4a2b7e;
  --shell-hi: rgba(255,255,255,0.22);
  --screen-frame: #2b2b32;
  --screen-frame-2: #17171c;
  --btn-ab: #9b2257;
  --btn-ab-dark: #6f1740;
  --dpad: #232326;
  --dpad-dark: #0f0f11;
  --label: #efe9fb;
}

* { box-sizing: border-box; }

canvas {
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
}

html, body {
  font-family: "VT323", ui-monospace, "Courier New", monospace;
  font-size: 18px;
  line-height: 22px;
  color: var(--terminal-color);
  background: #0b0b0d;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  touch-action: manipulation;   /* disable double-tap-to-zoom, keep scrolling */
}

/* ----- GitHub corner (from ch8go) ----- */
.github-corner:hover .octo-arm { animation: octocat-wave 1500ms ease-in-out infinite; }
@keyframes octocat-wave {
  0%, 10% { transform: rotate(0); }
  20%, 40% { transform: rotate(-25deg); }
  30%, 50% { transform: rotate(10deg); }
  60%, 100% { transform: rotate(0); }
}
@media (max-width: 500px) {
  .github-corner:hover .octo-arm { animation: none; }
  .github-corner .octo-arm { animation: octocat-wave 1500ms ease-in-out infinite; }
}

/* ----- Layout / titles ----- */
.page { margin: 0 auto; display: flex; flex-direction: column; align-items: center; padding: 12px 12px 16px; }
.subtitle { font-size: 0.82rem; color: var(--label); text-align: center; line-height: 1.25; margin: 2px 6px 8px; opacity: 0.9; }
.subtitle > span { display: inline-block; text-align: left; }
.subtitle .brand { font-weight: 800; font-size: 1.5em; letter-spacing: 1px; }
.credit { display: block; text-align: left; font-size: 0.62rem; opacity: 0.75; letter-spacing: 1px; }

/* ----- Game Boy Color body ----- */
.device {
  position: relative;
  width: fit-content;
  min-width: 320px;
  max-width: 96vw;
  background: linear-gradient(165deg, var(--shell) 0%, var(--shell-2) 100%);
  border-radius: 20px 20px 26px 26px;
  padding: 7px 24px 125px;
  border: 1px solid var(--shell-edge);
  box-shadow:
    inset 0 -4px 8px rgba(0,0,0,0.25),
    0 12px 30px rgba(0,0,0,0.55);
  /* Kill text selection / long-press callout so touch controls don't get hijacked */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ----- Control bar (ch8go style) ----- */
.inputs {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
}
.input-group {
  display: flex; align-items: center; gap: 6px; height: 30px; padding: 2px 6px;
  border: 1px solid rgba(255,255,255,0.28); border-radius: 6px; box-shadow: inset 0 0 3px #0003;
  color: var(--label); font-size: 0.85rem;
}
.bezel-btn {
  background: #f4f2f8; border: 1px solid rgba(0,0,0,0.15); box-shadow: 0 2px 0 var(--shell-edge);
  color: var(--shell-edge); border-radius: 5px; cursor: pointer; min-width: 26px; min-height: 26px;
  padding: 2px 6px; font-family: inherit; font-size: 0.85rem; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; outline: none;
}
.bezel-btn.pressed { box-shadow: 0 1px 0 var(--shell-edge); transform: translateY(1px); }
.file-btn { padding: 3px 9px; line-height: 1; display: inline-flex; align-items: center; box-shadow: none; }
.file-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label); }
.file-name:empty { display: none; }   /* no filename shown; only appears on a load error */
#roms {
  padding: 3px 6px; border: 1px solid rgba(0,0,0,0.15); border-radius: 5px; background: #fff; color: var(--shell-edge);
  font-family: inherit; font-size: 0.85rem; cursor: pointer; max-width: 120px;
}
.sound {
  background: #a02d5a; border: none; padding: 0 7px; border-radius: 6px; min-width: 36px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: inherit; font-size: 0.8rem; cursor: pointer; box-shadow: 0 3px 0 #6f1740;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.sound svg { display: block; }
.sound.pressed { box-shadow: 0 1px 0 #6f1740; transform: translateY(2px); }
.sound.off { opacity: 0.8; }
.scale-control { display: flex; align-items: center; gap: 3px; color: var(--label); font-size: 0.85rem; }
.scale-control label { font-size: 0.85rem; }
/* Scale −/+ use the flat bezel-control style (see .screen-frame rules below) */
.bezel-input {
  width: 15px; height: 22px; text-align: center; background: transparent; color: #e9eef4;
  border: none; outline: none; font-family: inherit; font-size: 0.95rem; padding: 0;
}

/* ----- Screen block (dark GBC bezel) ----- */
.screen-frame {
  width: fit-content;
  background: linear-gradient(160deg, var(--screen-frame), var(--screen-frame-2));
  border-radius: 8px;
  padding: 12px;
  margin: 8px auto 4px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.7);
}

/* Controls on the bezel: flat light icons/labels (no pills), like print on a real device */
.screen-frame .inputs { margin: 0 0 10px; gap: 10px; justify-content: center; }
.screen-frame .input-group { border: none; box-shadow: none; padding: 0; height: auto; gap: 6px; color: #e9eef4; }
.screen-frame .scale-control { color: #e9eef4; }
.screen-frame .file-name { color: #cfd6de; }

.screen-frame .bezel-btn,
.screen-frame .sound {
  background: none; border: 1px solid rgba(255,255,255,0.2); box-shadow: none; border-radius: 5px;
  color: #e9eef4; min-width: 26px; min-height: 24px; height: auto; padding: 2px 7px; opacity: 0.9;
  display: inline-flex; align-items: center; justify-content: center;
}
.screen-frame .bezel-btn { font-size: 1.05rem; line-height: 1; }
.screen-frame .scale-control .bezel-btn { min-width: 20px; min-height: 20px; padding: 0 4px; font-size: 1rem; }
.screen-frame .file-btn svg { width: 16px; height: 16px; display: block; }
.screen-frame #pause svg { width: 18px; height: 18px; display: block; }   /* 18 = 9×2 → integer scale, crisp equal bars */
.screen-frame .sound svg { width: 20px; height: 20px; display: block; }
.screen-frame .bezel-btn:hover, .screen-frame .sound:hover { opacity: 1; color: #fff; border-color: rgba(255,255,255,0.45); }
.screen-frame .bezel-btn:active, .screen-frame .sound:active,
.screen-frame .bezel-btn.pressed, .screen-frame .sound.pressed { opacity: 0.5; transform: none; }
.screen-frame .sound.off { opacity: 0.9; }

.screen-frame #roms {
  background: none; border: none; border-bottom: 1px solid rgba(255,255,255,0.22);
  color: #e9eef4; padding: 2px; max-width: 130px; cursor: pointer;
}
.screen-frame #roms option { color: #1a1a1a; }

.screen-wrap { display: flex; align-items: center; justify-content: center; gap: 7px; width: fit-content; margin: 0 auto; }
.screen { background: linear-gradient(180deg, #071017, #0d1418); border-radius: 4px; padding: 4px; position: relative; overflow: hidden; }

/* Power LED + label as a column to the left of the screen (DMG-style) */
.power { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; width: 44px; }
.power-spacer { flex: none; width: 44px; display: flex; align-items: center; justify-content: center; }   /* right bezel: holds Pause, mirrors the power column */
.power .led {
  width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9a9a, #d81414);
  box-shadow: 0 0 6px 1px rgba(224,20,20,0.8);
}
.power .pwr-txt { font-size: 0.4rem; letter-spacing: 0.5px; color: #cfd6de; opacity: 0.85; white-space: nowrap; }
canvas#screen { display: block; margin: 0 auto; width: 320px; max-width: 86vw; height: auto; aspect-ratio: 160 / 144; background: #0d1418; }

.brand { text-align: center; margin-top: 8px; font-style: italic; font-weight: 800; font-size: 1.2rem; color: #f4f2fb; letter-spacing: 0.5px; }
/* Sound | oxGBC | Scale — brand centred, controls on either side */
.brand-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.brand-row .sound { justify-self: start; }
.brand-row .scale-control { justify-self: end; }
.brand-row .brand { margin-top: 0; }
/* Game Boy Color-style per-letter palette (matches assets/logo.svg) */
.brand span { font-weight: 900; }
.brand .c-o { color: #ff3b30; }   /* red */
.brand .c-x { color: #a259ff; }   /* purple */
.brand .c-g { color: #34c759; }   /* green */
.brand .c-b { color: #ffd60a; }   /* yellow */
.brand .c-c { color: #30d5c8; }   /* turquoise */

/* Overlays */
#pause-overlay, .bar-loader { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; background: rgba(0,0,0,0.9); color: #fff; }
#pause-overlay { font-size: 34px; font-weight: 700; letter-spacing: 2px; display: none; }
#pause-overlay.active { display: flex; }
.bar-loader { flex-direction: column; gap: 12px; }
.bar-loader.hidden { display: none; }
.bar { display: flex; border: 2px solid #fff; padding: 4px; gap: 4px; }
.bar span { display: block; width: 12px; height: 20px; opacity: 0.15; animation: fill 1.2s infinite; }
.bar span:nth-child(1){animation-delay:0s}.bar span:nth-child(2){animation-delay:.1s}
.bar span:nth-child(3){animation-delay:.2s}.bar span:nth-child(4){animation-delay:.3s}
.bar span:nth-child(5){animation-delay:.4s}.bar span:nth-child(6){animation-delay:.5s}
.bar span:nth-child(7){animation-delay:.6s}.bar span:nth-child(8){animation-delay:.7s}
@keyframes fill { 0%{background:#fff;opacity:.2} 50%{background:#fff;opacity:1} 100%{background:transparent;opacity:.2} }

/* ----- Game Boy controls ----- */
.gb-controls { display: flex; justify-content: space-between; align-items: center; margin: 35px 4px 4px; }
.gb-controls button { font-family: inherit; touch-action: none; -webkit-tap-highlight-color: transparent; outline: none; }

.dpad { display: grid; grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(3, 32px); filter: drop-shadow(0 3px 3px rgba(0,0,0,0.4)); }
.dpad button { border: none; background: var(--dpad); cursor: pointer; }
.dpad .up { grid-area: 1/2; border-radius: 6px 6px 0 0; }
.dpad .left { grid-area: 2/1; border-radius: 6px 0 0 6px; }
.dpad .mid { grid-area: 2/2; }
.dpad .right { grid-area: 2/3; border-radius: 0 6px 6px 0; }
.dpad .down { grid-area: 3/2; border-radius: 0 0 6px 6px; }
.dpad .mid::after { content: ""; display: block; width: 12px; height: 12px; margin: 10px auto; border-radius: 50%; background: var(--dpad-dark); }
.dpad button.pressed { background: var(--dpad-dark); }

.ab { display: flex; align-items: center; gap: 16px; }
.ab-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ab-wrap .lbl { font-weight: 700; font-size: 0.85rem; color: var(--label); }
.btn-round {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--btn-ab), var(--btn-ab-dark));
  box-shadow: 0 4px 0 var(--btn-ab-dark); color: #f4d3e0; font-weight: 700;
}
.btn-round.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-ab-dark); }
.btn-b { margin-top: 22px; }   /* B low, A high — Game Boy diagonal */

.startselect { display: flex; justify-content: center; gap: 22px; margin: 29px auto 0; }
.pill-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pill-wrap .lbl { font-size: 0.7rem; letter-spacing: 0.5px; color: var(--label); }
.pill { width: 48px; height: 15px; border-radius: 10px; border: none; cursor: pointer; background: #3a3340; box-shadow: 0 3px 0 #1b1820; transform: rotate(-20deg); }
.pill.pressed { transform: rotate(-20deg) translateY(2px); box-shadow: 0 1px 0 #1b1820; }

.speaker {
  position: absolute; right: 18px; bottom: 16px;   /* corner overlay — out of flow, so it won't grow the body */
  width: 90px; height: 90px; border-radius: 50%;
  background-image: radial-gradient(rgba(0,0,0,0.4) 1.6px, transparent 1.9px);
  background-size: 8px 8px;
  background-position: center;
  transform: rotate(-25deg);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.hint { font-size: 0.85rem; opacity: 0.7; text-align: center; padding: 6px 12px 0; }
kbd { background: #1b1d22; border: 1px solid #3a3d44; border-radius: 4px; padding: 1px 5px; }

/* Bundled-ROM attribution / credits */
.rom-credits { max-width: 460px; margin: 12px auto 0; font-size: 0.72rem; line-height: 1.5; color: #9aa0aa; text-align: center; padding: 0 12px; }
.rom-credits ul { list-style: none; padding: 0; margin: 6px 0 0; text-align: left; display: inline-block; }
.rom-credits li { margin: 1px 0; }
.rom-credits a { color: #b9c2cf; text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,0.3); }
.rom-credits a:hover { color: #fff; }

/* ----- Shell color themes (canonical GBC colors) ----- */
.device[data-theme="grape"]     { --shell: #8a5fc4; --shell-2: #6b3fa8; --shell-edge: #4a2b7e; --label: #efe9fb; }
.device[data-theme="teal"]      { --shell: #3fc0cf; --shell-2: #1f97a6; --shell-edge: #0d5560; --label: #04343b; }
.device[data-theme="berry"]     { --shell: #d24b86; --shell-2: #b3346c; --shell-edge: #7a1f48; --label: #fff0f6; }
.device[data-theme="dandelion"] { --shell: #f2cf4c; --shell-2: #e0b52e; --shell-edge: #8a6a10; --label: #4a3908; }
.device[data-theme="kiwi"]      { --shell: #8fc73f; --shell-2: #6fae2c; --shell-edge: #3f6a12; --label: #25390d; }
.device[data-theme="atomic"]    { --shell: #b7b1d8; --shell-2: #9c96c2; --shell-edge: #56507a; --label: #282540; }

.themes { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin: 0; }
/* Shell-colour picker lives on the body, between the D-pad and A/B — one row, up near the screen */
.gb-controls .themes { flex-wrap: nowrap; align-self: flex-start; margin-top: -14px; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid rgba(255,255,255,0.55); box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
}
.swatch.active { outline: 2px solid #fff; outline-offset: 1px; }

/* ----- Mobile: fit within the viewport (no right-side clipping) ----- */
@media (max-width: 480px) {
  .page { padding: 8px 6px 16px; }
  .device {
    min-width: 0;
    max-width: 100vw;
    padding: 8px 10px 92px;
    border-radius: 14px 14px 20px 20px;
  }
  .screen-frame { padding: 8px; }
  /* canvas display width capped so device (canvas + all paddings) fits the screen */
  canvas#screen { max-width: calc(100vw - 124px); }   /* room for the power/pause columns */
  .power, .power-spacer { width: 34px; }
  .power .pwr-txt { display: none; }
  .gb-controls .themes { flex-wrap: wrap; max-width: 78px; margin-top: 0; }
  .speaker { width: 74px; height: 74px; right: 12px; bottom: 12px; }
  .subtitle { font-size: 1rem; }
}
