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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --accent: #e94560;
  --text: #eaeaea;
  --muted: #8888aa;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%; width: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
}

/* ── Screens ──────────────────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  gap: 16px;
  text-align: center;
}
.screen.active { display: flex; }

/* ── Join screen ──────────────────────────────────────────────────────── */
#screen-join h1 { font-size: 2rem; color: var(--accent); }
#screen-join p  { color: var(--muted); }
#screen-join input {
  width: 100%; max-width: 300px;
  padding: 14px 18px; font-size: 1.1rem;
  background: var(--surface); border: 2px solid var(--muted);
  color: var(--text); border-radius: var(--radius); outline: none;
  text-align: center;
}
#screen-join input:focus { border-color: var(--accent); }

/* ── Wait screen ──────────────────────────────────────────────────────── */
#screen-wait h2 { font-size: 1.5rem; }
#screen-wait p  { color: var(--muted); font-size: 1.1rem; }
#wait-team {
  padding: 8px 24px; border-radius: 20px;
  color: #fff; font-weight: 600; font-size: 1rem;
}

/* ── Roll screen ──────────────────────────────────────────────────────── */
#screen-roll h2 { font-size: 1.4rem; }
#roll-btn {
  width: 180px; height: 180px; border-radius: 50%;
  background: var(--accent); border: none;
  font-size: 1.6rem; font-weight: 700; color: #fff;
  cursor: pointer; font-family: var(--font);
  box-shadow: 0 8px 32px rgba(233,69,96,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
}
#roll-btn:active { transform: scale(0.93); box-shadow: 0 4px 12px rgba(233,69,96,0.3); }
#roll-result { font-size: 3rem; animation: popIn 0.3s ease; }
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Draw screen ──────────────────────────────────────────────────────── */
#screen-draw {
  padding: 0;
  justify-content: flex-start;
  background: var(--bg);
}
#draw-header {
  width: 100%; padding: 10px 16px;
  background: var(--surface);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
#draw-word {
  flex: 1; font-size: 1.4rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent);
}
#draw-category-badge {
  padding: 3px 12px; border-radius: 20px;
  font-size: 0.8rem; color: #fff; font-weight: 600;
}
#draw-timer {
  font-size: 1.2rem; font-weight: 700; min-width: 32px; text-align: right;
}
#draw-timer.urgent { color: var(--accent); animation: pulse 0.8s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

#canvas-wrap-player {
  flex: 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
#draw-canvas {
  display: block;
  background: #fff;
  touch-action: none;
  /* Aspect ratio is set dynamically by JS */
}

#draw-toolbar {
  width: 100%; padding: 10px 16px;
  background: var(--surface);
  display: flex; gap: 10px; justify-content: center; align-items: center;
  flex-shrink: 0;
}
.tool-btn {
  padding: 10px 24px; border-radius: var(--radius);
  border: 2px solid transparent; cursor: pointer;
  font-size: 1rem; font-weight: 600; font-family: var(--font);
  transition: all 0.15s;
  color: var(--text); background: var(--surface2, #16213e);
}
.tool-btn.active { border-color: var(--accent); color: var(--accent); }
.tool-btn.clear-btn {
  background: transparent; border-color: var(--muted); color: var(--muted);
}
.tool-btn.clear-btn:active { border-color: var(--accent); color: var(--accent); }

/* ── All-play wait ────────────────────────────────────────────────────── */
#screen-allplay h2 { font-size: 1.6rem; }
#allplay-names { color: var(--muted); font-size: 1rem; }
.all-play-badge {
  padding: 8px 28px; border-radius: 20px;
  background: #2980b9; color: #fff; font-weight: 700; font-size: 1.1rem;
}

/* ── Finished screen ──────────────────────────────────────────────────── */
#screen-finished h1 { font-size: 2.5rem; }
#screen-finished p  { color: var(--muted); }

/* ── Host link (desktop only) ─────────────────────────────────────────── */
#host-link {
  display: none;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}
#host-link:hover { color: var(--text); }

@media (min-width: 768px) {
  #host-link { display: inline-block; }
}

/* ── Player name tag ──────────────────────────────────────────────────── */
#player-name-tag {
  position: fixed;
  top: 8px;
  left: 10px;
  z-index: 200;
  display: none;
}
#player-name-display {
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(26,26,46,0.85);
  user-select: none;
  white-space: nowrap;
}
#player-name-display:hover { color: var(--text); }
#player-name-edit {
  display: none;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  outline: none;
  width: 130px;
  font-family: var(--font);
}

/* Utility */
.big-btn {
  width: 100%; max-width: 320px; padding: 16px;
  border-radius: var(--radius); border: none;
  font-size: 1.1rem; font-weight: 700; cursor: pointer; font-family: var(--font);
  background: var(--accent); color: #fff;
  transition: opacity 0.2s;
}
.big-btn:hover { opacity: 0.88; }
.hidden { display: none !important; }
