/* Layout only. Every color, font and radius comes from the skin (src/skin). */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px 32px;
  min-height: 100dvh;
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* Text */
.logo { font-family: var(--font-display); font-size: 64px; font-weight: 800; margin: 0; color: var(--color-accent); letter-spacing: -1px; }
.logo.small { font-size: 32px; }
.title { font-family: var(--font-display); font-size: 36px; font-weight: 800; margin: 8px 0 0; }
.label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); margin: 8px 0 0; }
.muted { color: var(--color-text-muted); margin: 0; line-height: 1.45; }
.small { font-size: 14px; }

/* Controls */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }

.btn {
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-weight: 700;
  padding: 14px 18px;
  font-size: 17px;
}
.btn.big { padding: 18px; font-size: 19px; }
.btn.ghost { background: var(--color-surface-raised); color: var(--color-text); }
.btn:disabled { opacity: 0.4; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.link { background: none; border: 0; padding: 10px 0; color: var(--color-text-muted); font-weight: 600; font-size: 16px; }

.chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
}

.input {
  width: 100%;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 14px 16px;
  font-size: 18px;
}
.input:focus { outline: none; border-color: var(--color-accent); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 15px;
}
.tab.selected { background: var(--color-op-selected); color: var(--color-op-selected-text); border-color: var(--color-op-selected); }

/* Welcome */
.welcome { justify-content: center; text-align: center; gap: 20px; }

/* Home */
.games { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.game-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: 22px;
  box-shadow: 0 8px 24px var(--color-shadow);
}
.game-title { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--color-accent); }
.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }

/* Leaderboards */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row {
  display: grid;
  grid-template-columns: 2.2em 1fr auto;
  grid-template-areas: "rank name time" "rank date time";
  align-items: center;
  column-gap: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.row.mine { outline: 2px solid var(--color-accent); }
.rank { grid-area: rank; font-weight: 800; color: var(--color-text-muted); }
.name { grid-area: name; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { grid-area: time; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 18px; }
.date { grid-area: date; }

/* Settings */
.setting { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.setting .label { margin: 0; }
.switch {
  appearance: none;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: var(--color-surface-raised);
  position: relative;
  cursor: pointer;
  margin: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-text);
  transition: transform 0.15s;
}
.switch:checked { background: var(--color-success); }
.switch:checked::after { transform: translateX(20px); }

/* Make 10 */
.m10-play .bar { font-weight: 700; }
.timer { font-family: var(--font-display); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 5.5ch; text-align: right; }
.progress { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 24px; }
.card {
  height: 96px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--color-tile);
  color: var(--color-tile-text);
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 800;
  box-shadow: 0 6px 0 var(--color-shadow);
  transition: opacity 0.2s, transform 0.2s;
}
.card.used { opacity: 0.3; transform: scale(0.92); }
.card.deal { animation: deal 0.35s cubic-bezier(0.2, 0.8, 0.3, 1.2) both; }
.card.leave, .solution.leave { animation: leave 0.25s ease-in forwards; }

.solution {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px;
  min-height: 64px; padding: 8px; border-radius: var(--radius-md);
  border: 2px dashed var(--color-text-muted);
  transition: border-color 0.2s, background 0.2s;
}
.solution.yes { border-style: solid; border-color: var(--color-success); }
.solution.no { animation: shake 0.35s; }
.token { transition: transform 0.1s; }
.token.enter { animation: pop 0.18s ease-out; }
.token {
  min-width: 44px; height: 48px; padding: 0 8px; border: 0; border-radius: var(--radius-md);
  background: var(--color-op); color: var(--color-op-text);
  font-family: var(--font-display); font-size: 28px; font-weight: 800;
}
.token.num { background: var(--color-tile); color: var(--color-tile-text); }

.answer { min-height: 1.5em; margin: 0; text-align: center; font-size: 24px; font-weight: 800; }
.answer.yes { color: var(--color-success); }
.answer.no { color: var(--color-danger); }
.answer.show { animation: pop 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.4); }

@keyframes deal { from { opacity: 0; transform: translateY(-16px) scale(0.9); } }
@keyframes leave { to { opacity: 0; transform: translateY(12px) scale(0.95); } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  .card, .solution, .token, .answer, .stats-bar, .choice { animation: none !important; transition: none !important; }
}

.ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.op {
  height: 68px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-op);
  color: var(--color-op-text);
  font-size: 32px;
  font-weight: 700;
}
.op.selected { background: var(--color-op-selected); color: var(--color-op-selected-text); }
.op:disabled { opacity: 0.4; }

.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
.op.paren { font-size: 26px; background: var(--color-surface-raised); color: var(--color-text); }

/* Make 10 setup */
.choices { display: flex; gap: 8px; }
.choice {
  flex: 1; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
  min-height: 52px; padding: 8px 6px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.choice:active { transform: scale(0.97); }
.choice.selected { background: var(--color-op-selected); color: var(--color-op-selected-text); border-color: var(--color-op-selected); }
.choice-title { font-weight: 800; font-size: 16px; }
.choice-note { font-size: 11px; opacity: 0.75; line-height: 1.2; text-align: center; }
.btn.start { margin-top: 8px; }

/* Session stats: faded while playing, full between rounds */
.stats-bar {
  margin-top: auto; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--color-surface); transition: opacity 0.4s;
}
.stats-bar.dim { opacity: 0.15; }
.stats-label { margin: 0 0 4px; font-size: 12px; color: var(--color-text-muted); }
.stats-line { margin: 0; display: flex; gap: 16px; flex-wrap: wrap; font-weight: 700; font-variant-numeric: tabular-nums; }

.overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}
.panel p { margin: 0 0 8px; font-size: 18px; font-weight: 600; }

.m10-end { justify-content: center; text-align: center; }
.big-time { font-family: var(--font-display); font-size: 72px; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; color: var(--color-accent); }
.badge { align-self: center; margin: 0; background: var(--color-success); color: var(--color-success-text); border-radius: 999px; padding: 6px 14px; font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0; }
.stats div { background: var(--color-surface); border-radius: var(--radius-md); padding: 14px; }
.stats dt { color: var(--color-text-muted); font-size: 14px; }
.stats dd { margin: 4px 0 0; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }

