* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0b1026;
  --bg2: #141a3d;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.12);
  --ink: #f4f6ff;
  --muted: rgba(244, 246, 255, 0.55);
  --accent: #7c6cff;
  --accent2: #38e0c8;
  --good: #4ade80;
  --bad: #ff5470;
  --radius: 20px;
}

html, body { height: 100%; }

body {
  font-family: 'Avenir Next', 'Nunito', -apple-system, system-ui, sans-serif;
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(124, 108, 255, 0.25), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(56, 224, 200, 0.16), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.02em; }

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(10px);
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 16px 20px;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #a24df6); border: none; }
.btn.good { background: linear-gradient(135deg, #22c55e, #4ade80); border: none; color: #06210f; }
.btn.warn { background: linear-gradient(135deg, #f59e0b, #fbbf24); border: none; color: #2a1a00; }
.btn.ghost { background: transparent; }
.btn.small { width: auto; display: inline-block; padding: 9px 14px; font-size: 14px; border-radius: 12px; }

input[type='text'], input[type='number'], select {
  width: 100%;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 17px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1c2350;
  border: 1px solid var(--card-border);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 99;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.conn-badge {
  position: fixed;
  top: 10px;
  right: 10px;
  background: var(--bad);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  z-index: 98;
  display: none;
}
.conn-badge.show { display: block; }

/* ------------------------------------------------ phone */

body.phone #app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.phone .logo { font-size: 42px; text-align: center; margin-top: 8vh; }
.phone .tagline { text-align: center; margin-bottom: 10px; }

.phone .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
}
.phone .topbar .code { letter-spacing: 0.2em; color: var(--accent2); }

.team-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.team-chip {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 12px 8px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  cursor: pointer;
}
.team-chip.mine { border-color: currentColor; }

.word-row { display: flex; gap: 8px; margin-bottom: 10px; }
.word-row input { flex: 1; }
.word-row .dice {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  width: 52px;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink);
}

.roster { display: flex; flex-direction: column; gap: 8px; }
.roster .p {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
}
.roster .p .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.roster .p .status { margin-left: auto; font-size: 13px; color: var(--muted); }
.roster .p.gone { opacity: 0.45; }

.bigword {
  font-size: clamp(34px, 10vw, 52px);
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow-wrap: anywhere;
}

.timerbar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.timerbar .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.2s linear; }
.timerbar .fill.low { background: var(--bad); }

.giver-actions { display: flex; gap: 10px; margin-top: 8px; }
.giver-actions .btn { padding: 26px 10px; font-size: 22px; }

.center-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.center-stage .huge { font-size: clamp(38px, 12vw, 60px); font-weight: 800; line-height: 1.1; }
.center-stage .emoji { font-size: 64px; }

.scorelist { display: flex; flex-direction: column; gap: 10px; }
.scorelist .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
  border-left: 6px solid transparent;
}
.scorelist .row .pts { font-size: 24px; }

/* ------------------------------------------------ tv */

body.tv { overflow: hidden; }
body.tv #app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 3vh 4vw;
  gap: 2vh;
}

.tv .tv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tv .tv-logo { font-size: 3.2vh; font-weight: 800; letter-spacing: 0.05em; }
.tv .tv-code { font-size: 3.2vh; font-weight: 800; letter-spacing: 0.25em; color: var(--accent2); }

.tv .lobby-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 34% 1fr;
  gap: 2vw;
  min-height: 0;
}

