* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0a0612;
  --bg2:         #150b22;
  --card:        #1a0f2e;
  --border:      #2d1b3d;
  --text:        #f5f3ff;
  --muted:       #8b7ba8;
  --purple:      #7c3aed;
  --purple-glow: #a855f7;
  --orange:      #f97316;
  --orange-glow: #fb923c;
  --green:       #22c55e;
  --red:         #ef4444;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top, #1a0f2e 0%, #0a0612 70%);
  color: var(--text);
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 0;
}

#screen-game {
  overflow: hidden;
  padding: 0;
}
.screen.hidden { display: none; }

h1 {
  font-size: 32px;
  text-align: center;
  background: linear-gradient(135deg, var(--orange), var(--purple-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 40px;
}
h2 {
  font-size: 24px;
  text-align: center;
  color: var(--orange-glow);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
input[type="text"] {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
input[type="text"]:focus { border-color: var(--purple-glow); }
input.shake { animation: shake .4s; border-color: var(--red); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-8px); }
  75%     { transform: translateX(8px); }
}

.btn {
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, opacity .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--orange), var(--purple));
  color: #fff;
  box-shadow: 0 4px 20px rgba(249,115,22,.3);
}
.btn.ghost {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
}

/* HUD */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.hud-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.hud-value { font-size: 20px; font-weight: 700; color: var(--orange-glow); }
.hud-value.low-time { color: var(--red); animation: pulse .6s infinite; }

/* Curse bar */
.curse-wrap { display: flex; flex-direction: column; gap: 4px; }
.curse-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
}
.curse-bar {
  height: 10px; background: var(--card);
  border-radius: 5px; overflow: hidden;
  border: 1px solid var(--border);
}
.curse-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), #fbbf24, var(--red));
  transition: width .3s ease;
}

/* Recipe */
.recipe-box {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.recipe-title {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 8px;
}
.recipe-list { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.recipe-item {
  font-size: 28px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all .2s;
  opacity: .4;
}
.recipe-item.done   { opacity: .2; text-decoration: line-through; }
.recipe-item.current {
  opacity: 1;
  border-color: var(--orange-glow);
  box-shadow: 0 0 15px rgba(251,146,60,.5);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.05); }
}

/* Cauldron */
.cauldron {
  flex: 1;
  min-height: 60px;
  background: radial-gradient(circle, rgba(124,58,237,.35) 0%, transparent 70%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  transition: all .2s;
}
.cauldron::after { content: '🪄'; animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}
.cauldron.flash {
  background: radial-gradient(circle, rgba(249,115,22,.6) 0%, transparent 70%);
  transform: scale(1.1);
}

/* Ingredients */
.ingredients {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ingredient {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 4px;
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  cursor: pointer;
  transition: all .1s;
  font-family: inherit;
  color: var(--text);
}
.ingredient:active, .ingredient.tapped {
  transform: scale(.92);
  border-color: var(--orange-glow);
  background: var(--bg2);
}
.ingredient .emoji    { font-size: 28px; }
.ingredient .ing-name { font-size: 10px; color: var(--muted); }

/* Result */
.result-score {
  text-align: center;
  font-size: 64px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--orange), var(--purple-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-stats {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  font-size: 14px; color: var(--muted);
}
.result-stats b { color: var(--text); float: right; }

/* Leaderboard */
.tabs { display: flex; gap: 8px; }
.tab {
  flex: 1; padding: 10px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.tab.active {
  color: var(--text);
  border-color: var(--purple-glow);
  background: var(--bg2);
}
.leaderboard {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; overflow-y: auto;
}
.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  padding: 10px 12px;
  background: var(--card);
  border-radius: 10px;
  border: 2px solid transparent;
  align-items: center;
}
.lb-row.highlight { border-color: var(--orange-glow); background: var(--bg2); }
.lb-rank {
  grid-row: 1 / 3;
  font-size: 18px; font-weight: 700;
  color: var(--orange-glow);
  text-align: center;
}
.lb-name {
  font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-score {
  font-size: 16px; font-weight: 700;
  color: var(--orange-glow);
  text-align: right;
}
.lb-meta { grid-column: 2 / 4; font-size: 11px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 14px; }

.party-code-box {
  background: var(--card);
  border: 2px dashed var(--orange-glow);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}
.party-code-label {
  font-size: 10px; letter-spacing: 1px; color: var(--muted);
  text-transform: uppercase;
}
.party-code {
  font-size: 40px; font-weight: 800; letter-spacing: 8px;
  color: var(--orange-glow);
  font-family: 'Courier New', monospace;
}
.party-code-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.party-qr-wrap { display: flex; justify-content: center; }

.party-status {
  text-align: center; font-size: 14px; color: var(--muted);
}
.party-current {
  text-align: center; font-size: 18px; font-weight: 700;
  color: var(--orange-glow);
}

.party-players {
  background: var(--card); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.party-player {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 8px;
}
.party-player.active {
  background: var(--bg2);
  box-shadow: inset 0 0 0 2px var(--orange-glow);
}
.party-player .pp-name { font-weight: 600; }
.party-player .pp-score { color: var(--orange-glow); font-weight: 700; }
.party-player .pp-meta  { font-size: 11px; color: var(--muted); }

.party-actions { display: flex; flex-direction: column; gap: 8px; }

/* Stats */
.stats-box {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  font-size: 14px;
}
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-row span { color: var(--muted); }
.stat-row b { color: var(--text); font-size: 16px; }

.ach-grid { display: flex; flex-direction: column; gap: 10px; }
.ach-item {
  padding: 14px 16px; border-radius: 12px; background: var(--card);
  border: 2px solid var(--border);
}
.ach-item.unlocked { border-color: var(--orange-glow); background: var(--bg2); }
.ach-item.locked   { opacity: .5; }
.ach-title { font-weight: 700; font-size: 15px; }
.ach-desc  { font-size: 12px; color: var(--muted); margin-top: 4px; }

.tour-bracket {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 12px;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}
.tour-round {
  min-width: 150px;
  flex-shrink: 0;
}
.tour-round-title {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 600;
}
.tour-match {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.tour-match.active {
  border-color: var(--orange-glow);
  box-shadow: 0 0 12px rgba(251, 146, 60, 0.3);
}
.tour-match.done {
  opacity: 0.6;
  border-color: var(--green);
}
.tour-winner {
  color: var(--green);
  font-weight: 700;
  margin-top: 4px;
  font-size: 11px;
}
.tour-code-hint {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
  font-family: 'Courier New', monospace;
}

.recipe-emoji {
  font-size: 28px;
  line-height: 1;
  display: inline-block;
}

@media (max-width: 360px) {
  .hud-value { font-size: 16px; }
  .ingredient .emoji { font-size: 24px; }
  .recipe-item { width: 36px; height: 36px; font-size: 22px; }
  .cauldron { min-height: 40px; }
}

