:root {
  color-scheme: light;
  --bg: #f4fbff;
  --ink: #10202b;
  --muted: #5e7080;
  --panel: #ffffff;
  --line: #c9dbe6;
  --water: #127fa6;
  --water-deep: #075976;
  --coral: #e46d50;
  --sun: #f5bd45;
  --shadow: 0 18px 50px rgb(7 47 63 / 14%);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 72%), rgb(244 251 255 / 88%)),
    url("data:image/svg+xml,%3Csvg width='220' height='120' viewBox='0 0 220 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 76c36-22 72-22 108 0s74 22 112 0v44H0z' fill='%23127fa6' fill-opacity='.12'/%3E%3Cpath d='M0 44c36-20 72-20 108 0s74 20 112 0v20c-38 20-76 20-112 0S36 44 0 64z' fill='%23f5bd45' fill-opacity='.13'/%3E%3C/svg%3E");
}

body,
button,
input {
  font: inherit;
}

button,
input {
  color: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.topbar,
.top-actions,
.game-layout,
.game-header,
.control-row,
.leaderboard-head {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
}

.topbar h1,
.play-section h2,
.leaderboard h2 {
  margin: 0;
  line-height: 1.02;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.5rem, 3.4vw, 2.4rem);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--coral);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions {
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 78%);
}

.top-actions span,
.top-actions strong {
  min-width: 5.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: calc(var(--radius) - 2px);
  text-align: center;
}

.top-actions span {
  color: var(--muted);
  font-weight: 800;
}

.top-actions strong {
  background: var(--water-deep);
  color: #fff;
}

.game-layout {
  align-items: flex-start;
  gap: 1rem;
}

.play-section,
.leaderboard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow);
}

.play-section {
  flex: 1 1 760px;
  min-width: 0;
  overflow: hidden;
}

.game-header {
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 2.4vw, 1.5rem);
}

.play-section h2 {
  font-size: clamp(2rem, 5vw, 4.2rem);
}

.player-field {
  display: grid;
  gap: 0.35rem;
  min-width: min(220px, 100%);
}

.player-field span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
}

input {
  min-height: 2.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.65rem 0.75rem;
}

input:focus,
button:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(18 127 166 / 30%);
  outline-offset: 2px;
}

.canvas-wrap {
  position: relative;
  background: var(--water);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 12 / 7;
  max-height: min(62vh, 520px);
  touch-action: manipulation;
}

.score-chip {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: grid;
  min-width: 5.5rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgb(255 255 255 / 44%);
  border-radius: var(--radius);
  background: rgb(5 46 60 / 72%);
  color: #fff;
}

.score-chip span {
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-chip strong {
  font-size: 2rem;
  line-height: 1;
}

.control-row {
  align-items: center;
  gap: 0.65rem;
  padding: clamp(1rem, 2.4vw, 1.5rem);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 6.2rem;
  min-height: 2.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 900;
  cursor: pointer;
}

.button.primary {
  background: var(--water-deep);
  color: #fff;
}

.button.secondary {
  border-color: var(--line);
  background: #fff;
}

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

.control-row p {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.leaderboard {
  flex: 0 0 360px;
  overflow: hidden;
}

.leaderboard-head {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.leaderboard h2 {
  font-size: 1.7rem;
}

.best-box {
  display: grid;
  min-width: 4.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: #fff4d8;
  text-align: center;
}

.best-box span {
  color: #8a5d12;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.best-box strong {
  font-size: 1.8rem;
  line-height: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

th,
td {
  padding: 0.78rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

td:first-child,
th:first-child,
td:nth-child(3),
th:nth-child(3) {
  text-align: center;
}

td:nth-child(2) {
  max-width: 9rem;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  font-weight: 900;
}

@media (max-width: 900px) {
  .game-layout,
  .game-header,
  .control-row,
  .site-footer {
    flex-direction: column;
  }

  .game-header,
  .control-row {
    align-items: stretch;
  }

  .leaderboard {
    flex: 1 1 auto;
    width: 100%;
  }

  .control-row p {
    margin: 0;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 1rem, 1180px);
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: space-between;
  }

  .play-section h2 {
    font-size: 2rem;
  }

  th,
  td {
    padding: 0.68rem 0.45rem;
    font-size: 0.82rem;
  }

  td:nth-child(4),
  th:nth-child(4) {
    display: none;
  }
}
