:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #0f1115);
  --card: var(--tg-theme-secondary-bg-color, #1a1d24);
  --text: var(--tg-theme-text-color, #f5f7fb);
  --muted: var(--tg-theme-hint-color, #9aa3b2);
  --accent: var(--tg-theme-button-color, #6c5ce7);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #ff5c72);
  --line: color-mix(in srgb, var(--text) 12%, transparent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 32px; line-height: 1; }
h2 { font-size: 20px; margin-bottom: 8px; }
h3 { font-size: 16px; margin-bottom: 8px; }

.card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .12);
}

.badge {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.timer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timer-card span { color: var(--muted); }
.timer-card strong { font-size: 26px; font-variant-numeric: tabular-nums; }

.role-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.role-emoji { font-size: 40px; }
.role-title h2 { margin: 0; }
.role-title small { display: block; color: var(--muted); margin-top: 3px; }

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

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.action-button, .primary-button, .secondary-button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}

.action-button:active, .primary-button:active, .secondary-button:active { transform: scale(.98); }
.action-button:disabled, .primary-button:disabled { cursor: wait; opacity: .6; }

.action-button {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border: 1px solid var(--line);
}

.action-button.selected {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.primary-button {
  width: 100%;
  margin-top: 10px;
  color: var(--accent-text);
  background: var(--accent);
  font-weight: 700;
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

.player-list, .history-list, .team-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.player-row, .history-row, .team-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.player-row:last-child, .history-row:last-child, .team-row:last-child { border-bottom: 0; }
.dead { opacity: .48; text-decoration: line-through; }

.loading, .notice, .error { line-height: 1.45; }
.error { color: var(--danger); }
.notice { color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 380px) {
  .actions-grid { grid-template-columns: 1fr; }
  h1 { font-size: 28px; }
}
