@import url("https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;700;800;900&display=swap");

:root {
  color-scheme: dark;
  --bg: #070708;
  --paper: #111112;
  --paper-2: #18191b;
  --paper-3: #25262a;
  --text: #ffffff;
  --muted: #a8a8aa;
  --line: #303136;
  --accent: #e3342f;
  --gold: #f1c45b;
  --green: #23d17b;
  --shadow: 0 18px 44px rgba(0, 0, 0, .32);
}

body.light {
  color-scheme: light;
  --bg: #f6f1e8;
  --paper: #fffaf0;
  --paper-2: #f0e9dc;
  --paper-3: #e6ddce;
  --text: #15120e;
  --muted: #6c6254;
  --line: #d4c7b4;
  --shadow: 0 22px 70px rgba(65, 45, 18, .16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, .14), transparent 24rem),
    radial-gradient(circle at 12% 10%, rgba(227, 52, 47, .16), transparent 28rem),
    linear-gradient(180deg, #121316 0%, var(--bg) 36%, #030303 100%);
  color: var(--text);
  font-family: "Fira Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light {
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, .72), transparent 24rem),
    radial-gradient(circle at 12% 10%, rgba(227, 52, 47, .08), transparent 28rem),
    linear-gradient(180deg, #fffaf0 0%, var(--bg) 42%, #ede3d5 100%);
}

button {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

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

.nav-actions {
  display: flex;
  gap: 8px;
}

.nav-left,
.season-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button,
.lang-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.mini-button.is-active,
.season-button.is-active,
.lang-pill {
  color: var(--text);
  border-color: var(--text);
  background: var(--paper-2);
}

.instruction-button {
  width: 34px;
  padding: 0;
  font-size: 16px;
}

.instructions-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .64);
}

.instructions-modal[hidden] {
  display: none;
}

.instructions-box {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), transparent 42%),
    var(--paper);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .54);
}

.instruction-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.4;
}

.instruction-list li::marker {
  color: var(--accent);
  font-weight: 900;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(330px, .72fr);
  gap: 18px;
  align-items: end;
  padding: 36px 0 22px;
}

.identity {
  min-width: 0;
}

.eyebrow,
.label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.score-logo {
  display: flex;
  align-items: baseline;
  gap: clamp(8px, 2vw, 22px);
  margin-bottom: 16px;
  font-size: clamp(78px, 18vw, 216px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: .78;
}

.score-logo span:nth-child(2) {
  color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 850px;
  font-size: clamp(34px, 6.2vw, 82px);
  line-height: .94;
  letter-spacing: 0;
  font-weight: 900;
}

h2 {
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1;
}

.intro {
  max-width: 680px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.control-panel,
.roll-panel,
.race-panel,
.results {
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .045), transparent 42%),
    color-mix(in srgb, var(--paper) 94%, transparent);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 16px;
}

.panel-header,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.record {
  display: grid;
  place-items: center;
  min-width: 74px;
  min-height: 48px;
  border-radius: 6px;
  background: var(--paper-2);
  font-size: 20px;
  font-weight: 900;
}

.season-grid {
  margin: 16px 0 14px;
}

.season-button {
  min-height: 40px;
  min-width: 74px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(310px, .72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: start;
}

.roll-panel,
.race-panel,
.results {
  padding: 16px;
}

.roll-panel {
  position: sticky;
  top: 14px;
}

.rolled-card {
  min-height: 148px;
  padding: 16px;
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .06), transparent 52%),
    var(--paper-2);
}

#currentRaceLabel {
  margin-bottom: 14px;
}

#rollHint {
  color: var(--muted);
  line-height: 1.45;
}

.roll-button,
.simulate-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 54px;
  border-radius: 6px;
  font-weight: 900;
  text-transform: uppercase;
}

.roll-button {
  margin-top: 12px;
  border: 0;
  color: #fff;
  background: var(--accent);
}

.dice-mark,
.flag-mark,
.reset-mark {
  position: relative;
  display: inline-block;
  width: 20px;
  height: 20px;
}

.dice-mark {
  border: 2px solid currentColor;
  border-radius: 6px;
}

.dice-mark::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 9px 0 currentColor, 4.5px 4.5px currentColor, 0 9px currentColor, 9px 9px currentColor;
  content: "";
}

.flag-mark {
  border-left: 2px solid currentColor;
}

