:root {
  --cyan: #35e0ff; --rose: #ff5b8a; --lime: #b6ff4d;
  --ink: #061019; --panel: rgba(10, 22, 32, 0.86);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #060a14;
  font-family: "Segoe UI", system-ui, sans-serif; color: #d9f4ff; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 10px;
  align-items: center; padding: 8px 12px; pointer-events: none;
  background: linear-gradient(#04101ad0, #04101a00); }
.stat { background: var(--panel); border: 1px solid #1e4a52; border-radius: 8px;
  padding: 4px 10px; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat .label { color: #6fd8e8; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; margin-right: 6px; }
#pause-tag { background: #2a1430; border: 1px solid var(--rose); color: #ffd9e4;
  border-radius: 8px; padding: 4px 10px; font-size: 13px; }
#back-link { margin-left: auto; color: var(--cyan); text-decoration: none;
  pointer-events: auto; font-size: 13px; opacity: 0.8; }
#back-link:hover { opacity: 1; }

#bottombar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 12px;
  align-items: center; padding: 10px 12px; background: linear-gradient(#04101a00, #04101ae8); }
#sel-info { background: var(--panel); border: 1px solid #1e4a52; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; min-width: 120px; color: #9fe8ff; }
#build-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
#build-buttons button, #dpad button, #play-start, #restart-link {
  background: linear-gradient(#0d2f3a, #0a2129); color: #d9f4ff;
  border: 1px solid #2a6f78; border-radius: 10px; padding: 10px 14px;
  font-size: 14px; cursor: pointer; touch-action: manipulation; }
#build-buttons button b { color: var(--lime); margin-left: 4px; }
#build-buttons kbd { background: #123; border-radius: 4px; padding: 1px 5px;
  margin-left: 6px; font-size: 11px; color: #6fd8e8; }
#build-buttons button:hover, #dpad button:hover { border-color: var(--cyan);
  box-shadow: 0 0 12px #35e0ff33; }
#build-buttons button.dim { opacity: 0.45; }

#marquee { display: none; position: fixed; border: 1px solid var(--cyan);
  background: #35e0ff1a; pointer-events: none; z-index: 30; }

#dpad { display: none; }
@media (pointer: coarse), (max-width: 760px) {
  #dpad { display: grid; position: fixed; right: 10px; bottom: 70px; gap: 4px;
    grid-template-areas: ". u ." "l m r" ". d ."; justify-items: center; }
  #dpad > button[data-pan="up"] { grid-area: u; }
  #dpad > button[data-pan="down"] { grid-area: d; }
  #dpad > button[data-pan="left"] { grid-area: l; }
  #dpad > button[data-pan="right"] { grid-area: r; }
  #dpad .row { grid-area: 2 / 1 / 3 / 4; display: flex; gap: 42px; align-items: center; }
  #dpad .mid { display: flex; flex-direction: column; gap: 4px; }
  #dpad button { width: 46px; height: 42px; font-size: 16px; opacity: 0.85; }
  #bottombar { flex-direction: column; align-items: stretch; }
  #sel-info { align-self: flex-start; }
}

#toast { position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  background: #2a1430e6; border: 1px solid var(--rose); color: #ffe3ee;
  padding: 8px 16px; border-radius: 10px; opacity: 0; transition: opacity 0.25s;
  font-size: 14px; pointer-events: none; }
#toast.show { opacity: 1; }

#start-overlay, #end-overlay { position: fixed; inset: 0; display: flex;
  align-items: center; justify-content: center; background: #02060cdd; z-index: 40; }
.hidden { display: none !important; }
.panel { max-width: 560px; margin: 16px; padding: 28px 32px; text-align: center;
  background: linear-gradient(#0a1c26, #071118); border: 1px solid #2a6f78;
  border-radius: 18px; box-shadow: 0 0 60px #1cf0c022; }
.panel h1 { margin: 0 0 4px; font-size: 40px; letter-spacing: 0.06em; color: var(--cyan);
  text-shadow: 0 0 24px #35e0ff66; }
.panel h2 { margin: 0 0 8px; font-size: 30px; }
.panel h2.win { color: var(--lime); } .panel h2.lose { color: var(--rose); }
.tag { color: #7fd0c8; margin: 0 0 14px; font-style: italic; }
.howto { text-align: left; font-size: 14px; line-height: 1.55; margin: 0 0 12px;
  padding-left: 20px; color: #bfe6f2; }
.keys { font-size: 12px; color: #6fd8e8; margin: 0 0 18px; }
#play-start, #restart-link { display: inline-block; font-size: 18px; padding: 12px 28px;
  text-decoration: none; background: linear-gradient(#12495a, #0c2f3a);
  border: 1px solid var(--cyan); box-shadow: 0 0 22px #35e0ff44; }
#play-start:hover, #restart-link:hover { background: linear-gradient(#175a6e, #103a48); }
