/* Indigo GB — device shell + UI */
:root {
  --screen-bg: #9bbc0f;
  --ink: #26232e;
  --ink-soft: #5c5768;
  --paper: #ecebe6;
  --case-hi: #d8d4c6;
  --case: #c6c2b4;
  --case-lo: #a09c8e;
  --accent: #5b4b8a;
  --accent-hi: #7a68b8;
  --btn-red: #9c2b4a;
  --btn-red-hi: #b8456a;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% -10%, #f7f6f2 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #e4e2f0 0%, transparent 55%),
    var(--paper);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

kbd {
  background: #fff;
  border: 1px solid #cfcbc0;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 0.8em;
  font-family: inherit;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid #d8d5cc;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand h1 {
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  font-weight: 800;
}
.brand h1 span { color: var(--accent); }
.brand-dot {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent-hi), var(--accent));
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25);
}

.rom-badge { flex: 1; min-width: 0; }
.rom-lines { display: flex; flex-direction: column; line-height: 1.15; }
.rom-lines strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rom-lines small { color: var(--ink-soft); font-size: 0.72rem; }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  padding: 26px clamp(14px, 4vw, 48px) 40px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- the device ---------- */
.device { display: flex; justify-content: center; }

.case {
  position: relative;
  width: min(100%, 556px);
  padding: 14px 26px 26px;
  border-radius: 18px 18px 72px 18px;
  background:
    linear-gradient(160deg, var(--case-hi) 0%, var(--case) 45%, var(--case-lo) 130%);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.65),
    inset 0 -3px 6px rgba(0, 0, 0, 0.18),
    0 18px 40px rgba(40, 35, 60, 0.28),
    0 3px 8px rgba(40, 35, 60, 0.18);
  user-select: none;
}

.case-top { display: flex; justify-content: center; margin-bottom: 10px; }
.case-groove {
  width: 74%;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(0,0,0,0.16), rgba(255,255,255,0.35));
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.25);
}

.bezel {
  border-radius: 12px 12px 40px 12px;
  padding: 8px 10px 14px;
  background: linear-gradient(165deg, #43414a, #2c2a32 70%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.35);
}

.bezel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 8px;
  color: #b9b4c9;
  font-size: 0.56rem;
  letter-spacing: 0.22em;
  font-weight: 600;
}
.bezel-label::before,
.bezel-label::after {
  content: "";
  flex: 1;
  height: 3px;
  border-top: 1.5px solid #7b4b8a;
  border-bottom: 1.5px solid #3f7a5a;
}

.screen-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 160 / 144;
  border-radius: 6px;
  background: var(--screen-bg);
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.45),
    inset 0 0 2px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#screen {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* scanlines overlay */
.screen-wrap.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.13) 0px,
    rgba(0, 0, 0, 0.13) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 18, 28, 0.55);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.3em;
  font-size: 1.1rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.power-led {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(0, 0, 0, 0.45);
  font-size: 0.42rem;
  letter-spacing: 0.12em;
  font-weight: 700;
}
.power-led i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e0402a;
  box-shadow: 0 0 6px #e0402a, inset 0 -1px 2px rgba(0,0,0,0.4);
}

.case-brand {
  margin: 12px 4px 6px;
  color: #4b4a55;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.case-brand em {
  font-family: "Gill Sans", "Avenir Next", sans-serif;
  font-style: italic;
  color: var(--accent);
  font-size: 1.05rem;
  margin-right: 4px;
}
.case-brand .tm { font-size: 0.6rem; color: #7a7787; }

/* d-pad + buttons */
.controls-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 0 6px;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
}
.dp {
  border: none;
  background: linear-gradient(160deg, #3d3b45, #26242c 70%);
  cursor: pointer;
  touch-action: none;
}
.dp.up { grid-area: 1 / 2; border-radius: 5px 5px 0 0; }
.dp.left { grid-area: 2 / 1; border-radius: 5px 0 0 5px; }
.dp.center { grid-area: 2 / 2; cursor: default; position: relative; }
.dp.center::after {
  content: "";
  position: absolute; inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #34323c, #1c1a22 75%);
}
.dp.right { grid-area: 2 / 3; border-radius: 0 5px 5px 0; }
.dp.down { grid-area: 3 / 2; border-radius: 0 0 5px 5px; }
.dp.up, .dp.down, .dp.left, .dp.right { box-shadow: inset 0 1px 1px rgba(255,255,255,0.15); }
.dp.pressed { background: linear-gradient(160deg, #1b1a20, #121116); transform: translateY(1px); }

.ab {
  display: flex;
  gap: 18px;
  transform: rotate(-18deg);
  margin-right: 6px;
}
.round-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  touch-action: none;
  background: radial-gradient(circle at 35% 30%, var(--btn-red-hi), var(--btn-red) 65%);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.35),
    inset 0 -3px 5px rgba(0, 0, 0, 0.3),
    inset 0 2px 2px rgba(255, 255, 255, 0.25);
  color: #3c1220;
  font-weight: 800;
  font-size: 0.95rem;
  position: relative;
}
.round-btn span { position: relative; top: 30px; color: #4b4a55; }
.round-btn.pressed {
  transform: translateY(2px);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35),
    inset 0 2px 2px rgba(255, 255, 255, 0.18);
}

.meta-btns {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 22px;
}
.pill {
  width: 58px; height: 16px;
  border: none;
  border-radius: 9px;
  transform: rotate(-18deg);
  background: linear-gradient(180deg, #8f8b7e, #6f6b60);
  box-shadow: 0 2px 4px rgba(0,0,0,0.35), inset 0 1px 1px rgba(255,255,255,0.3);
  color: #4b4a55;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: none;
  position: relative;
}
.pill::after {
  content: attr(aria-label);
  position: absolute;
  top: 20px; left: 50%;
  transform: translateX(-50%) rotate(18deg);
  color: #55535e;
}
.pill.pressed { transform: rotate(-18deg) translateY(2px); box-shadow: 0 1px 2px rgba(0,0,0,0.35); }

.speaker {
  position: absolute;
  right: 22px;
  bottom: 20px;
  display: flex;
  gap: 7px;
  transform: rotate(-18deg);
}
.speaker i {
  width: 6px; height: 52px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(0,0,0,0.28), rgba(0,0,0,0.18));
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.3);
}

