@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;800&display=swap');
:root {
  --bg: #f7f8fc;
  --card: #ffffff;
  --text: #1a1a1a;
  --accent: #ff3b3b;
  --accent2: #2d7dd2;
  --warning: #f5a623;
  --border: #d9deea;
  --muted: #616777;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  position: relative;
  /* Prevent pull-to-refresh / overscroll bounce */
  overscroll-behavior-y: none;
  overscroll-behavior: none;
}
.bg-anim::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1600px 1000px at 20% 25%, rgba(140, 0, 255, 0.55), transparent 60%),
    radial-gradient(1400px 900px at 80% 30%, rgba(0, 200, 140, 0.52), transparent 65%),
    radial-gradient(1200px 800px at 50% 75%, rgba(0, 120, 255, 0.50), transparent 70%),
    radial-gradient(1100px 900px at 30% 80%, rgba(0, 255, 170, 0.48), transparent 70%);
  animation: lavaFlow 12.8s ease-in-out infinite alternate;
  filter: blur(24px) saturate(140%) contrast(115%);
  will-change: transform;
  pointer-events: none;
}
@keyframes lavaFlow {
  0% { transform: translate3d(0,0,0) scale(1) rotate(0deg); }
  20% { transform: translate3d(-18%, 12%, 0) scale(1.26) rotate(6deg); }
  50% { transform: translate3d(22%, -16%, 0) scale(1.32) rotate(-8deg); }
  80% { transform: translate3d(-16%, -20%, 0) scale(1.28) rotate(6deg); }
  100% { transform: translate3d(0,0,0) scale(1) rotate(0deg); }
}

/* Second animated layer for extra motion */
.bg-anim::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(1700px 1050px at 75% 20%, rgba(200, 80, 255, 0.50), transparent 60%),
    radial-gradient(1400px 1000px at 25% 75%, rgba(0, 230, 160, 0.48), transparent 65%),
    radial-gradient(1200px 900px at 60% 40%, rgba(40, 120, 255, 0.46), transparent 70%);
  animation: lavaFlow2 16.8s ease-in-out infinite alternate-reverse;
  filter: blur(28px) saturate(150%) contrast(120%);
  opacity: 1;
  will-change: transform;
  pointer-events: none;
}
@keyframes lavaFlow2 {
  0% { transform: translate3d(0,0,0) scale(1) rotate(0deg); }
  33% { transform: translate3d(20%, -18%, 0) scale(1.34) rotate(-9deg); }
  66% { transform: translate3d(-22%, 16%, 0) scale(1.36) rotate(9deg); }
  100% { transform: translate3d(0,0,0) scale(1) rotate(0deg); }
}
.main, .screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
  background: transparent;
  position: relative;
  z-index: 1;
}
.hidden { display: none; }
.title {
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
  margin: 12px 0 16px;
}
.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin: 6px 0;
}
.input {
  width: 100%;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 700;
  outline: none;
}
.input.code { text-align: center; letter-spacing: 3px; }
.input:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(45, 125, 210, 0.15); }
.btn {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 12px;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--accent2); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-link { background: transparent; color: var(--accent2); text-decoration: underline; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.divider {
  margin: 16px 0;
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--muted);
}
.error { color: var(--accent); font-weight: 700; min-height: 24px; }
.row { display: flex; gap: 8px; justify-content: space-between; }
.col { flex: 1; }
.col.right { text-align: right; }
.badge {
  display: inline-block;
  background: #f0f4ff;
  border: 2px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
}
.room-code-top {
  position: absolute;
  top: 8px;
  right: 12px;
}
#promptBox { text-align: center; display: block; margin: 0 auto; white-space: pre-line; }
/* Hide timer badge unless it has text */
#phaseTimer:empty { display: none; }
.list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}
.list li {
  background: #f5f7ff;
  border: 2px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.list li.score-correct {
  background: #e7f9ee;
  border-color: #b7e3c4;
}
.list li.score-wrong {
  background: #f5f7ff;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}
#yourTurnBox {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent2);
  letter-spacing: 0.5px;
  -webkit-text-stroke: 1px rgba(0,0,0,0.25);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4), 0 2px 6px rgba(0,0,0,0.15);
}
.controls { margin-top: 16px; }
.countdown {
  margin-top: 12px;
  text-align: center;
  font-size: 42px;
  font-weight: 800;
}
.fade-in { animation: fadeIn 400ms ease both; }
.fade-out { animation: fadeOut 400ms ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
@keyframes fadeOut { from { opacity: 1; transform: translateY(0);} to { opacity: 0; transform: translateY(-6px);} }
.score-value { font-weight: 800; font-size: 20px; }
.modal {
  position: fixed;
  inset: 0;
  display: none;
}
.modal:not(.hidden) { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
}
.modal-card {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.center { text-align: center; }
@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.1); }
  .btn-secondary:hover { filter: brightness(1.1); }
  .btn-warning:hover { filter: brightness(1.05); }
}
