/* ══════════════════════════════════════════════════════════════════
   TABOCKY v2 — styles
   Tokens: midnight felt table, electric cyan ball-light, magenta
   score line, coin gold. Display face: Chakra Petch. Body: Inter.
   ══════════════════════════════════════════════════════════════════ */

:root {
  --felt-0:   #070b14;   /* deepest table */
  --felt-1:   #0d1424;   /* panel base */
  --line:     rgba(148, 180, 255, 0.14);
  --ink:      #eaf2ff;
  --ink-dim:  #8fa3c4;
  --cyan:     #22d3ee;   /* ball light */
  --magenta:  #f43f5e;   /* score line */
  --gold:     #ffc53d;   /* coins */
  --ok:       #34d399;
  --radius:   16px;
  --display:  'Chakra Petch', system-ui, sans-serif;
  --body:     'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--felt-0);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
  touch-action: none;
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 1;
  display: block;
}

.hidden { display: none !important; }

/* ── HUD ─────────────────────────────────────────────────────────── */

#hud {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 5;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 0;
  pointer-events: none;
}

#scoreStrip {
  display: flex; gap: 6px; justify-content: center; flex-wrap: wrap;
}

.chip {
  font-family: var(--display);
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(10, 16, 30, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 6px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.holder { border-color: var(--cyan); box-shadow: 0 0 12px rgba(34, 211, 238, 0.35); }

#incoming {
  margin: 10px auto 0;
  width: max-content;
  font-family: var(--display);
  font-weight: 700; font-size: 14px; letter-spacing: 0.18em;
  color: var(--gold);
  animation: blink 0.4s steps(2) infinite;
  text-shadow: 0 0 14px rgba(255, 197, 61, 0.6);
}
.incoming-arrow { display: inline-block; animation: drop 0.5s ease-in-out infinite alternate; }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes drop  { from { transform: translateY(-3px);} to { transform: translateY(3px);} }

/* ── OVERLAY PANELS ──────────────────────────────────────────────── */

#overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 18px;
  background:
    radial-gradient(120vmax 80vmax at 50% 120%, rgba(34,211,238,0.08), transparent 55%),
    radial-gradient(90vmax 60vmax at 50% -20%, rgba(244,63,94,0.07), transparent 55%);
}
#overlay.hidden { display: none; }

.panel {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(20,29,52,0.92), rgba(10,15,28,0.94));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  text-align: center;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(38px, 11vw, 52px);
  letter-spacing: 0.10em;
  margin: 0 0 2px;
  line-height: 1;
}
.wordmark .o {
  color: var(--cyan);
  display: inline-block;
  text-shadow: 0 0 22px rgba(34,211,238,0.8);
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-7px);} }

.tagline { color: var(--ink-dim); font-size: 13px; margin: 0 0 20px; }

/* random launch flavors for the wordmark */
.wordmark-sub {
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.42em;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
  margin: 2px 0 0 0.42em;      /* offset balances the letter-spacing */
  opacity: 0;
  animation: subIn 0.7s ease 0.25s forwards;
}
.wordmark.kana-main {
  font-family: system-ui, -apple-system, 'Hiragino Sans', 'Yu Gothic', sans-serif;
  letter-spacing: 0.12em;
}
.wordmark-sub.latin {
  font-family: var(--display);
  color: var(--ink-dim);
  text-shadow: none;
}
@keyframes subIn { to { opacity: 1; } }

h2 {
  font-family: var(--display);
  font-size: 20px; letter-spacing: 0.06em;
  margin: 0 0 10px;
}

.hint { color: var(--ink-dim); font-size: 13px; line-height: 1.5; }
.hint.small { font-size: 11px; margin: 12px 0 0; }

.field input {
  width: 100%;
  background: rgba(7, 11, 20, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 17px; font-weight: 600;
  text-align: center;
  padding: 12px;
  outline: none;
  margin-bottom: 14px;
}
.field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }

.btn-col { display: flex; flex-direction: column; gap: 10px; }

