:root {
  --bg1: #5b1fd1;
  --bg2: #d4148f;
  --ink: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --card: rgba(255, 255, 255, 0.12);
  --card-strong: rgba(255, 255, 255, 0.2);
  --yellow: #ffd23f;
  --red: #ff3b5c;
  --blue: #2f7bff;
  --green: #19d46b;
  --dark: #1b0b3a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed;
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 800;
  overscroll-behavior: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, h3, .display { font-family: 'Lilita One', 'Nunito', sans-serif; font-weight: 400; letter-spacing: 0.5px; margin: 0; }
h1 { font-size: 44px; line-height: 1; text-align: center; text-shadow: 0 4px 0 rgba(0,0,0,0.25); }
h2 { font-size: 30px; line-height: 1.05; }
h3 { font-size: 22px; }
p { margin: 0; color: var(--muted); line-height: 1.35; }

.logo { text-align: center; margin: 18px 0 6px; }
.logo .two { color: var(--yellow); }
.tag { text-align: center; color: var(--muted); }

.card { background: var(--card); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.center { text-align: center; align-items: center; justify-content: center; }

input {
  width: 100%;
  font: inherit;
  font-size: 20px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 0;
  background: #fff;
  color: var(--dark);
  outline: none;
}
input.code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-family: 'Lilita One'; font-size: 26px; }

button {
  font: inherit;
  font-family: 'Lilita One', sans-serif;
  font-size: 22px;
  letter-spacing: 0.5px;
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  color: var(--dark);
  background: var(--yellow);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
button:disabled { opacity: 0.45; }
button.ghost { background: var(--card-strong); color: #fff; }
button.small { font-size: 16px; padding: 10px 12px; border-radius: 12px; }
button.sel { outline: 3px solid #fff; }

.err { color: #fff; background: rgba(0,0,0,0.3); padding: 10px 12px; border-radius: 12px; }

/* Lobby */
.roomcode { font-family: 'Lilita One'; font-size: 64px; letter-spacing: 10px; text-align: center; line-height: 1; color: var(--yellow); }
.qr { background: #fff; border-radius: 14px; padding: 10px; width: 190px; height: 190px; margin: 0 auto; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.players { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card-strong); border-radius: 999px; padding: 6px 12px 6px 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 16px; }
.chip.red { background: var(--red); }
.chip.blue { background: var(--blue); }
.chip.off { opacity: 0.45; }
.chip .beers { color: var(--yellow); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; font-size: 18px; padding: 12px 8px; }

/* Top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 15px; color: var(--muted); }
.topbar .me { color: #fff; }
.topbar .beers { color: var(--yellow); }

/* Mode badges */
.badge { display: inline-block; font-family: 'Lilita One'; font-size: 18px; padding: 6px 14px; border-radius: 999px; background: var(--dark); color: var(--yellow); align-self: center; }
.badge.team { background: linear-gradient(90deg, var(--red) 50%, var(--blue) 50%); color: #fff; }
.twist { text-align: center; font-family: 'Lilita One'; font-size: 20px; color: var(--yellow); }

.teamcard { border-radius: 18px; padding: 14px; text-align: center; }
.teamcard.red { background: var(--red); }
.teamcard.blue { background: var(--blue); }
.teamcard .display { font-size: 34px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.teams .col { border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.teams .col.red { background: rgba(255, 59, 92, 0.55); }
.teams .col.blue { background: rgba(47, 123, 255, 0.55); }

.countdown { font-family: 'Lilita One'; font-size: 22px; text-align: center; color: var(--muted); }

/* Full-screen play areas */
.big {
  flex: 1;
  min-height: 55dvh;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.big .display { font-size: 56px; line-height: 1; }
.big.red { background: var(--red); }
.big.green { background: var(--green); }
.big.dark { background: var(--dark); }
.big.card { background: var(--card); }

.timer { font-family: 'Lilita One'; font-size: 84px; font-variant-numeric: tabular-nums; }

.bomb { font-size: 110px; line-height: 1; animation: shake 0.25s infinite; }
@keyframes shake { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.05); } }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; padding: 0 12px; }
.choices button { font-size: 48px; padding: 18px 0; background: #fff; }
.locked { opacity: 0.4; }

.votes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.votes button { font-size: 18px; padding: 14px 8px; background: #fff; }

/* Results */
.banner { border-radius: 22px; padding: 22px 16px; text-align: center; }
.banner .display { font-size: 48px; line-height: 1; }
.banner.drink { background: var(--red); }
.banner.beer { background: var(--yellow); color: var(--dark); }
.banner.safe { background: var(--card-strong); }
.rows { display: flex; flex-direction: column; gap: 6px; }
.rrow { display: flex; align-items: center; gap: 10px; background: var(--card); padding: 10px 12px; border-radius: 12px; font-size: 17px; }
.rrow.red { box-shadow: inset 5px 0 0 var(--red); }
.rrow.blue { box-shadow: inset 5px 0 0 var(--blue); }
.rrow .val { color: var(--muted); }

.waiting { text-align: center; color: var(--muted); font-size: 16px; }
.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.podium { font-size: 72px; text-align: center; line-height: 1; }
.rules li { color: var(--muted); margin: 4px 0; line-height: 1.3; }
.rules ul { margin: 0; padding-left: 20px; }
details summary { cursor: pointer; font-family: 'Lilita One'; font-size: 18px; }

/* ---------- Mini game pieces ---------- */
button.huge { font-size: 34px; padding: 26px; }
.tbar { height: 10px; background: rgba(255,255,255,0.2); border-radius: 999px; overflow: hidden; }
.tbar i { display: block; height: 100%; width: 100%; background: var(--yellow); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swatch { height: 92px; }
.optbtn { font-size: 34px; padding: 20px 0; background: #fff; }
.pads .pad { height: 26dvh; max-height: 190px; opacity: 0.55; transition: opacity 0.08s, transform 0.08s; }
.pads .pad.lit { opacity: 1; transform: scale(1.04); box-shadow: 0 0 30px #fff; }

.numgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.numgrid button { font-size: 26px; padding: 18px 0; background: #fff; }
.numgrid button.gone { opacity: 0.15; }
.numgrid button.wrong { background: var(--red); color: #fff; }

.oddgrid { display: grid; gap: 6px; }
.oddgrid button { background: rgba(255,255,255,0.14); box-shadow: none; padding: 6px 0; font-size: inherit; border-radius: 10px; }
.oddgrid.locked { opacity: 0.4; }

.holes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hole { height: 96px; font-size: 52px; padding: 0; background: var(--dark); box-shadow: inset 0 6px 0 rgba(0,0,0,0.4); color: #fff; }
.hole.up { background: rgba(255,255,255,0.25); }

.track { position: relative; width: 88%; height: 46px; border-radius: 999px; background: rgba(255,255,255,0.18); }
.track .mid { position: absolute; left: 50%; top: -8px; bottom: -8px; width: 4px; margin-left: -2px; background: var(--yellow); border-radius: 2px; }
.track .mark { position: absolute; top: 5px; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%; background: #fff; }

.pourwrap { display: flex; justify-content: center; padding: 10px 0; touch-action: none; user-select: none; -webkit-user-select: none; }
.glass { position: relative; width: 150px; height: 300px; border: 5px solid rgba(255,255,255,0.85); border-top: 0; border-radius: 0 0 26px 26px; overflow: hidden; background: rgba(255,255,255,0.08); }
.glass .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(#fff 0 12px, #ffb627 12px, #f08a00); }
.glass .line { position: absolute; left: -5px; right: -5px; height: 4px; background: var(--red); z-index: 2; box-shadow: 0 0 8px var(--red); }

.holdbtn { height: 34dvh; font-size: 44px; }
.holdbtn.holding { background: var(--green); color: #fff; }

.field { position: relative; height: 340px; border-radius: 18px; background: var(--card); }
.field span { position: absolute; font-size: 30px; line-height: 1; }

.arena { position: relative; height: 210px; }
.cupwrap { position: absolute; top: 40px; width: 25%; height: 150px; cursor: pointer; }
.cupwrap .ball { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 46px; }
.cup { position: absolute; left: 6%; right: 6%; bottom: 0; height: 120px; background: linear-gradient(90deg, #c4163a, #ff3b5c 40%, #c4163a); clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%); border-radius: 6px; transition: transform 0.3s; }
.cupwrap.lift .cup { transform: translateY(-80px); }

.court { position: relative; height: 56dvh; min-height: 360px; border-radius: 22px; background: linear-gradient(#0f5a2e, #127a3c); overflow: hidden; touch-action: none; }
.court::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.4); }
.pongcup { left: 0; top: 18px; width: 70px; height: 70px; clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%); bottom: auto; z-index: 1; }
.pball { position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,0.3); z-index: 2; }
.pongmsg { position: absolute; left: 0; right: 0; top: 45%; text-align: center; pointer-events: none; }

.followbox { position: relative; height: 56dvh; min-height: 340px; border-radius: 22px; background: var(--card); touch-action: none; overflow: hidden; }
.dot { position: absolute; left: 0; top: 0; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,0.25); display: flex; align-items: center; justify-content: center; font-size: 34px; border: 3px solid #fff; }
.dot.on { background: var(--green); box-shadow: 0 0 24px var(--green); }

.meter { width: 90%; height: 28px; border-radius: 999px; background: rgba(255,255,255,0.18); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); }

/* ---------- Unlock ---------- */
.unlockcard { border: 2px solid var(--yellow); }
#modal { position: fixed; inset: 0; background: rgba(15, 4, 35, 0.72); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 16px; }
#modal .sheet { position: relative; width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto; background: linear-gradient(160deg, #6a24e0, #c81690); border-radius: 24px; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 -10px 40px rgba(0,0,0,0.4); }
#modal .close { position: absolute; top: 12px; right: 12px; padding: 6px 12px; }
#modal h2 { padding-right: 44px; }
.perks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.perks li { background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 16px; }
a.buy { display: block; text-align: center; text-decoration: none; font-family: 'Lilita One', sans-serif; font-size: 24px; color: var(--dark); background: var(--yellow); border-radius: 16px; padding: 16px; box-shadow: 0 5px 0 rgba(0,0,0,0.25); }
.small-print { font-size: 14px; }
.fairnote { background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 15px; color: var(--muted); }
.fairnote b { color: #fff; }

/* ---------- House rules ---------- */
.rule-row { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 10px 12px; }
.rule-row > div { flex: 1; }
.rule-row p { font-size: 14px; }
.toggle { min-width: 72px; text-align: center; font-family: 'Lilita One', sans-serif; font-size: 17px; padding: 10px 12px; border-radius: 999px; background: rgba(0,0,0,0.3); color: var(--muted); box-shadow: none; }
.toggle.on { background: var(--green); color: #fff; }
span.toggle { display: inline-block; }

/* ---------- Award reveal ---------- */
.reveal { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; min-height: 70dvh; }
.reveal .award { background: var(--yellow); color: var(--dark); border-radius: 24px; padding: 24px 18px; width: 100%; animation: pop 0.5s ease-out; }
.reveal .award p { color: var(--dark); }
.reveal .award .who { font-family: 'Lilita One', sans-serif; font-size: 34px; margin-top: 8px; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
