* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #081009;
  --accent: #cfe08a;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  font-family: "Press Start 2P", monospace;
  color: var(--accent);
  image-rendering: pixelated;
}

.game {
  display: flex;
  gap: 2.2%;
  align-items: stretch;
  height: min(832px, 88vh);
  max-width: 100%;
}

/* ---- Board (left) ---- */
.board {
  position: relative;
  height: 100%;
  aspect-ratio: 1402 / 1122;
  background: url("assets/board.png") center / 100% 100% no-repeat;
}

/* Playfield: positioned exactly over the grid inside the board's pixel border */
.play {
  position: absolute;
  left: 4.49%;
  top: 6.24%;
  width: 90.37%;
  height: 87.34%;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ---- Highscore panel (right) ---- */
.panel {
  position: relative;
  height: 100%;
  display: flex;
}

.panel img {
  height: 100%;
  width: auto;
  display: block;
  image-rendering: pixelated;
}

/* Live highscore rows drawn over the frame in the panel image */
.hs-list {
  position: absolute;
  list-style: none;
  /* covers the baked-in rows frame inside assets/highscore.png */
  top: 24.8%;
  bottom: 11.0%;
  left: 24.2%;
  right: 24.2%;
  margin: 0;
  padding: 0.4%;
  display: flex;
  flex-direction: column;
  /* opaque fill hides the rows baked into the image */
  background: #0d1d0f;
  gap: 1.0%;
}

.hs-row {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 6%;
  border: 2px solid #3f5a24;
  border-radius: 8px;
  background: #0d1d0f;
  font-size: clamp(6px, 1.15vh, 11px);
  color: #cfe08a;
  overflow: hidden;
}

.hs-row .rank {
  color: #e8e5b5;
  min-width: 2.4em;
}

.hs-row .name {
  color: #e8e5b5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hs-row .dots {
  flex: 1;
  overflow: hidden;
  color: #6f8140;
  letter-spacing: 2px;
  white-space: nowrap;
}

.hs-row .score {
  color: #cfe08a;
  white-space: nowrap;
}

.hs-row.is-empty {
  opacity: 0.4;
}

.hs-row.is-empty .rank { color: #6f8140; }

.hs-row.is-new {
  border-color: #e8e5b5;
  background: #1a2d12;
  animation: blink 0.6s steps(2, start) 6;
}

@keyframes blink {
  50% { border-color: #cfe08a; background: #26401a; }
}

/* ---- Name entry (game over) ---- */
.name-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.name-entry.hidden { display: none; }

.overlay-hint.accent { color: #e8e5b5; }

#nameInput {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(10px, 1.6vh, 16px);
  text-transform: uppercase;
  text-align: center;
  color: #e8e5b5;
  background: #0d1d0f;
  border: 2px solid #cfe08a;
  border-radius: 6px;
  padding: 10px 12px;
  width: min(240px, 60vw);
  outline: none;
}

#saveScore {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(9px, 1.4vh, 13px);
  color: #0d1d0f;
  background: #cfe08a;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
}

#saveScore:hover { background: #e8e5b5; }

/* ---- Overlays ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  background: rgba(8, 16, 9, 0.78);
  color: var(--accent);
  padding: 20px;
}

.overlay.hidden { display: none; }

.overlay-title {
  font-size: clamp(20px, 3.4vh, 40px);
  letter-spacing: 2px;
  color: #e8e5b5;
  text-shadow: 3px 3px 0 #1b2e14;
}

.overlay-score {
  font-size: clamp(12px, 1.8vh, 20px);
  color: #cfe08a;
}

.overlay-hint {
  font-size: clamp(8px, 1.3vh, 12px);
  line-height: 1.8;
  color: #9fb567;
}

@media (max-width: 720px) {
  .game { flex-direction: column; height: auto; }
  .board { width: 100%; height: auto; }
  .panel { height: auto; justify-content: center; }
  .panel img { width: 80%; height: auto; }
}
