/* Grover Arcade — Shared Design System (Hub, PIN Auth, Modals, Admin Shell) */

:root {
  --bg: #050918;
  --bg-2: #0a1332;
  --surface: rgba(13, 24, 62, 0.78);
  --surface-solid: #0c173d;
  --surface-hi: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.13);
  --border-hi: rgba(255, 204, 0, 0.45);
  --cobalt: #060ce9;
  --cobalt-deep: #04088a;
  --cobalt-bright: #1b28ff;
  --gold: #ffcc00;
  --gold-deep: #d69f4c;
  --gold-ink: #171200;
  --text: #f2f5ff;
  --muted: #98a9d6;
  --good: #2ee59d;
  --bad: #ff5c77;
  --amber: #ffb020;
  --radius: 14px;
  --display: 'Anton', 'Oswald', Impact, 'Arial Narrow', sans-serif;
  --cond: 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --serif: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --ui: system-ui, -apple-system, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font: 16px/1.45 var(--ui);
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Studio ambient lighting */
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 38% at 20% 10%, rgba(6, 12, 233, 0.36), transparent 70%),
    radial-gradient(40% 42% at 85% 82%, rgba(27, 40, 255, 0.22), transparent 72%),
    radial-gradient(28% 24% at 50% 0%, rgba(255, 204, 0, 0.11), transparent 68%);
  animation: studioDrift 32s ease-in-out infinite alternate;
}
@keyframes studioDrift {
  to { transform: translate3d(2.5%, -2%, 0) scale(1.06); }
}

h1, h2, h3 { margin: 0; line-height: 1.08; }
h1 {
  font-family: var(--display);
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.65), 0 0 28px rgba(255, 204, 0, 0.22);
}
h2 {
  font-family: var(--cond);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}
p { margin: 0; }
a { color: var(--gold); }

