:root {
  --team-a: #e0533d;
  --team-b: #3d7ee0;
  --bg: #14161c;
  --panel: #1e212b;
  --panel-2: #262a37;
  --text: #f2f3f5;
  --muted: #9aa0ac;
  --guessed: #2fa85a;
  --reroll: #d9a441;
  --taboo: #d94141;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1rem;
  animation: fade-in .18s ease-out;
}

.hidden { display: none !important; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo {
  text-align: center;
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: .04em;
  margin: 1.5rem 0 0;
}
.logo span { color: var(--taboo); }

.lang-switch {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: .5rem;
}

.lang-btn {
  border: 1px solid #383d4c;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .04em;
  padding: .4rem .9rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn.active {
  background: #4361d9;
  border-color: #4361d9;
  color: white;
}

/* ---------- setup form ---------- */

#setup-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
}

.field-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.field-row label {
  flex: 1 1 120px;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .8rem;
  color: var(--muted);
  align-items: flex-start;
}

.field-row input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid #383d4c;
  color: var(--text);
  border-radius: 10px;
  padding: .6rem .7rem;
  font-size: 1rem;
}

.field-row input:focus {
  outline: 2px solid #5b7fe0;
  outline-offset: 1px;
}

.team-dot {
  display: inline-block;
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  margin-right: .35rem;
  vertical-align: middle;
}
.team-dot.team-a { background: var(--team-a); }
.team-dot.team-b { background: var(--team-b); }

.hint {
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.4;
  text-align: center;
  padding: 0 .25rem;
}

/* ---------- buttons ---------- */

.btn {
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn-primary {
  background: #4361d9;
  color: white;
}
.btn-primary:active { background: #364eb3; }

.btn-big {
  padding: 1rem;
  font-size: 1.05rem;
  border-radius: var(--radius);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: .6rem;
  text-decoration: underline;
}

/* ---------- handoff / turn-end / final screens ---------- */

.handoff-team {
  text-align: center;
  margin-top: 2.5rem;
}
.handoff-team .team-dot {
  width: 1rem;
  height: 1rem;
  margin: 0 auto .5rem;
  display: block;
}
.handoff-team h2 { margin: 0; font-size: 2rem; }

.handoff-sub {
  text-align: center;
  color: var(--muted);
  margin: 0;
}

#screen-handoff, #screen-turn-end, #screen-final {
  justify-content: center;
  align-items: stretch;
  text-align: center;
}

.scoreboard {
  display: flex;
  gap: .75rem;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem;
}
.score-item {
  flex: 1;
  text-align: center;
  padding: .5rem;
  border-radius: 10px;
}
.score-item .score-team-name {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: .25rem;
  overflow-wrap: anywhere;
}
.score-item .score-value {
  font-size: 2rem;
  font-weight: 800;
}
.score-item.leading { background: var(--panel-2); }

.winner-banner { color: #ffd15c; }

/* ---------- play screen ---------- */

.play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.play-team {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.play-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 800;
  padding: .2rem .8rem;
  border-radius: 999px;
  background: var(--panel-2);
  min-width: 3.5rem;
  text-align: center;
}
.play-timer.low { color: var(--taboo); background: #3a1e1e; }

.play-score {
  font-size: 1.6rem;
  font-weight: 800;
  min-width: 2.2rem;
  text-align: right;
}

.reroll-meter {
  display: flex;
  gap: .3rem;
  justify-content: center;
}
.reroll-pip {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--reroll);
}
.reroll-pip.used {
  background: var(--panel-2);
}

.card {
  flex: 1;
  background: var(--panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 1.25rem;
  min-height: 0;
}

.card-word {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.card-taboo {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.card-taboo li {
  background: var(--panel-2);
  color: #ff8a8a;
  border: 1px solid #3a2a2a;
  border-radius: 10px;
  padding: .55rem .8rem;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
}

.play-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: .6rem;
}

.play-buttons .btn {
  padding: .9rem .4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  line-height: 1.1;
}

.btn-label { font-size: 1rem; }
.btn-hint { font-size: .7rem; opacity: .85; font-weight: 500; }

.btn-taboo { background: var(--taboo); }
.btn-taboo:active { background: #b93333; }

.btn-reroll { background: var(--reroll); color: #241a02; }
.btn-reroll:active { background: #bd8a33; }
.btn-reroll:disabled { opacity: .4; cursor: not-allowed; }

.btn-guessed { background: var(--guessed); }
.btn-guessed:active { background: #24893f; }

@media (max-width: 360px) {
  .card-word { font-size: 2rem; }
  .btn-label { font-size: .9rem; }
}
