:root {
  color-scheme: light;
  --ink: #202634;
  --muted: #667085;
  --panel: #fffdf8;
  --line: #d8e0dd;
  --sky: #7fd6eb;
  --blue: #22658f;
  --green: #36a35b;
  --orange: #f29f3d;
  --red: #cf4a3a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #e2f7f3 0%, #fff0c7 52%, #e9f1ff 100%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid rgba(32, 38, 52, 0.16);
  border-radius: 7px;
  padding: 0 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid #194cff;
  outline-offset: 3px;
}

h1,
h2,
p {
  margin: 0;
}

.shell {
  width: min(1060px, calc(100vw - 28px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 18px 0;
  display: grid;
  grid-template-columns: minmax(310px, 530px) minmax(250px, 320px);
  align-items: start;
  justify-content: center;
  gap: 16px;
}

.game-card,
.leaderboard-card {
  overflow: hidden;
  border: 1px solid rgba(32, 38, 52, 0.13);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 18px 50px rgba(32, 38, 52, 0.14);
}

.topbar,
.leaderboard-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

h1,
h2 {
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p,
.leaderboard-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.buttons {
  display: flex;
  gap: 8px;
}

#soundButton[aria-pressed="true"] {
  background: var(--red);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 400 / 600;
  border-top: 1px solid rgba(32, 38, 52, 0.13);
  background: var(--sky);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.score {
  position: absolute;
  top: 12px;
  left: 12px;
  min-width: 76px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(32, 38, 52, 0.58);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.score span {
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score strong {
  display: block;
  margin-top: 3px;
  font-size: 2rem;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 38, 52, 0.2);
}

.overlay[hidden] {
  display: none;
}

.dialog {
  width: min(330px, 100%);
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 18px 45px rgba(32, 38, 52, 0.22);
}

.dialog > p:first-child {
  color: var(--orange);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dialog h2 {
  margin-top: 4px;
  font-size: 1.65rem;
}

.dialog > p:not(:first-child) {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.score-form {
  margin-top: 14px;
}

.score-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.score-form div,
.actions {
  display: flex;
  gap: 8px;
}

input {
  min-width: 0;
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.actions {
  margin-top: 16px;
}

.actions button:first-child,
.score-form button {
  background: var(--green);
}

.leaderboard-card header {
  border-bottom: 1px solid rgba(32, 38, 52, 0.11);
}

#clearButton {
  color: var(--ink);
  background: transparent;
}

#leaderboard {
  min-height: 220px;
  margin: 0;
  padding: 8px 14px 14px 34px;
}

#leaderboard li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(32, 38, 52, 0.09);
  font-weight: 800;
}

#leaderboard span {
  float: right;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(290px, 530px);
  }
}

@media (max-width: 470px) {
  .shell {
    width: 100%;
    padding: 0;
  }

  .game-card,
  .leaderboard-card {
    border-radius: 0;
  }

  .topbar,
  .leaderboard-card header {
    flex-wrap: wrap;
  }
}
