:root {
  --bg: #070b12;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.1);
  --text: #f5f7ff;
  --muted: rgba(245, 247, 255, 0.7);
  --border: rgba(255, 255, 255, 0.14);

  --auto: #00d1ff;
  --teleop: #7bff6a;
  --endgame: #ffbf3c;
  --over: #ff4d5e;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    "Apple Color Emoji",
    "Segoe UI Emoji";
  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(0, 209, 255, 0.18), transparent 55%),
    radial-gradient(1100px 700px at 90% 30%, rgba(123, 255, 106, 0.14), transparent 60%),
    radial-gradient(1200px 900px at 40% 100%, rgba(255, 191, 60, 0.14), transparent 60%),
    linear-gradient(180deg, #05060b 0%, var(--bg) 100%);
}

.header {
  padding: 20px 18px 10px;
}

.header__top {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.header__title {
  margin: 0;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(18px, 2.4vw, 30px);
  text-wrap: balance;
}

.header__logos {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header__logo {
  height: 38px;
  max-width: min(44vw, 360px);
  object-fit: contain;
  background: rgba(255, 255, 255, 0.94);
  padding: 6px 10px;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.header__logo--rounded {
  background: rgba(255, 255, 255, 0.94);
}

.main {
  padding: 12px 18px 26px;
  display: grid;
  place-items: center;
}

.timer {
  width: min(1100px, 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 32px);
  backdrop-filter: blur(14px);
}

.timer__status {
  font-size: clamp(14px, 1.6vw, 18px);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.timer__time {
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-size: clamp(72px, 11vw, 170px);
  line-height: 0.95;
}

.timer__countdown {
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
  font-size: clamp(44px, 6vw, 86px);
  letter-spacing: -0.03em;
  color: rgba(245, 247, 255, 0.95);
  text-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.timer__progress {
  margin-top: 18px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.timer__bar {
  height: 100%;
  width: 0%;
  background: var(--auto);
  transition: width 150ms linear;
}

.controls {
  margin-top: 22px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 750;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 3px solid rgba(0, 209, 255, 0.45);
  outline-offset: 3px;
}

.btn--primary {
  border-color: rgba(0, 209, 255, 0.55);
  background: rgba(0, 209, 255, 0.16);
}

.btn--primary:hover {
  border-color: rgba(0, 209, 255, 0.8);
  background: rgba(0, 209, 255, 0.22);
}

.btn--small {
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 12px;
}

.settings {
  margin-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 16px;
}

.settings summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.settings__form {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.field {
  display: grid;
  gap: 6px;
}

.field--row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field__label {
  color: rgba(245, 247, 255, 0.84);
  font-weight: 650;
}

.field__input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 16px;
  width: 100%;
}

.field__input:focus-visible {
  outline: 3px solid rgba(123, 255, 106, 0.35);
  outline-offset: 2px;
}

.field__checkbox {
  transform: scale(1.1);
}

.settings__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  padding: 0.12em 0.42em;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.25);
  color: rgba(245, 247, 255, 0.92);
}

.footer {
  padding: 0 18px 22px;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
}

.footer__hint {
  font-size: 13px;
}

/* Phase colors (set by JS on <body>) */
body[data-phase="auto"] .timer__bar {
  background: var(--auto);
}

body[data-phase="teleop"] .timer__bar {
  background: var(--teleop);
}

body[data-phase="endgame"] .timer__bar {
  background: var(--endgame);
}

body[data-phase="over"] .timer__bar {
  background: var(--over);
}

body[data-phase="auto"] .timer__time {
  text-shadow: 0 0 30px rgba(0, 209, 255, 0.28);
}

body[data-phase="teleop"] .timer__time {
  text-shadow: 0 0 30px rgba(123, 255, 106, 0.22);
}

body[data-phase="endgame"] .timer__time {
  text-shadow: 0 0 30px rgba(255, 191, 60, 0.22);
}

body[data-phase="over"] .timer__time {
  text-shadow: 0 0 30px rgba(255, 77, 94, 0.22);
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .timer__bar {
    transition: none;
  }
}