.sound-hint {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: rgba(15, 56, 15, 0.75);
  background: rgba(155, 188, 15, 0.55);
  padding: 2px 10px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.4s;
  z-index: 3;
}
.sound-hint.hidden { opacity: 0; }

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #ddd9cf;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 2px 6px rgba(40, 35, 60, 0.06);
}
.card h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
details.card summary { cursor: pointer; list-style: none; }
details.card summary h2 { display: inline; }
details.card summary::-webkit-details-marker { display: none; }

.note { font-size: 0.82rem; line-height: 1.45; color: var(--ink-soft); margin-bottom: 10px; }
.note code { background: #f0eee8; padding: 0 4px; border-radius: 3px; }
.hint { font-size: 0.74rem; color: var(--ink-soft); margin-top: 8px; line-height: 1.5; }

.row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.row:last-child { margin-bottom: 0; }
.btn-row { gap: 8px; }

.btn {
  border: 1px solid #cfcbc0;
  background: linear-gradient(180deg, #ffffff, #f0eee8);
  border-radius: 9px;
  padding: 7px 13px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { background: linear-gradient(180deg, #ffffff, #e8e6df); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 0.78rem; }
.btn.icon { padding: 5px 9px; }
.btn.empty { opacity: 0.55; }

.stats { gap: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.95rem; font-weight: 700; color: var(--accent); }

.field { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 0.85rem; }
.field span { min-width: 58px; color: var(--ink-soft); font-weight: 600; }
.field select {
  flex: 1;
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #cfcbc0;
  background: #fff;
}
.volume-field input[type="range"] { flex: 1; accent-color: var(--accent); }

.check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin-bottom: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f5f3ee;
  border: 1px solid #e2ded4;
  border-radius: 8px;
  padding: 6px 8px;
}
.slot span {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bindings { width: 100%; border-collapse: collapse; margin-top: 10px; }
.bindings td { padding: 4px 0; font-size: 0.83rem; }
.bindings td:last-child { text-align: right; }
.key-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #cfcbc0;
  background: #fff;
  cursor: pointer;
  min-width: 74px;
}
.key-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- overlays ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 26, 44, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.drop-overlay.visible { opacity: 1; }
.drop-box {
  text-align: center;
  color: #fff;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  padding: 46px 60px;
}
.drop-box p { font-size: 1.2rem; margin: 14px 0 6px; }
.drop-box small { color: rgba(255, 255, 255, 0.7); }
.drop-cart {
  width: 46px; height: 52px;
  margin: 0 auto;
  border-radius: 5px 5px 12px 5px;
  background: linear-gradient(160deg, #b9b5a8, #8f8b7e);
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.5), 0 8px 16px rgba(0,0,0,0.4);
  position: relative;
}
.drop-cart::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px; top: 9px; height: 16px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent-hi), var(--accent));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 26, 44, 0.6);
}
.modal.hidden, .hidden { display: none !important; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px 26px;
  max-width: 420px;
  margin: 0 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.modal-box h3 { margin-bottom: 10px; }
.modal-box p { font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); }
.modal-box .error-file {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  margin: 8px 0 16px;
  color: var(--ink);
  word-break: break-all;
}
.modal-box .btn { margin-top: 14px; width: 100%; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 26, 44, 0.92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 22px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 70;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 16px 14px 32px;
  }
  .panel { max-width: 480px; margin: 0 auto; width: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .rom-badge { order: 3; flex-basis: 100%; }
}

@media (max-width: 400px) {
  .case { padding: 10px 14px 20px; }
  .dpad { grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); }
  .round-btn { width: 42px; height: 42px; }
  .speaker i { height: 40px; }
}
