:root {
  --bg: #f3f1ec;
  --text: #22252b;
  --muted: #5d636e;
  --link: #2f6b4f;
  --case: #cfcac2;
  --case-edge: #b5afa5;
  --bezel: #4b5160;
  --brand: #2b3a8f;
  --btn-dark: #2a2c33;
  --btn-ab: #9a2257;
  --panel: #ffffff;
  --border: #dcd8d0;
  --primary: #2f6b4f;
  --primary-text: #ffffff;
  --lcd: #e0f8d0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --text: #e6e7ea;
    --muted: #9aa0aa;
    --link: #8fd3a8;
    --case: #2e3036;
    --case-edge: #24262b;
    --bezel: #1c1e23;
    --brand: #8d9bf0;
    --btn-dark: #0f1013;
    --btn-ab: #b4386f;
    --panel: #1e2024;
    --border: #33363c;
    --primary: #4f9a74;
    --primary-text: #0d1410;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --text: #e6e7ea;
  --muted: #9aa0aa;
  --link: #8fd3a8;
  --case: #2e3036;
  --case-edge: #24262b;
  --bezel: #1c1e23;
  --brand: #8d9bf0;
  --btn-dark: #0f1013;
  --btn-ab: #b4386f;
  --panel: #1e2024;
  --border: #33363c;
  --primary: #4f9a74;
  --primary-text: #0d1410;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header { max-width: 860px; margin: 0 auto 24px; }
h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -0.01em; }
header p { margin: 0; color: var(--muted); }
a { color: var(--link); }

main {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: flex-start;
  justify-content: center;
}

/* ---- the handheld ---- */

.console {
  width: min(100%, 380px);
  background: var(--case);
  border: 1px solid var(--case-edge);
  border-radius: 14px 14px 56px 14px;
  padding: 22px 22px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.bezel {
  position: relative;
  background: var(--bezel);
  border-radius: 10px 10px 34px 10px;
  padding: 22px 30px;
}

#screen {
  display: block;
  width: 100%;
  aspect-ratio: 160 / 144;
  background: var(--lcd);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#drop-hint {
  position: absolute;
  inset: 22px 30px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 600;
}
#drop-hint[hidden] { display: none; }

.brand {
  margin: 10px 0 18px;
  color: var(--brand);
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.02em;
}
.brand span {
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
  margin-left: 6px;
  letter-spacing: 0.1em;
}

.pad {
  display: flex;
  justify-content: space-between;
  align-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pad button, .startselect button {
  border: none;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
}
.dpad button, .dpad .center { background: var(--btn-dark); }
.dpad .up { grid-area: 1 / 2; border-radius: 5px 5px 0 0; }
.dpad .left { grid-area: 2 / 1; border-radius: 5px 0 0 5px; }
.dpad .center { grid-area: 2 / 2; }
.dpad .right { grid-area: 2 / 3; border-radius: 0 5px 5px 0; }
.dpad .down { grid-area: 3 / 2; border-radius: 0 0 5px 5px; }

.ab { display: flex; gap: 14px; transform: rotate(-25deg); }
.round {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--btn-ab);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 700;
}

.startselect {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  justify-content: center;
  column-gap: 18px;
  row-gap: 4px;
  margin-top: 26px;
  touch-action: none;
}
.pill {
  height: 12px;
  border-radius: 6px;
  background: var(--muted);
  transform: rotate(-25deg);
}
.startselect span {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand);
}

.pad button.held, .startselect button.held { filter: brightness(1.5); }

/* ---- side panel ---- */

.panel {
  flex: 1 1 300px;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.status {
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-height: 1.5em;
}
.status strong { color: var(--text); }
.status.error { color: #c0392b; }

.keys { border-collapse: collapse; margin-bottom: 16px; }
.keys caption {
  text-align: left;
  font-weight: 700;
  margin-bottom: 6px;
}
.keys td { padding: 3px 14px 3px 0; }
kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 6px;
  margin-right: 3px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.note { color: var(--muted); font-size: 13px; margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
