@font-face { font-family: Laserian; src: url('../fonts/LASER4.TTF') format('truetype'); font-display: swap; }
:root { color-scheme: dark; font-family: 'Courier New', monospace; color: #f5f5f3; background: #080808; --green: #86ff5e; }
* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; min-height: 100svh; padding: 24px; display: flex; align-items: center; justify-content: center; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .24; cursor: default; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
[hidden] { display: none !important; }
#app { width: min(1260px, 100%); }
#app::after { content: ''; display: block; height: 1px; margin-top: 20px; background: #393939; }
#app.menu-open { max-width: 1260px; }
#start-menu { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; min-height: min(640px, calc(100svh - 180px)); padding: 40px 16px; background: #000; }
.menu-logo { width: min(460px, 100%); margin: 0; }
.menu-logo img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; object-fit: cover; }
.menu-actions { display: flex; flex-direction: column; gap: 14px; width: min(260px, 100%); }
.menu-actions .action-button { min-height: 54px; font-size: 18px; }
.menu-actions .secondary { background: #080808; color: #fff; border-color: #777; }
.menu-actions .secondary:hover { border-color: var(--green); color: var(--green); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0 0 20px; gap: 16px; border-bottom: 1px solid #393939; }
.brand, .top-actions { display: flex; align-items: center; gap: 12px; }
.audio-control { position: relative; display: flex; }
.audio-panel { position: absolute; top: calc(100% + 10px); right: 0; z-index: 9500; width: 300px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid #777; border-radius: 4px; background: #141414; box-shadow: 0 12px 32px #000a; }
.audio-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.audio-heading h2 { margin: 0; font-size: 16px; }
.audio-heading .icon-button { width: 30px; height: 30px; flex-basis: 30px; }
.volume-setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; margin-top: 14px; align-items: center; }
.volume-setting label { font-size: 14px; }
.volume-setting output { font-size: 14px; font-variant-numeric: tabular-nums; color: #ddd; }
.volume-setting input { grid-column: 1 / -1; width: 100%; height: 30px; margin: 0; cursor: pointer; accent-color: var(--green); }
.volume-setting input:focus-visible, .mute-setting input:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.mute-setting { display: flex; align-items: center; gap: 10px; padding-top: 14px; margin-top: 12px; border-top: 1px solid #444; cursor: pointer; font-size: 14px; }
.mute-setting input { width: 18px; height: 18px; margin: 0; accent-color: var(--green); cursor: pointer; }
h1 { font-family: Laserian, 'Courier New', monospace; font-size: 34px; font-weight: normal; line-height: 1; margin: 0 0 0 8px; display: flex; align-items: center; gap: 13px; }
.edition { font-size: 10px; color: #909090; margin-right: 18px; }
.icon-button { flex: 0 0 38px; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid transparent; border-radius: 3px; background: transparent; padding: 8px; color: #f5f5f3; text-decoration: none; }
.icon-button:hover:not(:disabled) { background: #252525; border-color: #555; }
svg { width: 19px; height: 19px; flex-shrink: 0; pointer-events: none; }
.game-area { display: grid; grid-template-columns: 116px minmax(0, 1fr) 196px; align-items: stretch; margin-top: 20px; }
.control-rail { min-width: 0; padding-right: 18px; margin-right: 18px; border-right: 1px solid #393939; }
.lives-readout { min-height: 64px; display: flex; flex-direction: column; gap: 9px; }
#lives { display: flex; gap: 6px; }
#lives svg { width: 20px; height: 20px; fill: #fff; }
#lives .spent { fill: none; color: #555; }
.launch-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 88px; padding: 8px 4px; border: 1px solid #fff; border-radius: 3px; background: #fff; color: #000; font-size: 12px; font-weight: bold; }
.launch-button:hover:not(:disabled) { background: var(--green); border-color: var(--green); }
.launch-button svg { width: 24px; height: 24px; }
.history-tools { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }
.history-tools .icon-button { border-color: #393939; }
.field-column { min-width: 0; }
.readout { display: flex; align-items: center; gap: 42px; min-height: 64px; padding: 0 0 17px; }
.readout > div { display: grid; gap: 5px; }
.readout > div:last-child { margin-left: auto; text-align: right; }
.stat-label { font-size: 10px; color: #a1a1a1; }
.readout strong { font-size: 25px; font-weight: 400; font-variant-numeric: tabular-nums; line-height: 1; }
.readout strong span { color: #686868; font-size: 14px; }
#arena { position: relative; width: 100%; aspect-ratio: 3 / 2; border: 1px solid #c9c9c5; background: #000; }
#field { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#pause-label { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-size: 12px; border: 1px solid #777; background: #000e; padding: 8px 16px; pointer-events: none; }
.tray { margin-left: 24px; padding: 64px 0 0 22px; border-left: 1px solid #393939; display: flex; flex-direction: column; min-width: 0; }
#palette { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.piece-tool { min-width: 0; height: 120px; border: 1px solid #383838; border-radius: 4px; background: #131313; display: flex; align-items: center; justify-content: center; padding: 14px 8px 12px; touch-action: none; user-select: none; }
.piece-tool:hover, .piece-tool.active { border-color: #e9e9e9; background: #232323; }
.piece-tool img { width: 80px; height: 70px; max-width: 100%; pointer-events: none; }
.tray-bottom { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; padding-top: 18px; margin-top: auto; }
.tray-tools { display: flex; gap: 6px; }
#result { position: absolute; inset: 0; display: grid; place-items: safe center; overflow: auto; background: #000e; text-align: center; }
.result-content { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 24px; width: min(600px, 100%); }
.result-kicker { color: var(--green); font-size: 14px; }
#result h2 { font-size: 48px; margin: 0; line-height: 1; }
#award { font-size: 40px; font-weight: normal; }
#run-total { display: flex; flex-direction: column; gap: 12px; }
#run-total span { color: #aaa; font-size: 14px; }
#run-score { font-size: 48px; font-weight: normal; }
.score-breakdown { width: min(440px, 100%); margin: 0; display: grid; gap: 18px; }
.score-breakdown > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.score-breakdown dt { color: #ccc; font-size: 20px; text-align: left; }
.score-breakdown dt span { color: #fff; margin-left: 8px; }
.score-breakdown dd { margin: 0; font-size: 24px; font-variant-numeric: tabular-nums; }
#time-penalty, #piece-penalty { color: #ff6262; }
.score-breakdown .score-total { padding-top: 18px; border-top: 1px solid #555; }
.score-total dt { color: #fff; }
.action-button { display: inline-flex; align-items: center; justify-content: center; gap: 20px; min-height: 44px; padding: 10px 20px; background: #f5f5f3; color: #070707; border: 1px solid white; border-radius: 2px; font-size: 12px; font-weight: bold; }
.action-button:hover { background: var(--green); border-color: var(--green); }
#next { width: min(380px, 100%); min-height: 64px; padding: 16px 24px; font-size: 20px; }
#next svg { width: 26px; height: 26px; }
#replay { font-size: 14px; }
.result-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }
.result-links .text-button { font-size: 14px; }
.text-button { border: none; background: none; font-size: 11px; padding: 8px; text-decoration: underline; }
#drag-ghost { position: fixed; pointer-events: none; z-index: 11000; width: 75px; height: 75px; transform: translate(-50%, -50%); }
#drag-ghost img { width: 100%; height: 100%; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#score-screen { background: #000c; }
#score-screen .score-dialog { background: #101010; border-color: #eee; box-shadow: none; }
#score-screen #score-title, #score-screen #score-title.game-over, #score-screen #top10-label { color: #f5f5f3; }
#score-screen .primary { color: #111; background: #fff; border-color: #eee; text-shadow: none; box-shadow: none; }
@media (min-width: 901px) and (max-height: 860px) { #app { max-width: calc((100svh - 276px) * 1.5 + 312px); } }
@media (max-width: 900px) {
  body { padding: 16px; }
  .game-area { grid-template-columns: 88px minmax(0, 1fr) 174px; }
  .control-rail { margin-right: 12px; padding-right: 12px; }
  #lives { gap: 3px; }
  #lives svg { width: 18px; height: 18px; }
  .tray { margin-left: 16px; padding-left: 16px; }
  .piece-tool { height: 96px; padding: 8px; }
  .piece-tool img { width: 64px; height: 54px; }
  .edition { display: none; }
  .readout { gap: 26px; }
}
@media (max-width: 620px) {
  body { padding: 12px; align-items: flex-start; }
  .topbar { padding-bottom: 12px; gap: 6px; }
  h1 { font-size: 25px; margin-left: 0; gap: 7px; }
  .brand { gap: 3px; }
  .top-actions { gap: 0; }
  .audio-panel { right: -34px; }
  .icon-button { flex-basis: 34px; width: 34px; height: 36px; padding: 7px; }
  .game-area { grid-template-columns: 60px minmax(0, 1fr); margin-top: 14px; column-gap: 12px; }
  .control-rail { grid-column: 1; grid-row: 1; margin: 0; padding: 0; border: 0; }
  .field-column { grid-column: 2; grid-row: 1; }
  .lives-readout { min-height: 56px; gap: 7px; }
  .launch-button { height: 80px; font-size: 11px; }
  .readout { min-height: 56px; padding-bottom: 14px; gap: 12px; }
  .readout strong { font-size: 18px; }
  .stat-label { font-size: 9px; }
  .tray { grid-column: 2; margin: 16px 0 0; padding: 16px 0 0; border-left: none; border-top: 1px solid #393939; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  #palette { grid-column: 1; grid-row: 1; gap: 8px; margin-bottom: 0; }
  .piece-tool { height: 88px; padding: 8px; }
  .piece-tool img { width: 58px; height: 49px; }
  .tray-bottom { grid-column: 2; grid-row: 1; margin: 0; padding: 0; align-self: end; flex-direction: column; align-items: flex-end; gap: 5px; }
}
@media (min-width: 621px) and (max-height: 650px) {
  body { padding: 12px; }
  #app { max-width: calc((100svh - 153px) * 1.5 + 262px); }
  .topbar { padding-bottom: 8px; }
  h1 { font-size: 25px; }
  .edition { display: none; }
  .game-area { grid-template-columns: 88px minmax(0, 1fr) 174px; margin-top: 8px; }
  .control-rail { margin-right: 12px; padding-right: 12px; }
  .readout, .lives-readout { min-height: 36px; padding-bottom: 8px; }
  .tray { padding-top: 36px; }
  .lives-readout { gap: 4px; }
  #lives { gap: 3px; }
  #lives svg { width: 16px; height: 16px; }
  .launch-button { height: 66px; font-size: 10px; gap: 6px; }
  .history-tools { gap: 8px; margin-top: 10px; }
  .readout > div { gap: 3px; }
  .readout strong { font-size: 18px; }
  .stat-label { font-size: 8px; }
  .history-tools .icon-button, .tray-bottom .icon-button { width: 30px; height: 30px; flex-basis: 30px; padding: 6px; }
  #palette { gap: 5px; }
  .piece-tool { height: 58px; padding: 4px; }
  .piece-tool img { width: 48px; height: 34px; }
  .tray-bottom { padding-top: 4px; }
}
@media (max-width: 360px) {
  h1 { font-size: 18px; }
  .topbar .icon-button { width: 30px; flex-basis: 30px; padding: 6px; }
}
@media (max-width: 900px), (max-height: 860px) {
  #result { position: fixed; z-index: 9000; padding: 16px; background: #000f; }
}
@media (max-width: 620px) {
  .result-content { gap: 16px; padding: 12px; }
  .result-kicker { font-size: 12px; }
  #result h2 { font-size: 32px; }
  .score-breakdown { gap: 14px; }
  .score-breakdown dt { font-size: 16px; }
  .score-breakdown dd { font-size: 20px; }
  .score-breakdown .score-total { padding-top: 14px; }
  #award { font-size: 32px; }
  #next { min-height: 56px; padding: 12px 16px; font-size: 16px; }
}
@media (min-width: 621px) and (max-height: 500px) {
  .result-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(4, auto); column-gap: 36px; row-gap: 16px; width: min(760px, 100%); padding: 12px; justify-items: center; }
  .result-kicker { grid-column: 1; grid-row: 1; font-size: 12px; }
  #result h2 { grid-column: 1; grid-row: 2; font-size: 32px; }
  .score-breakdown { grid-column: 2; grid-row: 1 / span 4; gap: 14px; }
  #run-total { grid-column: 2; grid-row: 1 / span 4; }
  .score-breakdown dt { font-size: 16px; }
  .score-breakdown dd { font-size: 20px; }
  .score-breakdown .score-total { padding-top: 14px; }
  #award { font-size: 32px; }
  #next { grid-column: 1; grid-row: 3; min-height: 56px; padding: 12px 16px; font-size: 16px; }
  .result-links { grid-column: 1; grid-row: 4; }
  #start-menu { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px 32px; padding: 24px; min-height: calc(100svh - 98px); }
  .menu-logo { grid-column: 1; grid-row: 1; }
  .menu-actions { grid-column: 2; grid-row: 1; }
}
