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

:root {
  --bg: #0d0d1a;
  --card: #1a1a2e;
  --border: #2a2a4a;
  --accent: #e94560;
  --text: #eaeaea;
  --muted: #777;
  --success: #27ae60;
  --danger: #c0392b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ─── VIEWS ─── */
.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── SHARED ─── */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.2rem;
  border: 1px solid var(--border);
}

.card h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

.btn {
  display: block;
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  text-align: center;
}

.btn:active { transform: scale(0.97); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; color: var(--text); border: 2px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

input[type="text"] {
  width: 100%;
  padding: 1rem 1.2rem;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus { border-color: var(--accent); }

.team-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── JOIN VIEW ─── */
#view-join {
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  gap: 1.4rem;
}

#view-join h1 { font-size: 2.8rem; font-weight: 900; letter-spacing: -1px; }
#view-join p { color: var(--muted); font-size: 1.05rem; }
#view-join input { max-width: 320px; text-align: center; }
#view-join .btn { max-width: 320px; }

.join-image {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 24px rgba(233,69,96,.4);
}

/* ─── LOBBY VIEW ─── */
#view-lobby {
  padding: 1.5rem;
  gap: 1.2rem;
}

.lobby-header { text-align: center; }
.lobby-header h2 { font-size: 1.6rem; font-weight: 800; }
.lobby-status {
  margin-top: 0.4rem;
  color: var(--accent);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.player-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.player-tag {
  background: var(--border);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.player-tag-me { background: var(--accent); color: #fff; }

.player-info-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .6rem 1.2rem;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.my-team-row { background: rgba(233,69,96,.08); }

/* ─── ROUND INFO (player) ─── */
.round-info-player {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: .4rem 0 .8rem;
}

.round-label {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.round-pips-sm { display: flex; gap: 3px; flex-wrap: wrap; }

.round-pip-sm {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background .2s, transform .2s;
}

.round-pip-sm.done { background: #555; }
.round-pip-sm.active {
  background: var(--accent);
  transform: scale(1.3);
  box-shadow: 0 0 6px rgba(233,69,96,.6);
}

.team-row {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.team-row:last-child { border-bottom: none; }
.team-row-name { font-weight: 700; font-size: 0.95rem; }
.team-row-members { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ─── GAME VIEW ─── */
#view-game { gap: 0; }

.scoreboard {
  background: var(--card);
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.scoreboard h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 0.7rem;
  text-align: center;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
}

.score-name { flex: 1; font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.score-bar-wrap {
  width: 70px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.score-pts { font-size: 1.3rem; font-weight: 800; min-width: 32px; text-align: right; }

.challenge-area {
  flex: 1;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.challenge-card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.challenge-num {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.challenge-emoji { font-size: 3.5rem; margin: 0.5rem 0 0.3rem; line-height: 1; }
.challenge-title { font-size: 1.9rem; font-weight: 900; margin-bottom: 0.6rem; }

.challenge-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.challenge-desc {
  line-height: 1.65;
  color: #bbb;
  font-size: 0.95rem;
}

.challenge-penalty {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(233, 69, 96, 0.12);
  border-radius: 10px;
  font-size: 0.88rem;
  border-left: 3px solid var(--accent);
}

.timer-card {
  background: var(--card);
  border-radius: 16px;
  padding: 1.2rem;
  border: 2px solid var(--accent);
  text-align: center;
}

.timer-card.urgent { border-color: #e74c3c; animation: blink 0.6s infinite; }

@keyframes blink {
  0%, 100% { border-color: #e74c3c; }
  50% { border-color: transparent; }
}

.timer-num { font-size: 4.5rem; font-weight: 900; color: var(--accent); line-height: 1; }
.timer-card.urgent .timer-num { color: #e74c3c; }
.timer-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }

/* ─── ADMIN ─── */
.admin-header {
  background: var(--card);
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-header h1 { font-size: 1.2rem; font-weight: 800; }

.admin-content {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding-bottom: 3rem;
}

.section {
  background: var(--card);
  border-radius: 16px;
  padding: 1.2rem;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* team count buttons */
.count-btns { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

.count-btn {
  flex: 1;
  padding: 0.7rem;
  background: var(--border);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.count-btn.active { background: var(--accent); border-color: var(--accent); }

/* player assign rows */
.assign-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.assign-row:last-child { border-bottom: none; }
.assign-name { flex: 1; font-weight: 600; font-size: 0.95rem; }

select {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
  outline: none;
}

/* challenge nav */
.challenge-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.nav-btn {
  width: 44px; height: 44px;
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.nav-btn:disabled { opacity: 0.3; cursor: default; }
.challenge-nav-info { flex: 1; }
.challenge-nav-num { font-size: 0.75rem; color: var(--muted); }
.challenge-nav-title { font-weight: 700; font-size: 1rem; }

.ch-list { display: flex; flex-direction: column; gap: 0.4rem; }

.ch-item {
  padding: 0.65rem 1rem;
  background: var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  border: 2px solid transparent;
  transition: background 0.15s;
}

.ch-item.active { background: var(--accent); border-color: var(--accent); }

/* points */
.points-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.points-row:last-child { border-bottom: none; }

.points-team {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.points-score {
  font-size: 1.5rem;
  font-weight: 900;
  min-width: 36px;
  text-align: center;
}

.pt-btns { display: flex; gap: 0.35rem; }

.pt-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.pt-plus { background: var(--success); color: #fff; }
.pt-minus { background: var(--danger); color: #fff; }
.pt-plus2 { background: #1a6b3c; color: #fff; font-size: 0.8rem; }

/* timer admin */
.timer-admin { display: flex; gap: 0.6rem; align-items: center; }
.timer-admin-num {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  min-width: 60px;
  text-align: center;
}

/* tabs */
.tabs {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 49px;
  z-index: 15;
}

.tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── ANIMATIONS ─── */
.anim-slide {
  animation: slideIn 0.45s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(50px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

.anim-pop {
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.75); }
  to   { opacity: 1; transform: scale(1); }
}

.fade-in { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─── MATCHUP CARD ─── */
.matchup-card {
  background: linear-gradient(135deg, #1a1a2e 0%, #0d0d1a 100%);
  border-radius: 20px;
  padding: 1.4rem 1.2rem;
  border: 2px solid var(--accent);
  box-shadow: 0 0 24px rgba(233,69,96,.2);
}

.matchup-title {
  text-align: center;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 1rem;
}

.matchup-body {
  display: flex;
  align-items: center;
  gap: .8rem;
}

.matchup-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.matchup-side:last-child { align-items: flex-end; text-align: right; }

.matchup-player {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.25rem;
  font-weight: 800;
  animation: nameReveal 0.5s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

.matchup-side:last-child .matchup-player { flex-direction: row-reverse; }

@keyframes nameReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.matchup-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.matchup-role {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: .1rem;
}

.matchup-me {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

.matchup-vs {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 2px;
  flex-shrink: 0;
  animation: vsPulse 2s ease-in-out infinite;
}

@keyframes vsPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.15); opacity: .8; }
}

/* ─── SCORE TABLE (player view) ─── */
.score-table-wrap {
  background: var(--card);
  border-radius: 16px;
  padding: 1.2rem;
  border: 1px solid var(--border);
}

.score-table-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: .9rem;
}

.matchup-note {
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  margin-top: .5rem;
}

/* ─── HOT POTATO ─── */
.hotpotato-body {
  text-align: center;
  padding: .5rem 0;
  animation: nameReveal 0.6s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

.hp-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin: 0 auto .6rem;
}

.hp-name {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.1;
}

.hp-team {
  color: var(--muted);
  font-size: .85rem;
  margin-top: .3rem;
}

.hotpotato-me .hp-name {
  color: var(--accent);
  animation: vsPulse 1s ease-in-out infinite;
}

.hp-alert {
  margin-top: .8rem;
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
  animation: popIn .4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: .3s;
}

.score-table-scroll { overflow-x: auto; }

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  white-space: nowrap;
}

.score-table th {
  text-align: center;
  padding: .4rem .6rem;
  color: var(--muted);
  font-size: .8rem;
  border-bottom: 1px solid var(--border);
}

.score-table th:first-child { text-align: left; }

.score-table td {
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.score-table td:first-child { text-align: left; font-weight: 600; }
.score-table tr:last-child td { border-bottom: none; }
.score-total { font-size: 1.1rem; font-weight: 900; color: var(--accent); }

/* url display */
.url-box {
  background: var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-family: monospace;
  font-size: 0.9rem;
  word-break: break-all;
  color: #adf;
}