.eyebrow {
  font: 700 12px/1 var(--cond);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
.lede { color: var(--muted); font-size: 18px; }
.small { color: var(--muted); font-size: 14px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  font: 700 16px/1 var(--cond); letter-spacing: 0.04em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
  color: var(--text);
  background: linear-gradient(180deg, #1b349e, #10216b);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer; touch-action: manipulation;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn:disabled { opacity: 0.36; cursor: default; }
.btn:focus-visible, .tile:focus-visible, .tab:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.btn.primary {
  background: linear-gradient(180deg, #ffd83d, #e0a800);
  color: var(--gold-ink);
  border-color: rgba(255, 240, 160, 0.6);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.good {
  background: linear-gradient(180deg, #3df2a9, #1db879);
  color: #022b19;
  border-color: rgba(255, 255, 255, 0.3);
}
.btn.bad {
  background: linear-gradient(180deg, #ff6e87, #d93855);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: none;
}
.btn.ghost:active:not(:disabled) { transform: scale(0.97); }
.btn.small { min-height: 40px; padding: 7px 13px; font-size: 14px; border-radius: 9px; }
.btn.big { min-height: 56px; padding: 13px 26px; font-size: 20px; border-radius: 13px; }
.btn.armed { background: linear-gradient(180deg, #ff6e87, #d93855); color: #fff; border-color: #ff9eb0; }
@media (hover: hover) { .btn:hover:not(:disabled) { filter: brightness(1.12); } }

input, textarea, select {
  font: inherit; color: var(--text); width: 100%;
  min-height: 46px; padding: 10px 14px;
  background: rgba(3, 8, 26, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); }
input[type='checkbox'] { width: 24px; height: 24px; min-height: 0; padding: 0; accent-color: var(--gold); cursor: pointer; }
textarea { resize: vertical; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: #6779aa; }
.field { display: grid; gap: 6px; text-align: left; }
.field > span { font: 700 13px/1.2 var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 46px; font-weight: 600; cursor: pointer; }

/* ---------- toast & feedback ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 120;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  padding: 12px 22px; border-radius: 999px;
  font: 700 15px var(--cond); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--gold); color: var(--gold-ink);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transition: transform 0.24s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.shake { animation: shake 0.4s; }
@keyframes shake {
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ---------- modals ---------- */
.modal {
  padding: 0; border: 0; background: transparent; color: var(--text);
  width: min(580px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
.modal::backdrop { background: rgba(2, 5, 16, 0.78); backdrop-filter: blur(6px); }
.modal-box {
  display: grid; gap: 14px; padding: 22px;
  max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #10205c, #09133a);
  border: 1.5px solid rgba(255, 204, 0, 0.25);
  border-radius: 20px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.7);
  animation: pop 0.26s cubic-bezier(0.2, 1.35, 0.4, 1);
}
.modal.wide { width: min(800px, calc(100vw - 24px)); }
.rows { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.score-field { width: 120px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 10px var(--c); }
.x {
  width: 40px; height: 40px; flex: none; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); font-size: 22px; line-height: 1;
}
.x.armed { background: var(--bad); color: #fff; font: 700 12px var(--cond); letter-spacing: 0.04em; text-transform: uppercase; width: auto; padding: 0 10px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.dialog-actions .push { margin-right: auto; }
@keyframes pop { from { transform: scale(0.88); opacity: 0; } }

/* ---------- page layout & arcade hub ---------- */
.page {
  max-width: 1200px; margin: 0 auto;
  padding: clamp(16px, 4vw, 44px);
  padding-top: calc(clamp(16px, 4vw, 44px) + env(safe-area-inset-top));
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
  display: grid; gap: 22px;
}
.hub-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hub-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  min-height: 42px; padding: 8px 16px; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 700 15px var(--cond); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: rgba(255, 255, 255, 0.06);
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.tab.on { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.tab.next { color: var(--gold); border-color: var(--gold); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 204, 0, 0.28); transform: scale(1.04); } }

.arcade { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.game-card {
  position: relative; overflow: hidden; display: grid; gap: 10px; align-content: start;
  padding: 22px; min-height: 260px;
  color: var(--text); text-decoration: none;
  background: linear-gradient(155deg, #0d1d75 0%, #081242 62%, #050b29 100%);
  border: 1.5px solid rgba(255, 204, 0, 0.32);
  border-radius: 20px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35), 0 22px 48px rgba(0, 0, 0, 0.45);
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
  animation: rise 0.45s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  animation-delay: calc(var(--i, 0) * 65ms);
}
.game-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.game-card h2 { font-family: var(--display); font-size: 30px; font-weight: 400; color: var(--gold); text-shadow: 0 2px 0 #000; }
.game-card p { color: var(--muted); }
.game-card .go {
  margin-top: auto; padding-top: 12px;
  font: 700 17px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold);
}
a.game-card:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
@media (hover: hover) {
  a.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--gold);
    box-shadow: 0 14px 0 rgba(0, 0, 0, 0.35), 0 28px 56px rgba(6, 12, 233, 0.35);
  }
}
.game-card.soon {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  box-shadow: none;
}
.game-card.soon::before { display: none; }
.game-card.soon h2 { color: var(--text); text-shadow: none; }
.game-card.soon .go { color: var(--muted); }
@keyframes rise { from { transform: translateY(22px) scale(0.97); opacity: 0; } }

/* Mini Jeopardy board icon */
.glyph { width: 112px; height: 74px; margin-bottom: 6px; }
.board-glyph {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 5px;
  background: #02040a; border: 1.5px solid rgba(255, 204, 0, 0.45); border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}
.board-glyph i {
  display: block; border-radius: 3px;
  background: linear-gradient(160deg, var(--cobalt-bright), var(--cobalt-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.board-glyph i:nth-child(3) { background: var(--gold); animation: wink 2.8s ease-in-out infinite; }
@keyframes wink { 50% { filter: brightness(1.3); transform: scale(1.08); } }
.letter-glyph {
  display: grid; place-items: center; border-radius: 14px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12);
  font: 400 38px var(--display); color: var(--gold);
}

/* Hall of Fame strip */
.hall { display: grid; gap: 12px; margin-top: 8px; }
.hall-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hall-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.hall-item {
  display: grid; gap: 4px; padding: 14px 16px;
  background: rgba(10, 19, 50, 0.72); border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--gold); border-radius: 12px;
}
.hall-item .who { font: 700 18px var(--cond); letter-spacing: 0.03em; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hall-item .meta-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.hall-item .pts { font: 700 15px var(--cond); color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- PIN sign-in ---------- */
.auth {
  width: min(440px, 100%); margin: 5vh auto 0; display: grid; gap: 18px; text-align: center; padding: 32px 28px;
  background: linear-gradient(180deg, #0f1f5c, #081134);
  border: 1.5px solid rgba(255, 204, 0, 0.28);
  border-radius: 26px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.65);
  animation: rise 0.45s both;
}
.logo { display: grid; grid-template-columns: repeat(2, 28px); gap: 5px; justify-content: center; padding: 6px; width: fit-content; margin: 0 auto 2px; background: #03060f; border-radius: 12px; border: 1px solid rgba(255, 204, 0, 0.4); }
.logo span { height: 28px; border-radius: 6px; background: linear-gradient(160deg, var(--cobalt-bright), var(--cobalt-deep)); }
.logo span:nth-child(2) { background: var(--gold); animation: wink 2.8s ease-in-out infinite; }

.pin { display: grid; gap: 22px; justify-items: center; }
.pin.busy { opacity: 0.55; pointer-events: none; }
.pin-dots { display: flex; gap: 16px; justify-content: center; min-height: 28px; align-items: center; }
.pin-dots span {
  width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--gold);
  transition: background 0.12s, transform 0.12s, box-shadow 0.12s;
}
.pin-dots span.on { background: var(--gold); transform: scale(1.18); box-shadow: 0 0 18px rgba(255, 204, 0, 0.75); }
.pin-dots.show { gap: 10px; }
.pin-dots.show span {
  width: 52px; height: 60px; border-radius: 12px; display: grid; place-items: center;
  font: 700 30px/1 var(--cond); color: var(--gold);
  background: rgba(0, 0, 0, 0.35); border-color: rgba(255, 255, 255, 0.22);
}
.pin-dots.show span.on { background: rgba(0, 0, 0, 0.35); border-color: var(--gold); transform: none; box-shadow: none; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; }
.pin-key {
  width: 76px; height: 76px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer; touch-action: manipulation;
  font: 400 32px/1 var(--display); color: var(--gold);
  background: linear-gradient(180deg, #162cb5, #091561);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 5px 0 #04092e, 0 14px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.pin-key:active { transform: translateY(4px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 0 #04092e; }
.pin-key.quiet { background: none; border-color: transparent; box-shadow: none; color: var(--muted); font: 700 24px var(--ui); }
.pin-field { letter-spacing: 0.4em; font-weight: 800; max-width: 9em; font-variant-numeric: tabular-nums; }

/* ---------- admin shell ---------- */
.panel {
  display: grid; gap: 14px; padding: 20px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px;
}
.list-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
}
.list-row .info { flex: 1 1 220px; min-width: 0; display: grid; gap: 3px; }
.list-row .info strong { font: 700 20px var(--cond); letter-spacing: 0.02em; color: var(--gold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.bar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.bar .field { flex: 0 1 240px; }
.bar .spacer { flex: 1; }

@media (max-width: 520px) {
  .auth { margin: 1.5vh auto 0; padding: 22px 18px; gap: 12px; }
  .pin { gap: 14px; }
  .pin-pad { grid-template-columns: repeat(3, 66px); gap: 10px; }
  .pin-key { width: 66px; height: 66px; font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  body::before { animation: none; }
}
