@font-face {
  font-family: "Silkscreen";
  src: url("./assets/fonts/Silkscreen-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --cream: #fff7df;
  --paper: #fffdf4;
  --plum: #34313e;
  --plum-soft: #61556c;
  --coral: #ffb7a5;
  --pink: #ed9eb7;
  --mint: #c5e7b1;
  --mint-edge: #86bda0;
  --lavender: #ded4f1;
  --aqua: #96dce2;
  --focus: #8a2257;
  --shadow: #34313e26;
  font-family: "Silkscreen", "Courier New", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--plum);
  background-image: linear-gradient(90deg, transparent 97%, #e9dfc1 97%),
    linear-gradient(transparent 97%, #e9dfc1 97%);
  background-size: 48px 48px;
}
button, summary, a, canvas { -webkit-tap-highlight-color: transparent; }
button {
  min-height: 44px;
  padding: 9px 14px;
  border: 2px solid var(--plum);
  border-radius: 3px;
  color: var(--plum);
  background: var(--paper);
  font: inherit;
  font-size: 12px;
  box-shadow: 0 3px 0 var(--plum);
  cursor: pointer;
  touch-action: manipulation;
}
button:hover { background: var(--lavender); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--plum); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible, canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}
.game-shell { width: min(100% - 32px, 800px); margin: 20px auto 16px; }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.title-lockup { display: flex; gap: 12px; align-items: center; min-width: 0; }
.title-lockup img { image-rendering: pixelated; }
h1 { margin: 0; font-size: clamp(20px, 3.8vw, 30px); font-weight: 400; line-height: 1.2; }
.title-lockup p { margin: 5px 0 0; font-size: 11px; color: var(--plum-soft); }
#sound { background: var(--mint); white-space: nowrap; }
.hud {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border: 2px solid var(--plum);
  border-bottom: 0; padding: 12px 8px; gap: 5px; text-align: center;
}
.hud-label { display: block; font-size: 10px; color: var(--plum-soft); margin-bottom: 5px; }
.hud output { font-size: 18px; font-variant-numeric: tabular-nums; }
#hearts { color: var(--focus); }
.playfield { position: relative; border: 3px solid var(--plum); background: var(--mint); }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; touch-action: manipulation; }
.overlay {
  position: absolute; left: 50%; top: 57%; transform: translate(-50%, -50%);
  width: min(88%, 400px); padding: 20px; text-align: center;
  border: 3px solid var(--plum); background: var(--paper);
  box-shadow: 6px 6px 0 var(--shadow);
}
.overlay img { image-rendering: pixelated; margin-bottom: 8px; }
.overlay h2 { font-size: 20px; font-weight: 400; line-height: 1.35; margin: 0 0 12px; }
.overlay p { font: 15px/1.6 system-ui, sans-serif; margin: 0 0 14px; }
.overlay .overlay-hint { font-size: 12px; margin: 14px 0 0; }
.primary { background: var(--coral); font-size: 14px; padding-inline: 22px; }
.time-track { position: absolute; left: 0; bottom: 0; width: 100%; height: 5px; background: var(--paper); }
.time-track span { display: block; height: 100%; width: 100%; background: var(--focus); }
.control-deck { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0 10px; }
.game-actions { flex: 1; }
.game-actions button { margin: 0 6px 5px 0; }
kbd { font: inherit; font-size: 10px; padding: 0 2px; }
#feedback { font: 14px/1.4 system-ui, sans-serif; min-height: 20px; margin: 8px 0 0; color: var(--plum-soft); }
.dpad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 36px); gap: 3px; }
.dpad button { padding: 0; min-height: 36px; font: 18px system-ui, sans-serif; background: var(--lavender); user-select: none; touch-action: none; }
.dpad button[data-direction="up"] { grid-area: 1 / 2; }
.dpad button[data-direction="left"] { grid-area: 2 / 1; }
.dpad button[data-direction="right"] { grid-area: 2 / 3; }
.dpad button[data-direction="down"] { grid-area: 3 / 2; }
.pad-center { grid-area: 2 / 2; display: grid; place-items: center; color: var(--plum-soft); font-size: 22px; }
details { border-top: 2px solid var(--mint-edge); margin-top: 4px; }
summary { cursor: pointer; padding: 14px 0; font-size: 12px; }
.instructions-body { font: 15px/1.6 system-ui, sans-serif; max-width: 72ch; padding: 0 0 10px; }
.instructions-body p { margin-top: 0; }
footer { display: flex; justify-content: space-between; gap: 12px; font: 11px/1.5 system-ui, sans-serif; color: var(--plum-soft); margin-top: 8px; }
a { color: var(--plum); text-underline-offset: 3px; }
.notice { padding: 10px; background: var(--lavender); border: 1px solid var(--plum); font: 13px/1.5 system-ui, sans-serif; }
@media (min-width: 900px) and (max-height: 850px) {
  .game-shell { max-width: 680px; margin-top: 12px; }
  .titlebar { margin-bottom: 12px; }
}
@media (max-width: 540px) {
  .game-shell { width: calc(100% - 16px); margin-top: 12px; }
  .title-lockup { gap: 7px; }
  .title-lockup img { width: 28px; height: 28px; }
  h1 { font-size: 18px; }
  .title-lockup p { font-size: 9px; }
  #sound { font-size: 10px; padding: 6px 8px; }
  .titlebar { margin-bottom: 12px; gap: 5px; }
  .hud { padding: 9px 3px; gap: 1px; }
  .hud output { font-size: 13px; }
  .hud-label { font-size: 9px; }
  .overlay { top: 52%; padding: 12px; }
  .overlay img { display: none; }
  .overlay h2 { font-size: 15px; margin-bottom: 6px; }
  .overlay p { font-size: 12px; margin-bottom: 8px; line-height: 1.5; }
  .overlay .overlay-hint { margin-top: 8px; font-size: 10px; }
  .primary { min-height: 40px; font-size: 12px; }
  .control-deck { gap: 8px; align-items: center; }
  .dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .dpad button { min-height: 44px; }
  .game-actions button { padding-inline: 8px; font-size: 11px; }
  .game-actions kbd { display: none; }
  #feedback { font-size: 12px; }
  footer { flex-wrap: wrap; }
}
@media (max-width: 350px) {
  h1 { font-size: 16px; }
  .title-lockup img { display: none; }
  .game-actions button { margin-right: 2px; padding-inline: 6px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  button:active { transform: none; }
}
