:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #475569;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #a855f7;
  --primary-dark: #7e22ce;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-top: max(20px, env(safe-area-inset-top));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Layout helpers ---------- */
.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.view-center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.spacer {
  flex: 1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.row > * {
  flex: 1;
}

/* ---------- Typography ---------- */
h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 22px;
  font-weight: 700;
}

.title-big {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--primary) 0%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
}

.label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-name {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.5px;
  word-break: break-word;
}

.word-display {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  word-break: break-word;
  line-height: 1.1;
}

.impostor-display {
  font-size: 40px;
  font-weight: 800;
  color: var(--danger);
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.starter-display {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  min-height: 56px;
  transition: transform 0.05s, background 0.15s;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-block {
  width: 100%;
}

.btn-xl {
  font-size: 20px;
  padding: 22px;
  min-height: 72px;
}

.btn-icon {
  min-width: 56px;
  min-height: 56px;
  flex: 0 0 auto;
  padding: 0;
  font-size: 24px;
}

/* ---------- Cards / Inputs ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
}

input[type="text"], input[type="number"] {
  width: 100%;
  font-family: inherit;
  font-size: 17px;
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 56px;
}

input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.input-row input {
  flex: 1;
}

/* ---------- Player list ---------- */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  gap: 10px;
}

.player-list .name {
  font-weight: 600;
  flex: 1;
  word-break: break-word;
}

.player-list .index {
  color: var(--muted);
  font-size: 13px;
  width: 22px;
}

.btn-remove {
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 18px;
  border-radius: 8px;
}

.btn-remove:hover {
  background: var(--surface-2);
  color: var(--danger);
}

/* ---------- Segmented control ---------- */
.segmented {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.segmented button {
  flex: 1;
  background: transparent;
  min-height: 48px;
  padding: 10px;
  border-radius: 10px;
  font-weight: 700;
  color: var(--muted);
}

.segmented button.active {
  background: var(--primary);
  color: white;
}

/* ---------- Toggle ---------- */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
  gap: 12px;
}

.toggle-row .toggle-label {
  font-weight: 600;
}

.toggle-row .toggle-desc {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-2);
  border-radius: 30px;
  transition: background 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}

.btn-back {
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  padding: 8px 12px;
  min-height: 40px;
}

/* ---------- Loading ---------- */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Score table ---------- */
.score-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
}

.score-list li.impostor {
  border-left: 4px solid var(--danger);
}

.score-list .points {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
}

.score-list .delta {
  color: var(--success);
  font-size: 13px;
  margin-left: 6px;
}

.badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Result banner ---------- */
.result-banner {
  text-align: center;
  padding: 24px;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 800;
}

.result-banner.win {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.result-banner.lose {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ---------- Hint ---------- */
.hint {
  margin-top: 12px;
  font-size: 18px;
  color: var(--warning);
  font-weight: 600;
}

.hint-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: block;
}

/* ---------- Misc ---------- */
.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.text-center {
  text-align: center;
}

footer {
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
