:root {
  --bg: #0c0d12;
  --bg-panel: #14151c;
  --ink: #eef0f6;
  --ink-dim: #8b8fa3;
  --accent: #3f5ee0;
  --accent-bright: #6c86ff;
  --ok: #37c98f;
  --warn: #e0a53f;
  --err: #e05a5a;
  --radius: 14px;
  --font-display: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 50% -10%, #1b1e2b 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--font-display);
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(12,13,18,0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-mark {
  color: var(--accent-bright);
  font-size: 14px;
}

.brand-name {
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--ink-dim);
  white-space: nowrap;
}
.status-pill.status-loading { color: var(--warn); border-color: rgba(224,165,63,0.35); }
.status-pill.status-ready   { color: var(--ok);   border-color: rgba(55,201,143,0.35); }
.status-pill.status-error   { color: var(--err);  border-color: rgba(224,90,90,0.35); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }

/* ---------- Stage ---------- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  gap: 14px;
}

.console-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.console {
  position: relative;
  width: min(420px, 88vw);
  aspect-ratio: 750 / 1334;
  user-select: none;
  touch-action: none;
}

.skin {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 30px 60px rgba(0,0,0,0.55));
}

.screen-mount {
  position: absolute;
  left: 7.2%;
  top: 6.52%;
  width: 84.53%;
  height: 31.86%;
  background: #0a0a0a;
  overflow: hidden;
}

#screen {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05060a;
  color: var(--ink-dim);
  font-size: clamp(9px, 2.4vw, 12px);
  text-align: center;
  transition: opacity 0.35s ease;
}
.screen-overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 10%; }

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent-bright);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Hit zones (invisible, positioned over the skin art) ---------- */

.hit {
  position: absolute;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hit:active { background: rgba(255,255,255,0.08); }
.hit:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.dpad-up    { left: 18.80%; top: 63.49%; width: 10.67%; height: 6.00%; border-radius: 6px; }
.dpad-down  { left: 18.80%; top: 75.49%; width: 10.67%; height: 6.00%; border-radius: 6px; }
.dpad-left  { left: 8.13%;  top: 69.49%; width: 10.67%; height: 6.00%; border-radius: 6px; }
.dpad-right { left: 29.47%; top: 69.49%; width: 10.80%; height: 6.00%; border-radius: 6px; }

.btn-a { left: 80.27%; top: 67.69%; width: 11.07%; height: 6.15%; border-radius: 50%; }
.btn-b { left: 62.80%; top: 71.36%; width: 11.07%; height: 6.15%; border-radius: 50%; }

.btn-l { left: 0%;     top: 50.22%; width: 13.73%; height: 4.57%; border-radius: 6px; }
.btn-r { left: 86.13%; top: 50.07%; width: 13.73%; height: 4.57%; border-radius: 6px; }

.btn-start  { left: 54.27%; top: 94.83%; width: 6.27%; height: 3.52%; border-radius: 50%; }
.btn-select { left: 39.33%; top: 94.83%; width: 6.40%; height: 3.52%; border-radius: 50%; }

.btn-menu { left: 47.87%; top: 53.75%; width: 4.27%; height: 2.32%; border-radius: 50%; }

.hint {
  color: var(--ink-dim);
  font-size: 12px;
  font-family: var(--font-mono);
  text-align: center;
  max-width: 480px;
  line-height: 1.6;
}
.hint kbd {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
}

/* ---------- Slide-out menu ---------- */

.menu-scrim {
  position: fixed;
  inset: 0;
  background: rgba(4,4,7,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 30;
}
.menu-scrim.open { opacity: 1; pointer-events: auto; }

.menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  background: var(--bg-panel);
  border-left: 1px solid rgba(255,255,255,0.08);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 18px;
  overflow-y: auto;
}
.menu.open { transform: translateX(0); }

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.menu-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  font-weight: 600;
}

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

.menu-btn, .file-btn {
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.menu-btn:hover, .file-btn:hover { background: rgba(255,255,255,0.08); }
.menu-btn.active { border-color: var(--accent-bright); color: var(--accent-bright); }

.file-btn { width: 100%; }

#volume {
  width: 100%;
  accent-color: var(--accent-bright);
}

.menu-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
}

@media (max-width: 420px) {
  .console { width: 92vw; }
}
