:root {
  --sea-deep: #0b2233;
  --sea: #123a52;
  --panel: #10303f;
  --line: #2b5a70;
  --text: #eef6f7;
  --muted: #9dbbc4;
  --signal: #ff7a3d;
  --gold: #ffd166;
  --container: #39b8c9;
  --bug: #ef476f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--sea-deep);
  color: var(--text);
  font-family: system-ui, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) 280px;
  gap: 24px;
  justify-content: center;
  align-items: start;
  padding: 24px 16px;
}

.hud {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.hud div {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.hud strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.canvas-wrap {
  position: relative;
  line-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--sea);
  border: 1px solid var(--line);
  border-radius: 6px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgb(11 34 51 / 88%);
  border-radius: 6px;
  line-height: 1.6;
  text-align: center;
}

.overlay[hidden] {
  display: none;
}

.overlay h1 {
  margin: 0;
  color: var(--signal);
  font-size: 44px;
  line-height: 1.1;
}

.overlay p {
  margin: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 0;
  padding: 0;
  font-size: 14px;
  list-style: none;
}

.legend[hidden] {
  display: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.chip-container {
  background: var(--container);
}

.chip-gold {
  background: var(--gold);
}

.chip-bug {
  background: var(--bug);
  border-radius: 50%;
}

button {
  min-height: 44px;
  padding: 10px 28px;
  color: #231006;
  background: var(--signal);
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.score-form {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 260px;
}

.score-form[hidden] {
  display: none;
}

.score-form label {
  font-size: 13px;
  text-align: left;
}

.score-form input {
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--sea-deep);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.score-form button {
  color: var(--text);
  background: var(--line);
}

.form-message {
  min-height: 22px;
  font-size: 13px;
}

.board {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.board h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.board ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.board li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 6px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: rank;
}

.board li::before {
  color: var(--muted);
  content: counter(rank);
}

.board li:first-child::before {
  color: var(--gold);
  font-weight: 700;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.note {
  padding: 8px 10px;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 6px;
  font-size: 13px;
}

.board footer {
  margin-top: 16px;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: minmax(0, 420px);
  }
}
