*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 1.25rem 0.75rem 2rem;
  background: #0f0f17;
  color: #e8e8ef;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.score-corner {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  z-index: 2;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  background: #16213e;
  border: 1px solid #3d3d5c;
  color: #e8e8ef;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.score-corner #score {
  font-weight: 700;
  min-width: 1ch;
  text-align: right;
}

.layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 760px;
}

#board-wrap {
  position: relative;
  width: 300px;
  height: 600px;
  flex-shrink: 0;
  background: #1a1a2e;
}

#board,
#next {
  display: block;
  background: #1a1a2e;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(8, 8, 16, 0.75);
  text-align: center;
}

.overlay-score {
  margin: 0;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.high-score-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.high-score-form.hidden {
  display: none;
}

.high-score-form p,
.high-score-form label {
  margin: 0;
  font-weight: 700;
}

#player-name {
  width: 5.5rem;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
  color: #e8e8ef;
  background: #1a1a2e;
  border: 1px solid #3d3d5c;
  padding: 0.35rem 0.4rem;
}

#player-name:focus-visible {
  outline: 2px solid #e8e8ef;
  outline-offset: 3px;
}

.hidden {
  display: none;
}

#overlay-text {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.high-scores,
.panel {
  flex-shrink: 0;
  padding: 1rem 1rem 1.15rem;
  background: #16213e;
}

.high-scores {
  width: 11.5rem;
}

.high-scores ol {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.high-scores li {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.high-scores .rank {
  width: 1.25rem;
  color: #9a9ab4;
}

.high-scores .name {
  width: 3.4ch;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.high-scores .points {
  margin-left: auto;
}

.high-scores li.latest .name,
.high-scores li.latest .points {
  color: #f2d15a;
}

.high-score-status {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: #f0a0a0;
}

.high-score-status:empty {
  display: none;
}

.panel {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.label {
  font-size: 0.85rem;
  font-weight: 600;
}

.next-block .label {
  margin: 0 0 0.4rem;
}

.stat {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 1rem;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

button {
  font: inherit;
  color: #e8e8ef;
  background: #1a1a2e;
  border: 1px solid #3d3d5c;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

button:hover {
  background: #24243a;
}

button:focus {
  outline: 2px solid #e8e8ef;
  outline-offset: 3px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

button:focus-visible {
  outline: 2px solid #e8e8ef;
  outline-offset: 3px;
}

.keys {
  margin: 0.15rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
    align-items: center;
  }

  #board-wrap {
    order: 1;
  }

  .panel,
  .high-scores {
    order: 2;
    width: 300px;
  }

  .high-scores {
    order: 3;
  }
}
