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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  user-select: none;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #fff;
  background: linear-gradient(135deg, #1f8a4c 0%, #146b3a 55%, #0d4d29 100%);
  transition: background 0.4s ease;
}
#app.light-red { background: linear-gradient(135deg, #b71c1c 0%, #8e0000 55%, #5c0000 100%); }
#app.light-green { background: linear-gradient(135deg, #2e9e56 0%, #1f8a4c 55%, #146b3a 100%); }

.screen {
  display: none;
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.screen.active { display: flex; }

.title { font-size: 2.6rem; margin: 0; font-weight: 900; text-shadow: 3px 3px 0 rgba(0,0,0,0.25); }
.subtitle { font-size: 1.1rem; opacity: 0.9; margin: 0 0 6px; font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; margin-top: 6px; }

.big-btn {
  padding: 20px 24px;
  font-size: 1.3rem;
  font-weight: 800;
  border: none;
  border-radius: 20px;
  background: #ffd93d;
  color: #3a2a00;
  cursor: pointer;
  border-bottom: 6px solid #d9a900;
  transition: transform 0.05s ease;
}
.big-btn:active { transform: translateY(4px); border-bottom: 2px solid #d9a900; }
.big-btn:disabled { opacity: 0.5; cursor: default; border-bottom: 6px solid rgba(0,0,0,0.2); }
.big-btn.secondary { background: #4dd8ff; border-bottom: 6px solid #1a9fc7; color: #03303f; }

.text-btn {
  background: none;
  border: none;
  color: #fff;
  opacity: 0.85;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.field { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.field > span { font-weight: 800; font-size: 1.05rem; opacity: 0.95; }
.field input {
  padding: 16px;
  font-size: 1.2rem;
  border-radius: 14px;
  border: none;
  outline: none;
  font-weight: 700;
}

.error-text { color: #ffe0e0; font-weight: 800; min-height: 20px; }

.room-code {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: 12px;
  background: rgba(0,0,0,0.25);
  padding: 10px 30px;
  border-radius: 18px;
}
.hint { opacity: 0.85; margin: 0; font-weight: 600; }
.opponent-status { font-weight: 800; opacity: 0.95; min-height: 24px; }

.countdown-number {
  font-size: 10rem;
  font-weight: 900;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.25);
}

/* ---------- GAME SCREEN ---------- */
.light-banner {
  font-size: 1.8rem;
  font-weight: 900;
  background: rgba(0,0,0,0.3);
  padding: 10px 26px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.doll-wrap { display: flex; justify-content: center; }
.doll {
  font-size: 5rem;
  transition: transform 0.35s ease;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.doll.watching { transform: rotateY(180deg); }

.tracks { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.track-row { display: flex; align-items: center; gap: 10px; }
.track-label { width: 90px; font-weight: 800; font-size: 0.95rem; text-align: right; flex-shrink: 0; }
.track {
  position: relative;
  flex: 1;
  height: 52px;
  background: rgba(0,0,0,0.28);
  border-radius: 26px;
  overflow: hidden;
}
.track-finish {
  position: absolute;
  right: 6px;
  top: 4px;
  bottom: 4px;
  width: 6px;
  background: repeating-linear-gradient(45deg, #fff, #fff 4px, #222 4px, #222 8px);
  border-radius: 3px;
}
.runner {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translate(0, -50%);
  font-size: 2rem;
  transition: left 0.25s ease;
}

.freeze-msg { font-weight: 900; font-size: 1.2rem; min-height: 28px; color: #ffe082; }

.go-btn {
  width: 100%;
  max-width: 420px;
  padding: 34px 20px;
  font-size: 1.6rem;
  font-weight: 900;
  border: none;
  border-radius: 26px;
  background: #ffd93d;
  color: #3a2a00;
  cursor: pointer;
  border-bottom: 8px solid #d9a900;
  transition: transform 0.03s ease;
}
.go-btn:active { transform: translateY(5px); border-bottom: 3px solid #d9a900; }
.go-btn:disabled { background: #9e9e9e; color: #555; border-bottom: 8px solid #6e6e6e; cursor: default; }

.end-banner { font-size: 2.4rem; margin: 0; font-weight: 900; }
.end-scores { display: flex; align-items: center; gap: 20px; margin: 10px 0; }
.end-score-card {
  background: rgba(0,0,0,0.28);
  border-radius: 20px;
  padding: 20px 26px;
}
.end-name { font-weight: 800; opacity: 0.9; margin-bottom: 6px; }
.end-score { font-size: 2.2rem; font-weight: 900; }
.end-vs { font-size: 1.5rem; font-weight: 900; opacity: 0.7; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 800;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .title { font-size: 2rem; }
  .track-label { width: 64px; font-size: 0.8rem; }
  .doll { font-size: 3.6rem; }
  .go-btn { font-size: 1.3rem; padding: 26px 16px; }
}
