:root {
  --bg: #f6f2f7;
  --card: #ffffff;
  --ink: #2a1d2e;
  --muted: #766b79;
  --brand: #4b1f58;
  --brand-2: #7d4b86;
  --accent: #f2b544;
  --green: #2e8b57;
  --green-soft: #e7f6ed;
  --purple-soft: #efe5f2;
  --border: #e7dfe9;
  --danger: #a63333;
  --shadow: 0 8px 24px rgba(52, 28, 58, .10);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(125,75,134,.12), transparent 30%),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  color: white;
  background: linear-gradient(135deg, var(--brand), #6a3475);
  box-shadow: 0 4px 18px rgba(45, 19, 53, .22);
}
.brand {
  grid-column: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  text-align: left;
}
.brand-mark { font-size: 30px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: .2px; }
.brand small { opacity: .76; font-size: 11px; }
.topbar > .icon-btn:first-child { grid-column: 1; grid-row: 1; }
.topbar > .icon-btn:last-child { grid-column: 3; grid-row: 1; }

main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 16px 14px calc(40px + env(safe-area-inset-bottom));
}
.screen { animation: fade .22s ease; }
.hidden { display: none !important; }

.card {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero { overflow: hidden; }
.hero-art {
  display: flex;
  justify-content: space-around;
  align-items: center;
  min-height: 110px;
  margin: -18px -18px 18px;
  padding: 18px;
  font-size: clamp(38px, 11vw, 66px);
  background: linear-gradient(135deg, #f7d98f, #efe2f2);
}
.hero-art span:nth-child(2) { transform: translateY(-8px) rotate(-6deg); }
.hero-art span:nth-child(3) { transform: translateY(8px) rotate(10deg); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 7vw, 38px); line-height: 1.05; }
h2 { margin-bottom: 6px; font-size: 20px; }
p { color: var(--muted); line-height: 1.45; }

label {
  display: block;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
input, select {
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9cedc;
  border-radius: 14px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(125,75,134,.14);
}

.primary, .secondary, .small-btn, .icon-btn {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
}
.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #71377d);
  box-shadow: 0 6px 14px rgba(75,31,88,.24);
}
.secondary {
  color: var(--brand);
  background: var(--purple-soft);
}
.wide { width: 100%; }
.compact { min-height: 38px; padding: 0 14px; }
.small-btn { min-height: 36px; padding: 0 12px; color: var(--brand); background: var(--purple-soft); }
.icon-btn {
  width: 42px;
  min-height: 42px;
  color: inherit;
  background: rgba(255,255,255,.13);
  font-size: 22px;
}
.card .icon-btn { color: var(--ink); background: #f5eff6; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  color: #63460f;
  background: #fff4d8;
  border: 1px solid #f1d590;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.game-code-card { text-align: center; }
.game-code-card span { display: block; color: var(--muted); font-size: 13px; }
.game-code-card strong {
  display: block;
  margin: 4px 0 12px;
  font-size: 38px;
  letter-spacing: 6px;
  color: var(--brand);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.section-heading p { margin: 0; font-size: 13px; }
.player-list, .progress-list { display: grid; gap: 10px; margin-top: 14px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: #faf7fb;
  border: 1px solid var(--border);
  border-radius: 14px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  color: white;
  background: var(--brand-2);
  border-radius: 50%;
  font-weight: 900;
}
.player-row .player-meta { flex: 1; min-width: 0; }
.player-row strong, .player-row small { display: block; }
.player-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row small { color: var(--muted); }
.host-badge {
  padding: 4px 8px;
  color: #6d4b0a;
  background: #fff0c9;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.add-row input { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  background: #f5eff6;
  border-radius: 999px;
  font-size: 13px;
}
.chip button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--danger);
  background: white;
  border: 0;
  border-radius: 50%;
}
.center { text-align: center; }
.pulse { font-size: 42px; animation: pulse 1.4s infinite; }

.score-strip {
  position: sticky;
  top: 76px;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  color: white;
  background: rgba(75,31,88,.96);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.score-strip small, .score-strip strong { display: block; }
.score-strip small { opacity: .75; font-size: 11px; }
.score-strip strong { font-size: 20px; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
}
.toolbar input, .toolbar select { margin: 0; min-height: 44px; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 12px;
}
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%; }
.dot.found { background: var(--green); }
.dot.everyone { background: var(--accent); }

.item-list { display: grid; gap: 10px; }
.item-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 12px;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 18px;
  box-shadow: 0 4px 15px rgba(52,28,58,.07);
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.item-card:active { transform: scale(.985); }
.item-card.found-by-me { background: var(--green-soft); border-color: #a6d8b9; }
.item-card.found-by-everyone {
  background: linear-gradient(135deg, #fff6dc, #eef9f2);
  border-color: var(--accent);
}
.item-emoji {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: #f6f1f7;
  border-radius: 14px;
  font-size: 27px;
}
.item-info strong, .item-info small { display: block; }
.item-info strong { font-size: 16px; }
.item-info small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.item-actions { display: flex; align-items: center; gap: 6px; }
.check-btn, .bonus-btn {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
}
.check-btn {
  width: 42px;
  height: 42px;
  color: var(--brand);
  background: var(--purple-soft);
  font-size: 22px;
}
.found-by-me .check-btn { color: white; background: var(--green); }
.bonus-btn {
  width: 30px;
  height: 30px;
  color: #6b4a0a;
  background: #ffe5a8;
  font-size: 15px;
}
.bonus-mark {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  color: #6b4a0a;
  background: #ffe5a8;
  border-radius: 999px;
  font-size: 10px;
  vertical-align: 2px;
}
.everyone-tag {
  display: inline-block;
  margin-top: 4px;
  color: #7c570c;
  font-size: 11px;
  font-weight: 800;
}

.progress-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.progress-track {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  background: #eee7f0;
  border-radius: 999px;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--accent)); border-radius: inherit; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%);
  width: min(90%, 520px);
  padding: 12px 16px;
  color: white;
  background: rgba(32,24,35,.94);
  border-radius: 14px;
  box-shadow: var(--shadow);
  text-align: center;
  font-weight: 700;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30,18,34,.72);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  width: min(440px, 100%);
  overflow: hidden;
  padding: 28px 22px 22px;
  background: white;
  border-radius: 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.trophy, .bonus-icon { font-size: 76px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.12)); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 18px;
  background: var(--accent);
  animation: fall 2.4s linear infinite;
}
.empty-state { padding: 30px 16px; color: var(--muted); text-align: center; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes fall { to { transform: translateY(460px) rotate(720deg); } }

@media (min-width: 620px) {
  .toolbar { grid-template-columns: 1.5fr 1fr; }
}
@media (max-width: 390px) {
  .brand small { display: none; }
  .score-strip { top: 70px; }
  .item-card { grid-template-columns: 44px 1fr auto; gap: 9px; }
  .item-emoji { width: 44px; height: 44px; }
}
