:root { color-scheme: dark; font-family: system-ui, sans-serif; background: #101f30; color: #edf6ff; }
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 620px; margin: auto; padding: max(10px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 1.65rem; margin: 0; letter-spacing: -.04em; }
h2 { font-size: 1.05rem; margin: 10px 0; }
p { line-height: 1.45; }
#connection { font-size: .75rem; color: #a7d8cc; text-align: right; }
#status { min-height: 1.5em; margin: 8px 0; font-size: .9rem; }
#error { color: #ffc2bf; border: 1px solid #c76b75; border-radius: 8px; padding: 8px; }
button, input { font: inherit; border-radius: 10px; min-height: 46px; }
button { padding: 10px 16px; background: #b2ead7; color: #0b2931; border: 2px solid transparent; font-weight: 650; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, input:focus-visible { outline: 3px solid #ffd16c; outline-offset: 3px; }
button.quiet { background: #1a3448; color: #d2e9f4; border-color: #36536b; font-size: .8rem; min-height: 40px; padding: 7px 12px; }
#home-panel { padding: 18px 0; }
#home-panel > button { width: 100%; }
#join-form { margin: 26px 0; }
label { display: block; margin-bottom: 8px; }
.join-row { display: flex; gap: 8px; }
input { width: 100%; min-width: 0; background: #091725; color: #fff; border: 1px solid #52758e; padding: 10px; text-transform: uppercase; }
.muted, footer { color: #a2bbcd; font-size: .78rem; }
.room-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .85rem; border-top: 1px solid #294658; padding: 6px 0; }
#invite-code { letter-spacing: .08em; color: #ffdb8a; user-select: all; }
#lobby-panel { background: #162d40; padding: 14px; margin: 8px 0; border-radius: 12px; }
#seats { margin: 0 0 12px; }
#ready { width: 100%; }
#countdown { background: #ffdb8a; color: #18283a; padding: 7px; border-radius: 8px; text-align: center; font-weight: 700; }
.fields { display: grid; grid-template-columns: 1.65fr 1fr; gap: 12px; align-items: start; }
.field { min-width: 0; }
.field h2 { display: flex; flex-wrap: wrap; gap: 5px; justify-content: space-between; font-size: .85rem; margin: 7px 0; }
.stat { color: #bed2e0; font-size: .72rem; font-weight: 400; }
.preview { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 30px; margin-bottom: 5px; font-size: .65rem; color: #bbcedd; }
.capsule-preview { display: inline-flex; min-width: 40px; min-height: 22px; align-items: center; }
.color-chip { display: inline-grid; place-items: center; width: 20px; height: 22px; color: #12283a; font-size: 19px; font-weight: 800; line-height: 1; }
.color-chip:first-child { border-radius: 8px 0 0 8px; }
.color-chip:last-child { border-radius: 0 8px 8px 0; }
canvas { display: block; height: auto; border: 2px solid #72b2ad; border-radius: 8px; background: #0a1928; aspect-ratio: 1 / 2; }
.own canvas { width: min(100%, 26svh, calc((100svh - 370px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 2)); }
.opponent canvas { width: min(100%, 15svh); border-color: #56728b; }
#incoming { font-size: .75rem; color: #ffdb8a; margin: 12px 0; overflow-wrap: anywhere; }
.room-actions { display: flex; gap: 6px; flex-shrink: 0; }
#result-panel { padding: 10px 12px; margin: 10px 0; border: 1px solid #78bda9; background: #162f40; border-radius: 10px; }
#result-panel h2 { margin: 0; }
#result-panel p { margin: 6px 0; font-size: .82rem; }
#rematch { width: 100%; }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 10px 0 max(4px, env(safe-area-inset-bottom)); background: #101f30; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.controls button { min-height: 54px; padding: 3px; font-size: 1.5rem; line-height: 1.1; border-color: #527a91; background: #213e54; color: #f2f8ff; touch-action: none; }
.controls button span { display: block; font-size: .62rem; font-weight: 500; }
.controls button[data-pressed="true"] { background: #b2ead7; color: #0b2931; border-color: #f6fff8; }
.key-hint { font-size: .65rem; text-align: center; align-self: center; color: #a2bbcd; margin: 0; }
footer { text-align: center; margin-top: 9px; font-size: .65rem; }
[hidden] { display: none !important; }
@media (min-width: 600px) { main { padding: 20px; } .controls { max-width: 400px; margin: auto; } .own canvas { width: min(100%, 29svh); } .opponent canvas { width: min(100%, 20svh); } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
