/* ============================================================
   SHOP RUSH: CHOOSE YOUR ROLE
   Original retro-arcade styling. No external fonts or assets.
   ============================================================ */

:root {
  --bg:        #070a12;
  --bg2:       #0a0e17;
  --panel:     #0e1422;
  --panel2:    #141d31;
  --ink:       #e8f0ff;
  --muted:     #7f93b8;
  --line:      #1d2942;

  --neon:      #2de2e6;   /* cyan      */
  --neon2:     #ff4d8d;   /* magenta   */
  --neon3:     #ffd23f;   /* amber     */
  --neon4:     #51e898;   /* green     */
  --neon5:     #9b6dff;   /* violet    */
  --danger:    #ff5252;

  --advisor:   #2de2e6;
  --technician:#ffd23f;
  --owner:     #51e898;

  --glow: 0 0 8px currentColor, 0 0 18px currentColor;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Courier New", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% -10%, #16213d 0%, transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,0.18) 3px 4px),
    var(--bg);
}

/* ===================== STAGE / CANVAS ===================== */
#stage {
  position: relative;
  width: min(100vw, 100vh * 0.86);
  max-width: 760px;
  aspect-ratio: 644 / 588;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-aspect-ratio: 13/16) {
  #stage { width: 100vw; }
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  background: #05070d;
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 0 0 1px #000, 0 18px 60px rgba(0,0,0,0.7), inset 0 0 60px rgba(0,0,0,0.6);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===================== HUD ===================== */
#hud {
  position: absolute;
  top: -2px; left: 50%;
  transform: translate(-50%, -100%);
  width: 100%;
  display: flex;
  gap: 6px;
  align-items: stretch;
  padding: 6px 8px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  font-size: clamp(8px, 1.7vw, 12px);
  flex-wrap: wrap;
}
.hud-cell { display: flex; flex-direction: column; justify-content: center; padding: 2px 6px; min-width: 0; }
.hud-grow { flex: 1 1 90px; }
.hud-label { color: var(--muted); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.12em; }
.hud-value { color: var(--neon); font-weight: bold; text-shadow: var(--glow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { color: var(--muted); font-size: 0.72em; }
.hud-power { color: var(--neon3); }
.goal-track { height: 6px; background: #0a1020; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin: 2px 0; }
.goal-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--neon4), var(--neon)); transition: width 0.25s ease; }
.hud-buttons { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.icon-btn {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 12px;
}
.icon-btn:hover { border-color: var(--neon); color: var(--neon); }

/* ===================== TOASTS ===================== */
#toasts {
  position: absolute;
  top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none; z-index: 40; width: 90%;
}
.toast {
  background: rgba(10,16,28,0.92);
  border: 1px solid var(--neon3);
  color: var(--neon3);
  padding: 7px 14px; border-radius: 20px;
  font-size: clamp(9px, 2.2vw, 13px);
  text-shadow: var(--glow);
  box-shadow: 0 0 18px rgba(255,210,63,0.3);
  animation: toastIn 0.3s ease, toastOut 0.4s ease 2.4s forwards;
  white-space: nowrap;
}
.toast.good { border-color: var(--neon4); color: var(--neon4); box-shadow: 0 0 18px rgba(81,232,152,0.3); }
.toast.bad  { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ===================== TOUCH CONTROLS ===================== */
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}
.dpad {
  position: absolute;
  left: 14px; bottom: 14px;
  width: 150px; height: 150px;
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
}
.dbtn {
  background: rgba(20,29,49,0.82);
  border: 1px solid var(--neon);
  color: var(--neon);
  border-radius: 10px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  user-select: none; touch-action: none;
  box-shadow: 0 0 10px rgba(45,226,230,0.25);
}
.dbtn:active { background: var(--neon); color: #001; }
.dbtn.up    { grid-column: 2; grid-row: 1; }
.dbtn.left  { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down  { grid-column: 2; grid-row: 3; }
.action-cluster {
  position: absolute;
  right: 16px; bottom: 22px;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  pointer-events: auto;
}
.round-btn {
  width: 84px; height: 84px; border-radius: 50%;
  background: rgba(20,29,49,0.82);
  border: 2px solid var(--neon3); color: var(--neon3);
  font-size: 15px; font-weight: bold; letter-spacing: 0.1em;
  box-shadow: 0 0 16px rgba(255,210,63,0.3);
  touch-action: none; user-select: none;
}
.round-btn:active { background: var(--neon3); color: #001; }
.round-btn.small { width: 52px; height: 52px; border-color: var(--muted); color: var(--muted); font-size: 13px; box-shadow: none; }

/* ===================== SCREENS ===================== */
.screen {
  position: fixed; inset: 0; z-index: 50;
  display: none;
  align-items: center; justify-content: center;
  padding: 18px;
}
.screen.active { display: flex; }
.screen.overlay { background: rgba(4,6,12,0.82); backdrop-filter: blur(3px); }
.hidden { display: none !important; }

.screen-inner {
  width: min(560px, 96vw);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 2px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 0 1px #000, 0 26px 80px rgba(0,0,0,0.7), inset 0 0 40px rgba(0,0,0,0.4);
  padding: 26px 24px;
  position: relative;
  max-height: 94vh;
  overflow-y: auto;
}
.screen-inner.wide { width: min(860px, 96vw); }
.screen-inner.narrow { width: min(420px, 94vw); }
.screen-inner.center { text-align: center; }

/* START SCREEN */
.logo { text-align: center; margin-bottom: 4px; }
.title {
  font-size: clamp(38px, 11vw, 78px);
  font-weight: 900; letter-spacing: 0.08em; line-height: 0.9;
  color: var(--neon3);
  text-shadow: 0 0 10px var(--neon3), 0 0 28px rgba(255,210,63,0.6), 4px 4px 0 var(--neon2);
  animation: flicker 4s infinite;
}
.subtitle {
  text-align: center; color: var(--neon); letter-spacing: 0.55em;
  font-size: clamp(11px, 3vw, 18px); margin-top: 6px; text-shadow: var(--glow);
}
@keyframes flicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.72; }
}
.tagline { text-align: center; color: var(--muted); font-style: italic; margin: 16px 0 20px; font-size: clamp(11px, 2.6vw, 15px); }
.blurb { text-align: center; color: var(--neon4); margin-top: 18px; font-size: clamp(10px, 2.4vw, 13px); }
.legal { text-align: center; color: #4a5878; margin-top: 8px; font-size: 10px; }

.menu { display: flex; flex-direction: column; gap: 10px; }
.menu.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.menu-btn {
  appearance: none; cursor: pointer;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 13px 16px; font: inherit; font-weight: bold;
  letter-spacing: 0.12em; transition: all 0.12s ease;
}
.menu-btn:hover { border-color: var(--neon); color: var(--neon); box-shadow: 0 0 14px rgba(45,226,230,0.25); transform: translateY(-1px); }
.menu-btn.primary { background: linear-gradient(90deg, var(--neon), var(--neon4)); color: #00131a; border-color: transparent; }
.menu-btn.primary:hover { box-shadow: 0 0 22px rgba(45,226,230,0.55); color: #00131a; }
.menu-btn.danger { color: var(--danger); border-color: rgba(255,82,82,0.4); }
.menu-btn.danger:hover { border-color: var(--danger); box-shadow: 0 0 14px rgba(255,82,82,0.3); }

.back-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font: inherit; margin-bottom: 8px;
}
.back-btn:hover { color: var(--neon); }
.screen-title { text-align: center; color: var(--neon3); letter-spacing: 0.2em; margin-bottom: 18px; text-shadow: var(--glow); font-size: clamp(18px, 5vw, 28px); }
.danger-text { color: var(--danger); }
.win-text { color: var(--neon4); }
.hint { color: var(--muted); text-align: center; margin-top: 16px; font-size: 12px; }

/* ROLE GRID */
.role-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 620px) { .role-grid { grid-template-columns: repeat(3, 1fr); } }
.role-card {
  background: var(--panel); border: 2px solid var(--line);
  border-radius: 12px; padding: 16px; cursor: pointer; text-align: center;
  transition: all 0.15s ease; position: relative; overflow: hidden;
}
.role-card:hover:not(.locked) { transform: translateY(-3px); }
.role-card .role-emoji { font-size: 40px; }
.role-card h3 { margin: 8px 0 4px; letter-spacing: 0.1em; }
.role-card .role-goal { color: var(--muted); font-size: 11px; min-height: 28px; }
.role-card .role-metric { font-size: 11px; margin-top: 8px; }
.role-card.advisor { --rc: var(--advisor); }
.role-card.technician { --rc: var(--technician); }
.role-card.owner { --rc: var(--owner); }
.role-card:not(.locked) { border-color: color-mix(in srgb, var(--rc) 40%, var(--line)); }
.role-card:not(.locked):hover { border-color: var(--rc); box-shadow: 0 0 22px color-mix(in srgb, var(--rc) 35%, transparent); }
.role-card:not(.locked) h3 { color: var(--rc); text-shadow: 0 0 10px var(--rc); }
.role-card.locked { opacity: 0.55; cursor: not-allowed; }
.role-card.locked::after {
  content: "🔒 " attr(data-lock);
  position: absolute; inset: auto 0 0 0; padding: 6px;
  background: rgba(0,0,0,0.6); font-size: 10px; color: var(--muted);
}

/* TABS */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
.tabs.sub .tab { font-size: 11px; padding: 5px 10px; }
.tab {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 13px; cursor: pointer; font: inherit; font-size: 12px;
}
.tab.active { color: #001; background: var(--neon); border-color: var(--neon); }
.tab:hover:not(.active) { color: var(--neon); border-color: var(--neon); }

/* LEADERBOARD */
.lb-search { display: flex; gap: 8px; align-items: center; margin: 6px 0 12px; }
.lb-search input { flex: 1; }
.lb-source { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 12px; padding: 3px 8px; white-space: nowrap; }
.lb-table-wrap { max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lb-table th, .lb-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.lb-table th { position: sticky; top: 0; background: var(--panel2); color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.1em; }
.lb-table tbody tr:hover { background: rgba(45,226,230,0.06); }
.lb-rank { color: var(--neon3); font-weight: bold; }
.lb-rank.top { text-shadow: var(--glow); }
.lb-score { color: var(--neon4); font-weight: bold; text-align: right; }
.lb-empty { text-align: center; color: var(--muted); padding: 30px; }
.lb-me { background: rgba(255,210,63,0.08); }

/* ACHIEVEMENTS */
.ach-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .ach-grid { grid-template-columns: 1fr 1fr; } }
.ach {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.ach .ach-icon { font-size: 28px; filter: grayscale(1) brightness(0.6); }
.ach.unlocked { border-color: var(--neon3); box-shadow: 0 0 14px rgba(255,210,63,0.15); }
.ach.unlocked .ach-icon { filter: none; }
.ach h4 { font-size: 13px; letter-spacing: 0.08em; }
.ach.unlocked h4 { color: var(--neon3); }
.ach p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ach .ach-state { margin-left: auto; font-size: 10px; color: var(--muted); }
.ach.unlocked .ach-state { color: var(--neon4); }

/* HOW TO PLAY */
.howto { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 640px) { .howto { grid-template-columns: 1fr 1fr; } }
.howto h3 { color: var(--neon); margin: 14px 0 6px; font-size: 14px; letter-spacing: 0.1em; }
.howto h3:first-child { margin-top: 0; }
.howto p { font-size: 12px; color: #b9c7e6; line-height: 1.55; }
.kv { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.kv li { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.kv b { color: var(--neon3); }
.kv span { color: var(--muted); }

/* SETTINGS */
.settings { display: flex; flex-direction: column; gap: 14px; }
.toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 13px; }
.toggle input { display: none; }
.switch { width: 46px; height: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; position: relative; transition: all 0.15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: all 0.15s; }
.toggle input:checked + .switch { background: rgba(45,226,230,0.25); border-color: var(--neon); }
.toggle input:checked + .switch::after { left: 24px; background: var(--neon); box-shadow: var(--glow); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.field input { font: inherit; }
input[type="text"], input[type="url"] {
  background: #070b14; border: 1px solid var(--line); color: var(--ink);
  border-radius: 7px; padding: 9px 11px; font: inherit; font-size: 13px; width: 100%;
}
input:focus { outline: none; border-color: var(--neon); box-shadow: 0 0 10px rgba(45,226,230,0.25); }
.version { color: #4a5878; font-size: 10px; text-align: center; margin-top: 6px; }

/* READY */
.ready-level { color: var(--neon); letter-spacing: 0.4em; font-size: 14px; }
.ready-name { color: var(--neon3); margin: 8px 0 16px; font-size: clamp(20px, 6vw, 32px); text-shadow: var(--glow); }
.ready-go { color: var(--neon4); letter-spacing: 0.3em; animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* GAME OVER / VICTORY */
.go-rank { color: var(--neon3); font-size: clamp(16px, 4.5vw, 24px); margin: 6px 0 16px; text-shadow: var(--glow); letter-spacing: 0.1em; }
.win-rank { color: var(--neon4); }
.go-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; font-size: 13px; }
.go-stats .gs { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 2px; }
.go-stats .gs b { color: var(--neon); }
.trophy { font-size: 56px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* SUBMIT */
.submit-score { text-align: center; color: var(--neon4); font-size: 20px; margin-bottom: 14px; text-shadow: var(--glow); }
.submit-form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.submit-actions { display: flex; gap: 10px; margin-top: 6px; }
.submit-actions .menu-btn { flex: 1; }
.submit-status { text-align: center; font-size: 12px; min-height: 16px; }
.submit-status.ok { color: var(--neon4); }
.submit-status.err { color: var(--danger); }

/* SHARE */
#share-card { width: 100%; max-width: 560px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 12px; }
.share-text { font-size: 12px; color: #b9c7e6; margin-bottom: 14px; line-height: 1.5; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 600px) {
  .screen-inner { padding: 20px 16px; }
  #hud { font-size: 9px; }
}
