@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Mono:wght@400;700&display=swap');

:root {
  color-scheme: light;
  --ink: #173e35;
  --ink-deep: #102f2a;
  --paper: #f4f2e8;
  --sun: #f6bd4b;
  --berry: #dc5e4b;
  --mint: #c6e7a6;
  --line: #31564a;
  font-family: 'Space Mono', 'Courier New', monospace;
  background: #d9e4d1;
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: #d9e4d1;
  background-image: radial-gradient(#173e3517 0.8px, transparent 0.8px);
  background-size: 8px 8px;
}

button { font: inherit; }

.cabinet {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 10px 24px;
}

.game-heading, .session-name, .hud, .hud-group, .screen-footer, .game-footer, .controls-copy, .sound-button {
  display: flex;
  align-items: center;
}

.game-panel { padding: 16px 26px 12px; border: 2px solid var(--ink); background: var(--paper); box-shadow: 7px 7px 0 var(--ink); }
.game-heading { justify-content: space-between; gap: 12px; margin-bottom: 11px; }
h1 { margin: 0; font-family: 'Press Start 2P', monospace; font-size: clamp(16px, 4vw, 22px); line-height: 1.55; letter-spacing: 0; }
.session-name { min-width: 0; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 9px; }
.session-name span, .hud-label { color: #adc29c; font-size: 8px; font-weight: 700; }
.session-name strong { max-width: 180px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.session-name .coin-balance { display: flex; align-items: center; gap: 5px; color: var(--ink); }
.session-name .coin-balance strong { max-width: none; font-size: 10px; }
.coin-icon { display: grid; width: 15px; height: 15px; place-items: center; border: 1px solid var(--ink); border-radius: 50%; background: var(--sun); font-size: 8px; }

.screen-frame { padding: 7px; border: 2px solid var(--ink); background: var(--ink-deep); box-shadow: inset 0 0 0 2px #285447; }
.hud { justify-content: space-between; min-height: 32px; padding: 0 5px 4px; color: #f8f0d4; }
.hud-group { gap: 10px; }
.hud-group strong { min-width: 38px; font-size: 11px; }
.lives-group strong { color: #f68168; font-size: 12px; letter-spacing: 0; }
.level-tag { padding: 4px 6px; border: 1px solid #83ad75; color: #c6e7a6; font-size: 8px; }
.canvas-wrap { position: relative; width: 100%; overflow: hidden; background: #8ed3bc; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.screen-message { position: absolute; inset: 0; display: grid; place-items: center; background: #102f2a99; animation: message-in 160ms steps(3, end) both; }
.screen-message[hidden] { display: none; }
.message-box { width: min(84%, 310px); max-height: calc(100% - 24px); overflow-y: auto; padding: 20px 14px 17px; border: 3px solid var(--ink); outline: 3px solid #f4f2e8; background: var(--paper); text-align: center; box-shadow: 5px 5px 0 #102f2a; }
.message-kicker { margin: 0 0 10px; color: #668265; font-size: 9px; }
.message-box h2 { margin: 0 0 17px; font-family: 'Press Start 2P', monospace; font-size: 16px; line-height: 1.7; }
.message-box button { padding: 11px 12px; border: 2px solid var(--ink); background: var(--sun); color: var(--ink); font-size: 10px; font-weight: 700; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.message-box button:hover, .message-box button:focus-visible { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.message-box button span { margin-left: 5px; }
.message-box .guest-button { margin-top: 10px; background: var(--mint); }
.message-hint { display: block; margin-top: 12px; color: #6a7d68; font-size: 8px; }
.name-label { display: block; margin-bottom: 7px; color: #6a7d68; font-size: 8px; font-weight: 700; text-align: left; }
.message-box input { width: 100%; margin-bottom: 13px; padding: 10px; border: 2px solid var(--ink); background: #fffdf4; color: var(--ink); font: inherit; font-size: 12px; }
.message-box input:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.message-box button:focus-visible, .sound-button:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
.run-result { margin: -5px 0 16px; color: var(--ink); font-size: 10px; line-height: 1.8; }
.player-scoreboard { margin: 0 0 16px; text-align: left; }
.player-scoreboard h3 { margin: 0 0 7px; color: #668265; font-size: 9px; text-align: center; }
.player-scoreboard ol { margin: 0; padding-left: 27px; font-size: 9px; line-height: 1.8; }
.player-scoreboard li { padding-left: 2px; }
.message-box #shop-button { margin: 8px 0 0; background: var(--mint); }
.shop-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop-heading h3 { margin: 0; color: #668265; font-size: 10px; }
.shop-heading p { margin: 0; color: var(--ink); font-size: 9px; }
.shop-heading p > span { color: #d49a28; }
.shop-intro { margin: 8px 0; color: #6a7d68; font-size: 8px; }
.shop-items { display: grid; max-height: clamp(140px, 22vh, 210px); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow-y: auto; margin: 10px 0; text-align: center; }
.shop-item { display: flex; min-width: 0; flex-direction: column; align-items: center; padding: 8px 5px; border: 1px solid #b5c4a5; background: #fffdf4; }
.shop-item-icon { min-height: 25px; font-size: 20px; line-height: 1.2; }
.shop-item h3 { margin: 4px 0; font-size: 8px; line-height: 1.5; }
.shop-item p { min-height: 26px; margin: 0 0 5px; color: #6a7d68; font-size: 7px; line-height: 1.4; }
.shop-item-price { margin: auto 0 5px; color: #668265; font-size: 7px; font-weight: 700; }
.message-box .shop-item button { width: 100%; padding: 6px 3px; font-size: 8px; }
.message-box .shop-item button:disabled { border-color: #aeb9a7; background: #e6e7dc; color: #7a8376; cursor: not-allowed; box-shadow: none; transform: none; }
.shop-actions { display: flex; justify-content: center; gap: 8px; }
.message-box .shop-actions button { padding: 9px 7px; font-size: 8px; }
.message-box .shop-actions #shop-play-button { background: var(--mint); }
.account-status { margin: 7px 0 0; color: #668265; font-size: 9px; line-height: 1.6; text-align: center; }
.account-status[data-error="true"] { color: #a33d35; }
.screen-footer { justify-content: space-between; padding: 5px 4px 0; color: #c6e7a6; font-size: 8px; }
kbd { padding: 2px 4px; border: 1px solid #91ad81; font: inherit; }

.game-footer { justify-content: space-between; gap: 12px; padding: 10px 1px 0; }
.controls-copy { gap: 9px; }
.controls-copy p { margin: 0; color: #637768; font-size: 8px; line-height: 1.7; }
.controls-copy strong { color: var(--ink); font-size: 9px; }
.pixel-arrow, .pixel-badge { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--ink); background: var(--mint); font-family: 'Press Start 2P', monospace; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.pixel-badge { background: #f4cf77; font-size: 11px; }
.direction-pad { display: grid; grid-template-rows: repeat(2, 44px); grid-template-columns: repeat(3, 44px); grid-template-areas: ". up ." "left down right"; gap: 5px; }
.direction-pad[hidden] { display: none; }
.direction-pad button { display: grid; place-items: center; padding: 0; border: 1px solid var(--ink); background: var(--mint); color: var(--ink); font-size: 20px; font-weight: 700; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); touch-action: manipulation; user-select: none; }
.direction-pad button[data-move="up"] { grid-area: up; }
.direction-pad button[data-move="left"] { grid-area: left; }
.direction-pad button[data-move="down"] { grid-area: down; }
.direction-pad button[data-move="right"] { grid-area: right; }
.direction-pad button:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.direction-pad button:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.sound-button { gap: 6px; padding: 8px 9px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-size: 9px; font-weight: 700; cursor: pointer; }
.sound-button span { font-size: 16px; line-height: 1; }
.sound-button:hover, .sound-button:focus-visible { background: var(--mint); }
@keyframes message-in { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 700px) and (min-height: 600px) {
  canvas { width: min(100%, calc((100vh - 300px) * 0.736842)); margin: 0 auto; }
}

@media (max-width: 540px) {
  .cabinet { padding: 10px 15px 16px; }
  .game-panel { padding: 14px 14px 12px; box-shadow: 5px 5px 0 var(--ink); }
  .game-footer { justify-content: space-between; gap: 10px; flex-wrap: wrap; }
  .controls-copy { gap: 6px; }
  .controls-copy p { font-size: 7px; }
  .pixel-arrow, .pixel-badge { width: 25px; height: 25px; }
  .sound-button { margin-left: auto; }
  .screen-footer { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