.btn {
  font-family: var(--display);
  font-weight: 700; font-size: 15px; letter-spacing: 0.05em;
  color: var(--ink);
  background: rgba(34, 44, 72, 0.75);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 16px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, #10b3cf, #22d3ee);
  color: #04222b;
  box-shadow: 0 6px 22px rgba(34, 211, 238, 0.35);
}
.btn.primary:disabled { filter: grayscale(0.8) brightness(0.6); box-shadow: none; cursor: default; }
.btn.ghost { background: transparent; }
.btn.wallet {
  background: rgba(58, 44, 8, 0.55);
  border-color: rgba(255, 197, 61, 0.35);
  color: var(--gold);
}
.wallet-row { margin-top: 14px; }
.code-row { display: flex; gap: 8px; }
.code-row input {
  flex: 1; min-width: 0;
  background: rgba(7, 11, 20, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 15px; font-weight: 600;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px 8px;
  outline: none;
}
.code-row input:focus { border-color: var(--cyan); }
.code-row .btn { flex: 0 0 auto; padding: 12px 20px; }
.coin { color: var(--gold); }
.pid-row {
  margin-top: 10px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  cursor: pointer;
}
.pid-row:active { color: var(--cyan); }

/* profile modal */
.prof-id { display: flex; align-items: center; justify-content: center; gap: 10px; }
.mono-id {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 20px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(34, 211, 238, 0.4);
}
.prof-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px;
}
.prof-stats div {
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 6px; text-align: center;
}
.prof-stats b { font-family: var(--display); font-size: 16px; display: block; }
.prof-stats span { color: var(--ink-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.prof-h { font-size: 14px; margin: 18px 0 8px; text-align: left; }
.prof-purchases { max-height: 180px; overflow-y: auto; }
.prow {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; padding: 7px 4px;
  border-bottom: 1px solid rgba(148, 180, 255, 0.08);
}
.prow b { color: var(--gold); }
.prow span:first-child { color: var(--ink-dim); }

/* ── LISTS (lobby & waiting room) ────────────────────────────────── */

.list {
  margin: 6px 0 16px;
  max-height: 42vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.list:empty::after {
  content: 'Nothing here yet…';
  color: var(--ink-dim); font-size: 13px; padding: 14px 0; display: block;
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}
.row .grow { flex: 1; text-align: left; font-weight: 600; }
.row .sub  { color: var(--ink-dim); font-size: 12px; }
.row button { padding: 8px 14px; font-size: 13px; }
.row input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--cyan); }

.pulse-ball {
  width: 46px; height: 46px; border-radius: 50%;
  margin: 18px auto;
  background: radial-gradient(circle at 34% 30%, #fff, #9adfef 45%, #22d3ee 75%);
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.55);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.15);} }

.coins-earned {
  font-family: var(--display);
  color: var(--gold);
  font-size: 18px; font-weight: 700;
  margin: 6px 0 14px;
}

/* ── SHOP MODAL ──────────────────────────────────────────────────── */

.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(3, 5, 10, 0.7);
  backdrop-filter: blur(4px);
  padding: 16px;
}
.modal-card {
  width: min(460px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(22,31,56,0.97), rgba(10,15,28,0.98));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
}
.small-card { text-align: center; }
.small-card .btn { width: 100%; margin-top: 10px; }

.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { flex: 1; margin: 0; text-align: left; }
.wallet-chip {
  font-family: var(--display); font-weight: 700;
  color: var(--gold);
  border: 1px solid rgba(255,197,61,0.35);
  border-radius: 999px; padding: 5px 12px; font-size: 14px;
}
.x {
  background: none; border: none; color: var(--ink-dim);
  font-size: 18px; cursor: pointer; padding: 6px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1;
  font-family: var(--display); font-weight: 700; font-size: 12px;
  letter-spacing: 0.05em;
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 4px; cursor: pointer;
}
.tab.active { color: #04222b; background: var(--cyan); border-color: var(--cyan); }

.shop-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.item {
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}
.item.equipped { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.item canvas { width: 64px; height: 64px; display: block; margin: 0 auto 6px; }
.item .nm { font-weight: 600; font-size: 13px; }
.item .pr { font-family: var(--display); font-size: 12px; color: var(--gold); margin: 3px 0 8px; }
.item .btn { width: 100%; padding: 8px; font-size: 12px; border-radius: 10px; }
.item .btn.owned { background: rgba(52, 211, 153, 0.15); border-color: rgba(52,211,153,0.4); color: var(--ok); }

/* ── TOASTS ──────────────────────────────────────────────────────── */

#toasts {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  left: 0; right: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.toast {
  background: rgba(10, 16, 30, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  padding: 8px 16px;
  animation: toastIn 0.25s ease, toastOut 0.4s ease 2.4s forwards;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px);} }
@keyframes toastOut { to   { opacity: 0; transform: translateY(8px);} }

@media (prefers-reduced-motion: reduce) {
  .wordmark .o, .pulse-ball, #incoming, .incoming-arrow { animation: none; }
}

/* ── charge meter (v1 experiments) ───────────────────────────────── */
#charge {
  margin: 8px auto 0;
  width: max-content;
  font-family: var(--display);
  font-weight: 700; font-size: 13px; letter-spacing: 0.14em;
  color: var(--cyan);
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(10, 16, 30, 0.72);
  border: 1px solid var(--line);
}
#charge.full {
  color: var(--gold);
  border-color: rgba(255, 197, 61, 0.5);
  box-shadow: 0 0 16px rgba(255, 197, 61, 0.45);
  animation: blink 0.5s steps(2) infinite;
}

/* ── variant picker (host panel) ─────────────────────────────────── */
.rules-h { font-size: 15px; margin: 14px 0 6px; text-align: left; }
.variant-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.variant {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(7, 11, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.variant.sel { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.variant input { accent-color: var(--cyan); margin-top: 3px; }
.variant b { font-family: var(--display); font-size: 13px; letter-spacing: 0.04em; display: block; }
.variant small { color: var(--ink-dim); font-size: 11px; line-height: 1.45; display: block; margin-top: 2px; }