.tv .join-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; }
.tv .join-panel .code-huge { font-size: 11vh; font-weight: 800; letter-spacing: 0.18em; color: var(--accent2); line-height: 1; }
.tv .join-panel .url { font-size: 2.6vh; font-weight: 700; }
.tv .qr { background: #fff; padding: 1.2vh; border-radius: 12px; }
.tv .qr svg { display: block; width: 20vh; height: 20vh; }

.tv .teams-grid { display: grid; gap: 1.5vw; min-height: 0; }
.tv .teams-grid.n2 { grid-template-columns: 1fr 1fr; }
.tv .teams-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.tv .teams-grid.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.tv .team-col { display: flex; flex-direction: column; gap: 1vh; min-height: 0; overflow: hidden; }
.tv .team-col h3 { font-size: 2.8vh; border-bottom: 4px solid currentColor; padding-bottom: 0.8vh; }
.tv .team-col .p { font-size: 2.4vh; font-weight: 700; display: flex; gap: 0.6vw; align-items: center; }
.tv .team-col .p .rdy { margin-left: auto; }
.tv .team-col .p.gone { opacity: 0.4; }

.tv .footer-hint { text-align: center; font-size: 2.2vh; color: var(--muted); }

.tv .scores-strip { display: flex; gap: 2vw; justify-content: center; }
.tv .scores-strip .t {
  display: flex;
  align-items: center;
  gap: 0.8vw;
  font-size: 3vh;
  font-weight: 800;
  padding: 1vh 1.8vw;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border-bottom: 5px solid transparent;
}
.tv .scores-strip .t .pts { font-size: 4vh; }
.tv .scores-strip .t.active { background: rgba(255, 255, 255, 0.14); }

.tv .stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5vh;
  text-align: center;
  min-height: 0;
}
.tv .stage .huge { font-size: 8vh; font-weight: 800; line-height: 1.05; }
.tv .stage .big { font-size: 4.5vh; font-weight: 800; }
.tv .stage .emoji { font-size: 10vh; line-height: 1; }
.tv .stage .rules { font-size: 3vh; color: var(--muted); max-width: 60vw; }

.tv .timer-ring {
  width: 34vh;
  height: 34vh;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: conic-gradient(var(--ring-color, var(--accent2)) calc(var(--pct, 100) * 1%), rgba(255, 255, 255, 0.08) 0);
}
.tv .timer-ring::before {
  content: '';
  position: absolute;
  inset: 2.2vh;
  border-radius: 50%;
  background: var(--bg2);
}
.tv .timer-ring .num { position: relative; font-size: 11vh; font-weight: 800; font-variant-numeric: tabular-nums; }

.tv .bowl-meter { font-size: 2.6vh; font-weight: 700; color: var(--muted); }

.tv .lastwords { display: flex; flex-wrap: wrap; gap: 0.8vh 0.8vw; justify-content: center; max-width: 80vw; }
.tv .lastwords .w {
  font-size: 2.4vh;
  font-weight: 700;
  padding: 0.6vh 1.2vw;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.tv .scorebars { width: 60vw; display: flex; flex-direction: column; gap: 2vh; }
.tv .scorebars .row { display: flex; align-items: center; gap: 1.5vw; font-size: 3.2vh; font-weight: 800; }
.tv .scorebars .row .name { width: 14vw; text-align: right; }
.tv .scorebars .row .bar { flex: 1; height: 4.5vh; background: rgba(255, 255, 255, 0.07); border-radius: 12px; overflow: hidden; }
.tv .scorebars .row .bar .fill { height: 100%; border-radius: 12px; transition: width 0.6s ease; }
.tv .scorebars .row .pts { width: 6vw; font-size: 4vh; }

.tv .pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 25, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8vh;
  font-weight: 800;
  z-index: 40;
  backdrop-filter: blur(6px);
}

/* host drawer */
.tv #drawer-toggle {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 60;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(20, 26, 61, 0.9);
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}
.tv #drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: #10163a;
  border-left: 1px solid var(--card-border);
  z-index: 50;
  transform: translateX(105%);
  transition: transform 0.25s ease;
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tv #drawer.open { transform: translateX(0); }
.tv #drawer h2 { font-size: 20px; }
.tv #drawer label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.tv #drawer .row2 { display: flex; gap: 10px; }
.tv #drawer .row2 > * { flex: 1; }
.tv #drawer .checks { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 15px; }
.tv #drawer .checks label { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); margin: 0; }
.tv #drawer .admin-roster { display: flex; flex-direction: column; gap: 6px; }
.tv #drawer .admin-roster .p { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.tv #drawer .admin-roster .p button { margin-left: auto; }

/* scored-word flash */
#wordflash {
  position: fixed;
  top: 20vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  font-size: 5.5vh;
  font-weight: 800;
  color: #06210f;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  padding: 1.5vh 3vw;
  border-radius: 999px;
  box-shadow: 0 10px 40px rgba(34, 197, 94, 0.45);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
}
#wordflash.show { animation: wordflash 1.6s ease forwards; }
body.phone #wordflash {
  top: 96px; /* below the topbar + timer, above the word card and buttons */
  font-size: 20px;
  padding: 10px 20px;
  max-width: 92vw;
}
@keyframes wordflash {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  20% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(0.95); }
}

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  opacity: 0.9;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
