@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&display=swap");

:root {
  --amber: #f5b84b;
  --blue: #2f5fb3;
  --green: #1f8f4d;
  --ink: #171717;
  --line: #d7dce8;
  --muted: #62666f;
  --orange: #d97706;
  --paper: #f3f7fb;
  --panel: #fffdf8;
  --red: #d94b2b;
  --shadow: rgba(23, 23, 23, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 95, 179, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(31, 143, 77, 0.08) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  color: var(--ink);
  display: flex;
  align-items: center;
  font-family: "Inter", system-ui, -apple-system, blinkmacsystemfont, "segoe ui", sans-serif;
}

body::before {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: 10px;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--amber), var(--red));
  content: "";
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  width: min(1220px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 32px;
}

section {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--shadow);
  padding: 22px;
}

.chart-card,
.leaderboard-card {
  min-width: 0;
}

.chart-card {
  display: grid;
}

.leaderboard-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.chart-header,
.guess-form,
.guess-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chart-header {
  margin-bottom: 14px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(47, 95, 179, 0.08), rgba(31, 143, 77, 0.04)),
    #ffffff;
  aspect-ratio: 16 / 9;
  margin: 18px 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 8px;
}

h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.1;
}

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

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.round-track {
  display: flex;
  gap: 8px;
}

.round-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.round-step.is-current {
  background: var(--amber);
}

.round-step.is-done {
  background: var(--green);
  color: #ffffff;
}

input {
  width: 100%;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  padding: 0 16px;
  text-decoration: none;
  cursor: pointer;
}

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

.auto-next,
.final-score-button {
  width: fit-content;
  background:
    linear-gradient(to right, var(--ink) 0 50%, #9ca3af 50% 100%)
    100% 0 / 200% 100%;
  animation: fill-next 5s linear forwards;
  will-change: background-position;
}

.final-score-button {
  animation-duration: 2.5s;
}

@keyframes fill-next {
  from {
    background-position: 100% 0;
  }

  to {
    background-position: 0 0;
  }
}

.guess-form {
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.guess-form span {
  color: var(--ink);
  font-weight: 700;
}

.result-pill {
  --score-bg: var(--ink);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 2px;
  min-width: 118px;
  border: 2px solid var(--score-bg);
  border-radius: 8px;
  background: var(--score-bg);
  color: var(--score-fg);
  padding: 12px 14px;
  text-align: right;
}

.score-great {
  --score-bg: var(--green);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.78);
}

.score-good {
  --score-bg: var(--blue);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.78);
}

.score-ok {
  --score-bg: var(--amber);
  --score-fg: var(--ink);
  --score-muted: rgba(23, 23, 23, 0.62);
}

.score-low {
  --score-bg: var(--orange);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.78);
}

.score-rough {
  --score-bg: var(--red);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.78);
}

.result-pill strong {
  font-size: 1.7rem;
  line-height: 1;
}

.score-label,
.score-detail {
  color: var(--score-muted);
}

.score-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-detail {
  font-size: 0.92rem;
}

.game-over-dialog {
  width: min(430px, calc(100% - 32px));
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 10px 10px 0 var(--shadow);
  color: var(--ink);
  padding: 24px;
}

.game-over-dialog::backdrop {
  background: rgba(23, 23, 23, 0.42);
}

.game-over-dialog form {
  display: grid;
  gap: 14px;
}

.game-over-dialog h2 {
  font-size: 2.1rem;
}

.game-over-dialog label {
  color: var(--muted);
  font-weight: 800;
}

.previous-guesses {
  margin-top: auto;
  padding-top: 28px;
}

.guess-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.guess-list li {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 10px;
}

.guess-list li > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  font-weight: 800;
}

.guess-list small {
  color: var(--muted);
  font-size: 0.84rem;
}

.guess-list li > small {
  margin-left: auto;
}

.guess-list strong {
  color: var(--blue);
}

.guess-list .score-badge {
  --score-bg: var(--ink);
  --score-fg: #ffffff;
  --score-muted: rgba(255, 255, 255, 0.72);
  display: grid;
  min-width: 78px;
  border: 2px solid var(--score-bg);
  border-radius: 8px;
  background: var(--score-bg);
  color: var(--score-fg);
  justify-items: end;
  line-height: 1;
  padding: 6px 8px;
}

.guess-list .score-badge small {
  color: var(--score-muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  background: #ffffff;
  font-weight: 700;
}

td:first-child {
  border-left: 2px solid var(--line);
  border-radius: 8px 0 0 8px;
}

td:last-child {
  border-right: 2px solid var(--line);
  border-radius: 0 8px 8px 0;
}

tr.is-current-player td {
  border-color: var(--blue);
  background: #eff5ff;
}

.you-marker {
  color: #8b8b8b;
  font-weight: 600;
}

th:last-child,
td:last-child {
  text-align: right;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@media (max-width: 900px) {
  body {
    align-items: flex-start;
  }

  main {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    aspect-ratio: 4 / 3;
  }

  .chart-header,
  .guess-form {
    align-items: stretch;
    flex-direction: column;
  }

  .result-pill {
    text-align: left;
  }
}