.flag-mark::before {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 9px;
  border: 2px solid currentColor;
  border-left: 0;
  content: "";
}

.reset-mark {
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.reset-mark::after {
  position: absolute;
  right: -1px;
  top: 1px;
  width: 6px;
  height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(20deg);
  content: "";
}

.reroll-line {
  display: flex;
  justify-content: center;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.driver-select-wrap {
  display: block;
  position: relative;
}

.driver-picker-button {
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--paper-2);
  text-align: left;
  font-weight: 800;
}

.driver-picker-button::after {
  float: right;
  color: var(--muted);
  content: "v";
}

.driver-options {
  display: none;
  max-height: 330px;
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), transparent 46%),
    #0d0d0e;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .42);
}

body.light .driver-options {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .72), transparent 46%),
    #fffaf0;
  box-shadow: 0 16px 34px rgba(65, 45, 18, .18);
}

.driver-options.is-open {
  display: grid;
}

.driver-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: transparent;
  text-align: left;
}

.driver-option:last-child {
  border-bottom: 0;
}

.driver-option:hover,
.driver-option:focus-visible {
  background: rgba(255, 255, 255, .055);
}

body.light .driver-option:hover,
body.light .driver-option:focus-visible {
  background: rgba(21, 18, 14, .06);
}

.race-winner-option {
  background:
    linear-gradient(90deg, rgba(35, 209, 123, .14), transparent 68%),
    transparent;
}

.driver-option-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.driver-option-team {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-self: end;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.winner-pill {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border: 1px solid rgba(35, 209, 123, .68);
  border-radius: 3px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.ghost-button {
  margin-top: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.simulate-button {
  width: auto;
  min-width: 148px;
  padding: 0 16px;
  border: 0;
  color: #fff;
  background: #252525;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.share-actions .simulate-button {
  width: auto;
  min-width: 132px;
  min-height: 46px;
  font-size: 13px;
}

body.light .simulate-button {
  background: #181511;
}

.race-list,
.result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.race-slot,
.result-slot {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
}

.race-slot.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.race-slot.filled {
  background:
    linear-gradient(135deg, rgba(35, 209, 123, .12), transparent 54%),
    var(--paper-2);
}

.race-number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--paper-3);
  font-weight: 900;
}

.race-name,
.race-pick,
.race-meta {
  display: block;
  min-width: 0;
}

.race-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.race-pick {
  margin-top: 4px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.race-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.team-badge {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 18px;
  padding: 0 5px;
  border-radius: 3px;
  color: #fff;
  background: var(--team-color, #555);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
}

.results {
  margin-top: 18px;
}

.share-card {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 18px;
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  background: var(--paper-2);
}

.share-card strong {
  font-size: clamp(48px, 8vw, 96px);
  line-height: .9;
  font-weight: 900;
}

.share-card span:last-child {
  color: var(--muted);
  font-weight: 700;
}

.celebration {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  padding: 20px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: #07160d;
}

body.light .celebration {
  background: #f1fff6;
}

.celebration strong {
  display: block;
  color: var(--green);
  font-size: clamp(30px, 6vw, 74px);
  line-height: .9;
  font-weight: 900;
}

.celebration span {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -18px;
  width: 7px;
  height: 14px;
  background: var(--piece-color, var(--accent));
  animation: confetti-fall 1.55s ease-in forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(260px) rotate(520deg);
    opacity: 0;
  }
}

#resultScore {
  font-size: clamp(48px, 8vw, 92px);
}

.result-slot.win {
  border: 2px solid var(--green);
}

.result-slot.loss {
  border: 0;
}

.result-slot .race-name,
.result-slot .race-pick {
  white-space: normal;
}

.site-footer {
  margin: 22px 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.site-footer a {
  color: var(--text);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

@media (max-width: 880px) {
  .hero,
  .game-grid {
    grid-template-columns: 1fr;
  }

  .roll-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 12px;
  }

  .panel-header,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .score-logo {
    font-size: clamp(82px, 27vw, 126px);
  }

  .race-list,
  .result-list {
    grid-template-columns: 1fr;
  }

  .driver-options {
    max-height: min(58vh, 420px);
  }

  .driver-option {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 64px;
    padding: 10px 12px;
  }

  .driver-option-name {
    white-space: normal;
  }

  .driver-option-team {
    justify-self: start;
    flex-wrap: wrap;
  }

  .simulate-button {
    width: 100%;
  }

  .share-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
