* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #14181c; color: #e6edf3; font: 16px/1.45 system-ui, sans-serif; display: flex; justify-content: center; }
[hidden] { display: none !important; }
h1 { margin: 0 0 4px; font-size: 34px; }
h2 { margin: 18px 0 8px; font-size: 20px; }
.lead { margin: 0 0 18px; opacity: .8; }
.panel { background: #1d242b; border: 1px solid #323c46; border-radius: 12px; padding: 24px 28px; }
#start { width: min(520px, calc(100vw - 24px)); margin-top: 6vh; align-self: flex-start; }
form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
form label { grid-column: 1 / -1; font-size: 14px; opacity: .8; }
input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid #3a444e; background: #12171b; color: inherit; }
button { font: inherit; padding: 10px 18px; border-radius: 8px; border: 0; background: #ffd23f; color: #1a1a1a; font-weight: 600; cursor: pointer; }
.error { grid-column: 1 / -1; margin: 4px 0 0; min-height: 1.4em; color: #ff8a8a; font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #2c353e; }
th { font-size: 12px; text-transform: uppercase; opacity: .6; }
tr.mine td { background: rgba(255, 210, 63, .18); font-weight: 600; }
tr.outside td { border-top: 2px dashed #3a444e; }
.muted { opacity: .6; }
#play { display: flex; flex-direction: column; align-items: center; width: 100%; padding: 8px; }
#hud { display: flex; gap: 32px; font-size: 22px; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
#hud-title { color: #ffd23f; font-weight: 700; }
#stage { position: relative; width: 100%; max-width: 1264px; }
canvas { display: block; width: 100%; height: auto; border-radius: 8px; }
#end { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, 94%); max-height: 96%; overflow: auto; background: rgba(20, 26, 31, .96); }
#end h2 { margin-top: 0; font-size: 28px; }
#end p { margin: 6px 0; }
#dpad { display: none; position: relative; width: 168px; height: 168px; margin: 16px 0 calc(16px + env(safe-area-inset-bottom)); border-radius: 50%; background: rgba(255, 255, 255, .08); border: 1px solid #3a444e; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#dpad span { position: absolute; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #e6edf3; opacity: .7; border-radius: 12px; pointer-events: none; }
#dpad span.active { background: #ffd23f; color: #1a1a1a; opacity: 1; }
#dpad [data-key="ArrowUp"] { left: 56px; top: 8px; }
#dpad [data-key="ArrowDown"] { left: 56px; bottom: 8px; }
#dpad [data-key="ArrowLeft"] { left: 8px; top: 56px; }
#dpad [data-key="ArrowRight"] { right: 8px; top: 56px; }
@media (pointer: coarse) {
  #dpad:not([hidden]) { display: block; }
  #play { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
  #hud { gap: 14px; font-size: 16px; flex-wrap: wrap; justify-content: center; }
}
@media (pointer: coarse) and (orientation: landscape) {
  #dpad { position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: 8px; margin: 0; opacity: .75; }
}
