:root {
  color-scheme: light;
  --bg: #eef8f2;
  --ink: #10202a;
  --muted: #5d6f78;
  --panel: #ffffff;
  --line: #cbdad6;
  --sea: #116f95;
  --reef: #0f6c5d;
  --sun: #f0b84a;
  --danger: #c84a34;
  --shadow: 0 18px 44px rgb(16 32 42 / 14%);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgb(112 199 219 / 26%), transparent 44%),
    linear-gradient(135deg, #f7fbf8 0%, #e8f4ed 52%, #f8e7b5 100%);
}

body,
button,
input {
  font: inherit;
}

button,
input {
  color: inherit;
}

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

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

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

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

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

.play-panel {
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.topbar p,
.player-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1,
.side-panel h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar h1 {
  margin-top: 0.12rem;
  font-size: clamp(1.8rem, 5vw, 3.8rem);
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(5.25rem, 1fr));
  gap: 0.5rem;
}

.score-strip span {
  display: grid;
  gap: 0.12rem;
  min-height: 4.5rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-strip strong {
  color: var(--sea);
  font-size: 2rem;
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 3 / 2;
  min-height: 280px;
  background: #77c7dd;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.game-prompt {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  width: min(92%, 28rem);
  min-height: 3rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 86%);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.play-panel[data-status="playing"] .game-prompt {
  opacity: 0;
}

.game-prompt strong {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
}

.side-panel {
  display: grid;
  gap: 1.1rem;
  padding: 1rem;
}

.player-box {
  display: grid;
  gap: 0.65rem;
}

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

input {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  font-weight: 800;
}

button {
  min-height: 2.95rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--sea);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  background: #0d5c7a;
}

input:focus,
button:focus-visible,
canvas:focus-visible,
.skip-link:focus {
  outline: 3px solid rgb(240 184 74 / 54%);
  outline-offset: 2px;
}

.side-panel h2 {
  font-size: 1.35rem;
}

.leaderboard {
  display: grid;
  gap: 0.45rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: scores;
}

.leaderboard li {
  counter-increment: scores;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.leaderboard li::before {
  content: counter(scores);
  display: inline-grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgb(17 111 149 / 12%);
  color: var(--sea);
  font-size: 0.78rem;
  font-weight: 900;
}

.leaderboard span {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.leaderboard strong {
  color: var(--reef);
  font-size: 1.1rem;
}

.leaderboard .empty-score {
  grid-template-columns: 1fr;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.leaderboard .empty-score::before {
  content: none;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

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

  .topbar,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .score-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-wrap {
    min-height: 230px;
  }
}
