:root {
  --accent: #0aacca;
  --accent-dark: #0a5a63;
  --bg: #f4f5f7;
  --text: #16181d;
  --text-secondary: #6b7280;
  --danger: #e0453c;
  --card-bg: #ffffff;
  --radius: 16px;
  --team-0: #2f7ff2;
  --team-1: #e0453c;
  --team-2: #2fb673;
  --team-3: #f2a52f;
  --team-4: #9b59d9;
  --team-5: #ec5aa4;
  --team-6: #17a2a8;
  --team-7: #f2d02f;
}

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.screen-centered {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.spacer {
  flex: 1;
}

h1.title {
  font-size: 2.6rem;
  font-weight: 800;
  margin: 0;
}

h2.heading {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 4px;
}

p.subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.5;
  max-width: 420px;
  margin: 0 auto;
}

.icon-emoji {
  font-size: 4rem;
  line-height: 1;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 17px 20px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius);
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.btn-primary:disabled {
  background: #b9bec7;
  cursor: not-allowed;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 17px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: #e5e7eb;
  border-radius: var(--radius);
}

.btn-secondary:active {
  opacity: 0.8;
}

.btn-row {
  display: flex;
  gap: 12px;
}
.btn-row > * {
  flex: 1;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 36px;
}

.nav-btn {
  background: none;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 6px 4px;
}

.nav-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.progress-track {
  height: 5px;
  background: #e2e4e8;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.section-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 22px 0 8px;
}

.card-list {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #eef0f2;
}
.card-row:last-child {
  border-bottom: none;
}

.card-row input[type="text"] {
  flex: 1;
  border: none;
  background: none;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  min-width: 0;
}
.card-row input[type="text"]:focus {
  outline: none;
}

.icon-btn {
  background: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  padding: 2px 6px;
  line-height: 1;
}
.icon-btn.danger {
  color: var(--danger);
}

.add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: var(--accent);
  font-weight: 600;
  background: var(--card-bg);
}
.add-row:active {
  opacity: 0.7;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 8px 2px 0;
}

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

.badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.badge.warn {
  color: var(--danger);
}

.assign-select {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2px;
}

.term-input-row {
  display: flex;
  gap: 10px;
  margin: 18px 0 4px;
}
.term-input-row input[type="text"] {
  flex: 1;
  padding: 13px 14px;
  border: 1.5px solid #dcdfe4;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
}
.term-input-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.term-add-btn {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
}
.term-add-btn:disabled {
  background: #c7cbd1;
}

.term-chip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.term-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 12px 14px;
  border-radius: 10px;
}

/* Round intro */
.round-badge {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Handoff / Play full-color screens */
.color-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #fff;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.color-screen .header {
  text-align: center;
}
.color-screen .team-name {
  font-size: 1.3rem;
  font-weight: 700;
}
.color-screen .round-name {
  font-size: 1rem;
  opacity: 0.85;
  margin-top: 2px;
}
.color-screen .describer-block {
  margin-top: 22px;
}
.color-screen .describer-label {
  opacity: 0.8;
}
.color-screen .describer-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin-top: 2px;
}

.play-word {
  font-size: 3rem;
  font-weight: 800;
  text-align: center;
  padding: 0 16px;
  word-break: break-word;
}

.play-timer {
  font-size: 2.4rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.timer-track {
  height: 6px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 16px 8px;
}
.timer-fill {
  height: 100%;
  background: #fff;
  border-radius: 3px;
  transition: width 0.1s linear;
}
.timer-fill.low {
  background: #ffd54a;
}

.tap-hint {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  opacity: 0.85;
  padding-bottom: 30px;
}

.result-icon {
  font-size: 3.6rem;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
}
.score-table th, .score-table td {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.95rem;
}
.score-table th:first-child, .score-table td:first-child {
  text-align: left;
}
.score-table tbody tr {
  border-top: 1px solid #eef0f2;
}
.score-table .team-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-table .total-col {
  font-weight: 800;
}

.round-summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin-top: 12px;
}
.round-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #eef0f2;
}
.round-summary-row:last-child {
  border-bottom: none;
}
.round-summary-row .name {
  flex: 1;
}
.round-summary-row .delta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.round-summary-row .total {
  font-weight: 800;
  min-width: 28px;
  text-align: right;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --text: #f2f3f5;
    --text-secondary: #9aa0aa;
    --card-bg: #1b1e24;
  }
  .progress-track { background: #2a2d34; }
  .card-row { border-bottom-color: #2a2d34; }
  .btn-secondary { background: #262a31; color: var(--text); }
  .term-input-row input[type="text"] { background: #1b1e24; border-color: #2f333b; color: var(--text); }
  .score-table tbody tr, .round-summary-row { border-top-color: #2a2d34; border-bottom-color: #2a2d34; }
}
