:root {
  --primary: #e7508f;
  --primary-dark: #b43e70;
  --primary-soft: #fdeef4;
  --secondary: #04758c;
  --secondary-soft: #e6fafe;
  --bg: #fdf6f8;
  --surface: #ffffff;
  --surface-soft: #fdf1f5;
  --ink: #2b1f28;
  --muted: #75656e;
  --line: #f0dde4;
  --success: #168f63;
  --success-bg: #f0fbf6;

  --radius-card: 16px;
  --radius-control: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 14px 40px rgba(180, 62, 112, 0.10);

  --font-heading: "Baloo 2", ui-rounded, "SF Pro Rounded", sans-serif;
  --font-body: "Nunito", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body { margin: 0; padding: 0; width: 100%; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--font-heading); font-weight: 800; margin: 0; color: var(--ink); }
p { margin: 0; }
button { font-family: inherit; }
input { font-family: inherit; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.btn:focus-visible, .pill:focus-visible, .theme-card:focus-visible,
.winner-btn:focus-visible, .back-link:focus-visible, .text-input:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.wrap { max-width: 680px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.back-link { display: inline-block; font-size: .85rem; font-weight: 600; color: var(--muted); text-decoration: none; margin-bottom: 1rem; }
.back-link:hover { color: var(--primary-dark); }

.hero { margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(24px, 4vw, 32px); letter-spacing: -0.02em; margin-bottom: .35rem; }
.hero p { color: var(--muted); font-size: 14.5px; max-width: 52ch; }

.section { margin-bottom: 1.6rem; }
.section-label { font-family: var(--font-heading); font-weight: 700; font-size: 15px; margin-bottom: .6rem; display: block; }

.name-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.name-field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.text-input {
  width: 100%; border: 2px solid var(--line); border-radius: var(--radius-control);
  padding: 11px 12px; font-size: 14.5px; font-weight: 700; color: var(--ink); background: var(--surface);
}

.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 480px) { .theme-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.theme-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-card);
  padding: 14px 8px; cursor: pointer; text-align: center; transition: border-color .15s, transform .15s, background .15s;
}
.theme-card .icon { font-size: 28px; }
.theme-card .label { font-size: 12.5px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.theme-card:hover { transform: translateY(-1px); border-color: var(--primary); }
.theme-card.active { border-color: var(--primary-dark); background: var(--primary-soft); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-pill);
  padding: 9px 16px; font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.pill.active { border-color: var(--primary-dark); background: var(--primary-soft); color: var(--primary-dark); }
.pill small { font-weight: 500; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-control); padding: 14px 20px;
  font-weight: 800; font-size: 15.5px; cursor: pointer; font-family: var(--font-heading);
  background: var(--primary); color: #fff; box-shadow: var(--shadow-card);
  transition: transform .12s, background .15s; width: 100%;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn.secondary { background: var(--surface); color: var(--primary-dark); border: 2px solid var(--primary-soft); box-shadow: none; }
.btn.secondary:hover { background: var(--primary-soft); }
.btn-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 1.75rem; }

/* ---- round screen ---- */
.round-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.round-badge { font-size: 13px; font-weight: 800; color: var(--muted); }
.round-scores { display: flex; gap: 8px; }
.score-chip {
  border-radius: var(--radius-control); padding: 7px 12px; font-size: 13px; font-weight: 800;
  background: var(--surface); border: 2px solid var(--line); color: var(--ink);
  transition: transform .15s;
}
.score-chip.bump { animation: bump .35s ease; }
@keyframes bump { 0% { transform: scale(1); } 45% { transform: scale(1.12); } 100% { transform: scale(1); } }

.finish-now { background: none; border: none; color: var(--muted); font-size: 12.5px; font-weight: 700; text-decoration: underline; cursor: pointer; }

.prompt-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 24px; text-align: center; box-shadow: var(--shadow-card); margin-bottom: 1rem;
}
.prompt-instruction { font-size: 13.5px; color: var(--muted); font-weight: 700; margin-bottom: 14px; }
.prompt-visual { display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.prompt-visual img { max-width: 100%; max-height: 260px; border-radius: 14px; object-fit: cover; }
.prompt-visual .prompt-emoji { font-size: 110px; line-height: 1; }
.prompt-name { font-size: clamp(20px, 5vw, 28px); font-weight: 800; font-family: var(--font-heading); color: var(--primary-dark); }

.shape-grid { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.shape-cell {
  aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
  font-size: clamp(30px, 7vw, 44px); background: var(--surface-soft); border: 2px solid var(--line);
  border-radius: var(--radius-control);
}

.timer-ring {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%; border: 4px solid var(--primary-soft);
  font-weight: 800; font-size: 16px; color: var(--primary-dark); margin: 0 auto 10px;
}
.timer-ring.low { border-color: #ffd9d9; color: #c0392b; }

.winner-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.winner-btn {
  border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-card);
  padding: 16px; font-family: var(--font-heading); font-weight: 800; font-size: 16px;
  cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s, transform .1s;
}
.winner-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.winner-btn.tie { color: var(--secondary); }

.undo-row { text-align: center; margin-top: 10px; }
.undo-link { background: none; border: none; color: var(--muted); font-size: 12.5px; font-weight: 700; cursor: pointer; text-decoration: underline; }

/* ---- result screen ---- */
.result-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: 28px 20px; text-align: center; box-shadow: var(--shadow-card); margin-bottom: 1.5rem;
}
.result-emoji { font-size: 48px; margin-bottom: 8px; }
.result-title { font-size: 22px; margin-bottom: .5rem; }
.result-stats { display: flex; justify-content: center; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.result-stat { text-align: center; }
.result-stat .num { font-family: var(--font-heading); font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.result-stat .lbl { font-size: 12px; color: var(--muted); font-weight: 700; }

.history-toggle { text-align: center; margin-bottom: 10px; }
.history-toggle button { background: none; border: none; color: var(--primary-dark); font-weight: 700; font-size: 13.5px; cursor: pointer; text-decoration: underline; }
.history-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history-list li {
  display: flex; justify-content: space-between; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px 12px; font-size: 13px;
}
.history-list .h-round { color: var(--muted); font-weight: 700; min-width: 58px; }
.history-list .h-item { flex: 1; }
.history-list .h-winner { font-weight: 800; color: var(--primary-dark); }
