:root {
  --bg: #f2f2f5;
  --card: #ffffff;
  --ink: #0a0a0a;
  --muted: #6c6c74;
  --line: #e5e5ea;
  --ok: #15a34a;
  --bad: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font: 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* header */
header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.game-switcher { display: flex; gap: .4rem; min-width: 0; }
.game-tab {
  display: inline-flex;
  align-items: baseline;
  gap: .45rem;
  padding: .4rem .75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  line-height: 1.2;
}
.game-tab.active { background: var(--ink); border-color: var(--ink); }
.game-tab-name {
  font-size: .9rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: -.005em;
}
.game-tab.active .game-tab-name { color: #fff; cursor: default; }
.game-tab-sep { color: #c8c8d0; font-size: .85rem; user-select: none; }
.game-tab.active .game-tab-sep { color: rgba(255,255,255,.32); }
.game-tab-stats-link {
  font-size: .72rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .02em;
}
.game-tab.active .game-tab-stats-link { color: rgba(255,255,255,.7); }
.game-tab-stats-link:hover { color: var(--ink); }
.game-tab.active .game-tab-stats-link:hover { color: #fff; }

.stats { display: flex; align-items: center; gap: 1.25rem; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.stat-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.stat-value {
  margin-top: 2px;
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.stat-value.bump { transform: scale(1.18); }

.reset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  padding: .35rem .6rem;
  border-radius: 6px;
  cursor: pointer;
}
.reset-btn:hover { color: var(--ink); border-color: #c8c8d0; }

@media (max-width: 480px) {
  .stats { gap: .85rem; }
  .reset-btn { display: none; }
}

/* main + card */
main {
  max-width: 380px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
.stats-page main { max-width: 920px; }

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 110 / 137;
  background: #ececef;
  overflow: hidden;
}

.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .35s ease;
}
.photo.active { opacity: 1; }

.reveal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem 1.25rem 1.1rem;
  background: linear-gradient(to top, rgba(0,0,0,.78) 30%, rgba(0,0,0,0));
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.reveal.show { opacity: 1; transform: translateY(0); }

.name { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.actual { margin-top: .15rem; font-size: .95rem; opacity: .9; }

/* buttons */
.buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  padding: .75rem;
}

.party-btn {
  position: relative;
  padding: .95rem .75rem;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  background: var(--c);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: .01em;
  transition: transform .08s, opacity .2s, filter .2s;
  text-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.party-btn .stance {
  display: block;
  margin-top: 3px;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  opacity: .85;
  text-shadow: none;
}
.party-btn .stance:empty { display: none; }

.party-btn:hover:not(:disabled) { filter: brightness(1.05); }
.party-btn:active:not(:disabled) { transform: scale(.97); }
.party-btn:disabled { cursor: default; opacity: .25; filter: grayscale(.3); }
.party-btn.correct { opacity: 1; filter: none; animation: pulse .5s ease; }
.party-btn.wrong   { opacity: 1; filter: none; }

.party-btn.correct::after, .party-btn.wrong::after {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--card);
}
.party-btn.correct::after { content: "✓"; background: var(--ok); }
.party-btn.wrong::after   { content: "✕"; background: var(--bad); }

@keyframes pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@media (min-width: 480px) {
  .buttons { grid-template-columns: repeat(3, 1fr); }
  .party-btn { font-size: .82rem; padding: .85rem .35rem; }
}

/* countdown */
.countdown {
  height: 3px;
  background: var(--ink);
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
}
.countdown.run {
  opacity: 1;
  animation: cd var(--ms, 1800ms) linear forwards;
}
@keyframes cd {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* status + history */
.status {
  color: var(--muted);
  font-size: .85rem;
  margin: 1.25rem 0 0;
  text-align: center;
}

.history { margin-top: 2.5rem; }
.history h2 {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .75rem;
  padding: 0 .25rem;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.history-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--card);
  padding: .6rem .85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  animation: slide .25s ease;
}
.history-item.correct .history-mark { background: var(--ok); }
.history-item.wrong   .history-mark { background: var(--bad); }
.history-item.correct .history-mark::before { content: "\2713"; }
.history-item.wrong   .history-mark::before { content: "\2715"; }

.history-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #ececef;
}
.history-body { flex: 1; min-width: 0; }
.history-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
@keyframes slide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* footer */
.site-footer {
  margin-top: 3rem;
  padding: 2rem 1rem 2.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
.site-footer .by { font-weight: 600; color: var(--ink); }
.site-footer .footer-row {
  margin: 1rem auto 0;
  display: inline-flex;
  align-items: center;
  gap: .85rem;
  padding: .5rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 4px 14px rgba(0,0,0,.04);
}
.site-footer .footer-row a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.site-footer .footer-row a:hover { color: var(--muted); }
.site-footer .sep { color: var(--line); font-weight: 700; user-select: none; }

/* stats page */
.hero {
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.75rem;
}
.hero h1 {
  font-size: 2.3rem;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 .4rem;
  font-weight: 800;
}
.hero .lede { color: var(--muted); font-size: 1.05rem; margin: 0; }
.hero .lede strong { color: var(--ink); font-weight: 700; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: .75rem;
  margin-bottom: 2rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .85rem 1rem;
}
.kpi-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
}
.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  margin-top: .3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.015em;
}

section.block { margin: 1.75rem 0; }
section.block h2 {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 .75rem;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.2rem;
}
.bar-row {
  display: grid;
  grid-template-columns: 140px 60px 1fr 60px;
  align-items: center;
  gap: .6rem;
  padding: .45rem 0;
}
.bar-row + .bar-row { border-top: 1px solid #f0f0f3; }
.bar-label { font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: .5rem; }
.bar-label .swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.bar-count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track {
  height: 8px;
  background: #f0f0f3;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--c, #999); }
.bar-pct { font-weight: 700; font-size: .9rem; text-align: right; font-variant-numeric: tabular-nums; }

.matrix-wrap { overflow-x: auto; }
.matrix {
  border-collapse: collapse;
  font-size: .85rem;
  width: 100%;
  min-width: 460px;
}
.matrix th, .matrix td {
  padding: .45rem .55rem;
  text-align: center;
  border-bottom: 1px solid #f0f0f3;
}
.matrix th { font-weight: 700; color: var(--muted); }
.matrix td.label { text-align: left; font-weight: 700; }
.matrix td.diag { background: #f4faf6; font-weight: 700; }

.empty {
  color: var(--muted);
  font-size: .9rem;
  padding: 1.5rem 0;
  text-align: center;
}
