:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1016;
  color: #edf4fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; min-height: 100vh; overflow: hidden; background: #0b1016; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 3px solid #68e1d5; outline-offset: 3px; }
noscript { position: fixed; inset: 15px; z-index: 8; background: #0b1016; padding: 20px; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.game { position: fixed; inset: 0; overflow: hidden; background: #0a1118; }
#arena { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.game-hud { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); pointer-events: none; }
.hud-top, .hud-bottom, .scoreboard, .touch-controls { pointer-events: auto; }
.hud-top { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 7px; border: 1px solid #30404d; border-radius: 999px; background: #0c141ddd; color: #dceaf5; font-size: 0.73rem; font-weight: 800; letter-spacing: 0.1em; }
.brand-mark { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; background: #68e1d5; color: #091119; font-size: 0.88rem; }
.room-summary { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 11px; border: 1px solid #263846; border-radius: 999px; background: #0c141dcc; color: #afc1d2; font-size: 0.76rem; }
#connection-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#connection-status.error { color: #ff929e; }
.hud-actions { display: flex; gap: 7px; margin-left: auto; }
.icon-button, .quiet-button { border: 1px solid #334552; background: #0c141de8; color: #d8e5ef; }
.icon-button { display: grid; width: 44px; height: 44px; min-width: 44px; min-height: 44px; place-items: center; border-radius: 50%; font-size: 1.05rem; }
.restart-button { color: #8df2e8; font-size: 1.3rem; }
.restart-button:disabled { cursor: not-allowed; opacity: 0.48; }
.icon-button:hover, .quiet-button:hover { border-color: #68e1d5; }
.quiet-button { padding: 7px 10px; border-radius: 999px; font-size: 0.74rem; }
.scoreboard { align-self: flex-start; display: grid; gap: 5px; width: min(225px, 48vw); padding: 8px; margin: 12px 0 0; border: 1px solid #293b48; border-radius: 10px; background: #0b131bd9; list-style: none; }
.scoreboard:empty { display: none; }
.scoreboard li { display: flex; align-items: center; gap: 8px; color: #dae5ee; font-size: 0.76rem; }
.swatch { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 3px; }
.score-label { margin-left: auto; color: #94a9ba; font-variant-numeric: tabular-nums; }
.hud-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #a6b7c5; font-size: 0.75rem; text-shadow: 0 1px 8px #000; }
#control-hint { padding: 8px 11px; border: 1px solid #293b48; border-radius: 999px; background: #0b131bd9; }
#camera-label { padding: 8px 10px; border-radius: 999px; background: #0b131bd9; }
.touch-controls { display: none; align-self: flex-end; align-items: flex-end; justify-content: space-between; gap: 16px; margin: auto 0 12px; }
.direction-pad { display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); gap: 4px; }
.direction-pad button, .power-pad button { border: 1px solid #3d5362; background: #0b151ec9; color: #f0f5f8; touch-action: none; user-select: none; }
.direction-pad button { border-radius: 11px; font-size: 1.15rem; }
.direction-pad button:disabled { cursor: not-allowed; opacity: 0.38; }
.direction-pad button:nth-child(1) { grid-column: 2; grid-row: 1; }
.direction-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.direction-pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
.direction-pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
.power-pad { display: grid; grid-template-columns: repeat(2, 58px); gap: 5px; }
.power-pad button { min-height: 40px; border-radius: 10px; font-size: 0.63rem; font-weight: 800; letter-spacing: 0.06em; }
.power-pad button:active, .direction-pad button:active { background: #274053; }
.overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 18px; background: #050a10a8; backdrop-filter: blur(6px); }
.overlay.hidden { display: none; }
.menu-panel { width: min(100%, 590px); max-height: min(94vh, 920px); overflow: auto; padding: clamp(20px, 4vw, 32px); border: 1px solid #354b5b; border-radius: 18px; background: linear-gradient(150deg, #14212c 0%, #0e161f 78%); box-shadow: 0 28px 100px #000a; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0 0 7px; color: #68e1d5; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.14em; }
h1 { margin: 0; color: #f2f7fb; font-size: clamp(2rem, 8vw, 3.1rem); letter-spacing: -0.06em; line-height: 1; }
h2 { margin: 0; color: #b6c6d4; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.intro { max-width: 460px; margin: 15px 0 22px; color: #a7b9c8; font-size: 0.92rem; line-height: 1.5; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-grid label { display: grid; gap: 6px; color: #9fb2c2; font-size: 0.73rem; }
.field-hint { color: #6f8899; font-size: 0.68rem; }
.settings-grid select, .join-row input { min-width: 0; padding: 10px 11px; border: 1px solid #344957; border-radius: 9px; background: #0c151e; color: #e6eef5; }
.settings-grid select:focus, .join-row input:focus { outline: 2px solid #68e1d580; border-color: #68e1d5; }
.settings-grid .check-setting { display: flex; align-items: center; gap: 9px; min-height: 37px; padding: 7px 9px; border: 1px solid #2d414e; border-radius: 9px; background: #0d1821; color: #c2d0dc; }
.check-setting input { accent-color: #68e1d5; }
.menu-actions { display: grid; gap: 9px; margin-top: 16px; }
.primary-button, .secondary-button { min-height: 42px; padding: 10px 14px; border: 1px solid transparent; border-radius: 9px; font-weight: 800; }
.primary-button { background: #68e1d5; color: #07131a; }
.primary-button:hover { background: #8df2e8; }
.secondary-button { border-color: #3c5260; background: #1a2a36; color: #e3edf3; }
.secondary-button:hover { border-color: #68e1d5; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 0.14em; }
.room-list-block { margin-top: 21px; }
.list-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.text-button { border: 0; background: transparent; color: #74dcd3; font-size: 0.75rem; }
.room-list { display: grid; gap: 6px; max-height: 138px; overflow: auto; }
.room-list button { display: flex; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 1px solid #2e424e; border-radius: 8px; background: #0c151e; color: #dce7ef; text-align: left; }
.room-list button:hover { border-color: #68e1d5; }
.room-list button span:last-child, .muted { color: #91a5b6; font-size: 0.75rem; }
.key-list { margin-top: 18px; padding-top: 14px; border-top: 1px solid #2a3c48; color: #b9c9d5; }
.key-list summary { cursor: pointer; font-size: 0.8rem; font-weight: 750; }
.key-grid { display: grid; gap: 7px; margin-top: 11px; }
.key-grid span { color: #94a7b6; font-size: 0.75rem; line-height: 1.4; }
.key-grid b { display: inline-block; min-width: 92px; color: #e0eaf0; }
.menu-message { min-height: 18px; margin: 12px 0 0; color: #ffb4ba; font-size: 0.79rem; }
.menu-footnote { margin: 5px 0 0; color: #718696; font-size: 0.7rem; line-height: 1.4; }

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: flex; }
  #control-hint { display: none; }
  .hud-bottom { justify-content: flex-end; }
  .scoreboard { width: min(205px, 52vw); }
}

@media (max-width: 520px) {
  .game-hud { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .hud-top { gap: 5px; }
  .brand { gap: 0; padding: 6px; }
  .brand > span:last-child { display: none; }
  .brand-mark { width: 24px; height: 24px; }
  .room-summary { gap: 0; padding: 0; border: 0; background: transparent; font-size: 0.67rem; }
  #connection-status { display: none; }
  #copy-room { flex: 0 0 auto; height: 44px; white-space: nowrap; }
  .icon-button { width: 44px; height: 44px; }
  .settings-grid { grid-template-columns: 1fr; gap: 8px; }
  .menu-panel { padding: 20px 17px; }
  .touch-controls { width: 100%; }
  .direction-pad { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(2, 40px); }
}

@media (max-width: 400px) {
  .scoreboard { margin-top: 48px; }
}
