:root {
  --bg:#151d18; --panel:#202921; --deep:#151c17; --line:#434e43;
  --text:#efeddf; --muted:#c0c4b2; --accent:#d9bb8c;
  --ink:#25372d; --paper:#eeecdf; --rust:#9d5237; --paper-line:#c3c5b4;
  --sans:"Inter","PingFang SC","Hiragino Sans","Microsoft YaHei",system-ui,sans-serif;
  --display:"Barlow Condensed","Avenir Next Condensed","Arial Narrow","Roboto Condensed",Impact,var(--sans);
  --mono:"IBM Plex Mono","SFMono-Regular",Consolas,monospace;
  font:16px/1.5 var(--sans); color:var(--ink); background:var(--paper); color-scheme:light;
}
*,*::before,*::after { box-sizing:border-box }
body { margin:0; min-height:100vh; font-variant-numeric:tabular-nums }
button,input,select { font:inherit }
button { cursor:pointer; padding:0; color:inherit; -webkit-tap-highlight-color:transparent }
a { color:inherit; text-decoration:none; -webkit-tap-highlight-color:transparent }
button,a,input,select { transition:background .18s ease,border-color .18s ease,color .18s ease,transform .18s ease }
button:disabled { cursor:default; opacity:.42 }
button:active:not(:disabled),a:active { transform:translateY(1px) }
:where(button,a,input,select,canvas):focus-visible { outline:3px solid #b66543; outline-offset:3px }
[hidden] { display:none!important }
h1,h2,h3,p,figure,ul { margin:0 }
.ic { width:1.15em; height:1.15em; display:inline-block; flex:none; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; vertical-align:middle }
.tool,.inline-btn { padding:0; border:0; background:transparent }
.tool { display:grid; place-items:center; width:36px; height:36px; color:var(--muted); border:1px solid var(--line); border-radius:2px }
.tool:hover { color:var(--text); border-color:var(--muted) }
.form-actions { display:flex; align-items:center; gap:10px }
.button { display:inline-flex; align-items:center; justify-content:center; gap:9px; padding:0 20px; min-height:44px; border:1px solid; border-radius:2px; font-size:.95rem; font-weight:700; text-decoration:none }
.button .ic { width:18px; height:18px }
.button.primary { background:var(--accent); border-color:var(--accent); color:var(--button-ink,#20291e) }
.button.primary:hover:not(:disabled) { filter:brightness(1.1) }
.button.subtle { background:transparent; border-color:var(--line); color:var(--text) }
.button.subtle:hover:not(:disabled) { border-color:var(--text) }
.button.small { min-height:36px; padding:0 12px; font-size:.87rem }
dialog { width:min(464px,calc(100% - 32px)); padding:0; color:var(--text); background:var(--panel); border:1px solid #626c56; border-top:3px solid var(--accent); border-radius:5px; box-shadow:0 24px 72px #0009; max-height:90dvh; overflow:auto }
dialog::backdrop { background:#0c110edb; backdrop-filter:blur(4px) }
#dialog-inner { padding:26px }
.dialog-head { display:flex; justify-content:space-between; gap:12px; align-items:center; margin-bottom:20px }
.dialog-head h2 { font-size:1.45rem; font-weight:800 }
.dialog-head .tool { width:28px; height:28px }
.dialog-head .tool .ic { width:15px }
.subtext,.help-note { color:var(--muted); font-size:.9rem; line-height:1.7 }
label.field { display:grid; gap:7px; margin:14px 0; font-size:.88rem; font-weight:600 }
input,select { width:100%; min-width:0; border:1px solid #57614e; border-radius:3px; background:var(--deep); color:var(--text); padding:10px 12px; min-height:43px }
input::placeholder { color:#878d7e } input.code { font:1.2rem/1 var(--mono); letter-spacing:.2em; text-transform:uppercase }
input:hover:not(:disabled),select:hover:not(:disabled) { border-color:#8c987d }
select { appearance:none; padding-right:34px; background-image:linear-gradient(45deg,transparent 50%,#a9b299 50%),linear-gradient(135deg,#a9b299 50%,transparent 50%); background-position:calc(100% - 17px) 52%,calc(100% - 12px) 52%; background-size:5px 5px; background-repeat:no-repeat }
.form-actions { margin-top:20px; flex-wrap:wrap }
.form-actions .primary { flex:1 }
.form-error { color:#ffc08e; font-size:.88rem; margin-top:11px; min-height:0 }
.form-error:empty { margin:0 }
.room-code { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:3px 0 8px; margin-bottom:15px; border-bottom:1px solid var(--line) }
.room-code small,.muted { color:var(--muted); font-size:.82rem }
.room-code strong { display:block; color:var(--accent); font:bold 1.8rem/1.2 var(--mono); letter-spacing:.14em }
.room-info { display:flex; justify-content:space-between; gap:12px; color:var(--muted); font-size:.86rem; margin-bottom:9px }
.room-info>span:last-child { flex:none; white-space:nowrap }
.seat { display:flex; align-items:center; gap:9px; padding:7px 0; border-top:1px solid var(--line); font-size:.93rem }
.p-tag { color:var(--p); border:1px solid color-mix(in srgb,var(--p) 55%,transparent); border-radius:2px; padding:1px 4px; font:bold .73rem/1.35 var(--mono); white-space:nowrap }
.seat small { margin-left:auto; color:var(--muted) }
.seat strong { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
.seat .ready { color:#bad69a }
.help-table { width:100%; border-collapse:collapse; margin:12px 0; font-size:.88rem }
.help-table th,.help-table td { padding:9px 4px; text-align:left; border-bottom:1px solid var(--line) }
.help-table th { color:var(--muted); font-weight:500 }.help-table td { font-weight:600 }
.help-section { margin-top:17px; font-size:1rem; color:#e3c084 }
kbd { color:#e3e5d3; background:#30382e; border:1px solid #4b5546; border-radius:3px; padding:1px 5px; font: .8rem/1.5 var(--mono) }
.toast { position:fixed; z-index:20; left:50%; transform:translateX(-50%); bottom:22px; width:max-content; max-width:90%; border:1px solid #70765d; border-radius:3px; background:#2a3228; color:#f5ebcc; box-shadow:0 4px 25px #0005; padding:10px 17px; font-size:.9rem }
.time-preview { display:grid; gap:4px; padding:12px; border:1px solid var(--line); border-radius:3px; background:var(--deep); font-size:.83rem; color:var(--muted) }
.time-preview output { color:var(--text); font: .95rem var(--mono) }

dialog {
  --panel:#112019b8; --text:#f5f0df; --muted:#d3d8c8; --deep:#17271da3;
  --line:#abb69c70; --accent:#ead09e; --button-ink:#18241c;
  border:1px solid #b4bda274; border-top:2px solid #d8bd88c9; border-radius:2px;
  backdrop-filter:blur(9px); box-shadow:0 18px 65px #07120d48; color-scheme:dark;
}
dialog::backdrop { background:#0d18113b; backdrop-filter:blur(2px) }
dialog .time-preview { background:#283c2c69; border-color:var(--line) }
.room-code>div { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 10px }
.copy-invite { flex:none }
dialog .room-code strong,dialog .help-section { color:var(--accent) }
dialog select option { background:#24332a; color:var(--text) }
dialog input:hover,dialog select:hover { border-color:#bbbda4 }
dialog .button.primary { background:#6d5e3c7d; color:#fff0cc; border-color:#dec38f }
dialog .button.primary:hover:not(:disabled) { background:#806c43ab }
dialog .dialog-head h2 { line-height:1.2; letter-spacing:-.03em }
dialog .seat .ready { color:#c7dfa9 }.dialog-head .tool { flex:none }
@media(max-height:620px) {
  #dialog-inner { padding:16px 20px }.dialog-head { margin-bottom:12px }
  dialog label.field { margin-block:8px; gap:3px }dialog .form-actions { margin-top:12px }
  dialog .seat { padding-block:3px }dialog .room-code { margin-bottom:8px }
  dialog[data-view=room] .form-actions { display:grid; grid-template-columns:auto minmax(0,1fr); gap:7px }
  dialog[data-view=room] .form-actions .button { min-height:38px; padding-inline:8px }
}
@media(max-height:540px) and (min-aspect-ratio:6/5) {
  dialog:is([data-view=create],[data-view=join],[data-view=room]) { width:min(630px,calc(100% - 28px)); max-height:calc(100dvh - 16px) }
  #room-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:end; column-gap:12px }
  dialog[data-view=create] #room-form { grid-template-columns:repeat(3,minmax(0,1fr)) }
  #room-form .form-error,#room-form .form-actions { grid-column:1/-1 }
  .room-seats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 18px }
  dialog[data-view=room] #dialog-inner { padding:10px 16px }
  dialog[data-view=room] .dialog-head,dialog[data-view=room] .room-info { margin-bottom:5px }
  dialog[data-view=room] .room-code { padding:1px 0 4px; margin-bottom:4px }
  dialog[data-view=room] .room-code strong { font-size:1.45rem }
  dialog[data-view=room] .form-actions { margin-top:6px }
  .room-seats .seat { line-height:1.28; padding-block:2px }
}
body.in-match { color:var(--text); color-scheme:dark }
body.in-match { overflow:hidden }
.in-match .topbar { display:none }
.in-match .shell { width:100%; max-width:none; margin:0; padding:0 }
#battle { position:fixed; inset:0; isolation:isolate; overflow:hidden; background:#64715b; animation:scene-in .2s ease-out }
#arena { width:100%; height:100%; display:block; touch-action:none; cursor:crosshair; outline:none }
.battle-vignette,#danger-edge { position:absolute; inset:0; pointer-events:none }
.battle-vignette { background:linear-gradient(180deg,#242d2736,transparent 15%,transparent 86%,#222a2438) }
#danger-edge { opacity:0; box-shadow:inset 0 0 min(5vw,49px) 2px #c5b17f65; transition:opacity .19s ease-out,box-shadow .19s ease-out }
#danger-edge.notice { opacity:.58 }
#danger-edge.alert { opacity:1; box-shadow:inset 0 0 min(6vw,56px) 3px #a65d4673 }
.field-header { position:absolute; inset:max(14px,env(safe-area-inset-top)) 19px auto; display:flex; align-items:flex-start; gap:14px; pointer-events:none }
.field-identity,.field-status,.field-tools,.field-loadout,.classic-card,.field-roster,.field-keys,.phase-banner { background:#17271fc2; color:#edeadd; border:0; border-radius:3px; backdrop-filter:blur(6px); box-shadow:0 2px 7px #26302519 }
.field-identity { display:flex; gap:10px; align-items:center; padding:8px 12px }
.field-identity i { height:23px; width:3px; background:var(--accent) }
.field-identity small { display:block; color:#cbcdbb; font-size:.67rem; line-height:1.25; letter-spacing:.065em }
.field-identity h1 { line-height:1.28; font-size:1.02rem; font-weight:650 }
.field-status,.field-tools { display:flex; align-items:center; min-height:35px; pointer-events:auto }
.field-status { margin-left:auto }.field-tools { gap:1px }
#timer { display:flex; align-items:center; gap:6px; height:25px; border-right:1px solid #8f958052; padding:0 10px; font: .98rem var(--mono) }
#timer .ic { width:14px; color:#dacaab }
.hud-tool { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:0 10px; min-width:34px; min-height:35px; background:transparent; border:0; border-radius:3px; color:#e8e7d8 }
.hud-tool:hover,.hud-tool[aria-expanded=true] { background:#68745c80; color:#fff1cc }
.hud-tool:active { background:#77846c90 }.hud-tool .ic { width:17px;height:17px }
#alive { font:.76rem var(--mono) }
.field-roster { position:absolute; right:20px; top:65px; padding:14px 16px; min-width:min(225px,90%); animation:panel-in .18s ease-out }
.field-roster h2 { font-size:.93rem; margin-bottom:7px }
.roster-row { padding:6px 0; font-size:.84rem }.roster-row.out { opacity:.62 }
.roster-label { display:flex; align-items:center; gap:7px }.roster-label strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
.roster-label small { margin-left:auto; color:#d3d5c6; font:.72rem var(--mono) }
.hp { display:block; height:3px; background:#9ba18b33; margin:4px 0 0 }.hp i { display:block; height:100%; background:var(--p) }
.phase-banner { pointer-events:none; position:absolute; top:75px; left:50%; transform:translateX(-50%); max-width:min(92%,430px); width:max-content; padding:6px 13px; text-align:center; font-size:.82rem; animation:scene-in .18s ease-out }
.phase-banner b { margin-right:8px; font-family:var(--mono); color:#f1d9ad }.phase-banner small { color:#f1edda; font-size:.81rem }
.field-loadout,.classic-hud { position:absolute; bottom:max(18px,env(safe-area-inset-bottom)); pointer-events:none }
.field-loadout { left:19px; padding:8px 12px; max-width:46%; font-size:.82rem }
.field-loadout strong,.classic-card strong { color:var(--p); margin-right:8px; font-family:var(--mono) }
.field-loadout small,.classic-card small { color:#cbd0be; font-size:.73rem }
.ammo { font-family:var(--mono) }.ammo[data-empty=true] { color:#e9ac92 }
.field-loadout .life-line,.classic-card .life-line { height:2px; margin-top:5px; background:#a3a89540 }
.life-line i { display:block; height:100%; background:var(--p); transition:width .17s ease-out }
.classic-hud { left:19px; right:19px; display:flex; justify-content:space-between; gap:12px }
.classic-card { padding:7px 11px; font-size:.85rem; min-width:100px }
.field-keys { position:absolute; right:19px; bottom:18px; font-size:.74rem; line-height:1.5; padding:5px 9px; pointer-events:none; max-width:48%; color:#d8dbca }
#battle.is-duel .field-keys { left:50%; right:auto; bottom:20px; transform:translateX(-50%); width:max-content; max-width:45%; text-align:center }
.result { position:absolute; z-index:2; top:50%; left:50%; transform:translate(-50%,-50%); border:0; color:var(--text); border-radius:4px; background:#17261fce; backdrop-filter:blur(12px); box-shadow:0 12px 45px #26312438; padding:22px 26px; text-align:center; width:max-content; min-width:min(300px,90%); max-width:92%; animation:scene-in .2s ease-out }
.result h2 { display:block; margin:5px 0; font-size:1.5rem }.result>.ic { width:24px; height:24px; color:var(--accent) }.result time { display:block; margin-top:5px }.result .form-actions { justify-content:center; margin-top:15px }
.inline-btn { color:var(--accent); font-size:.87rem }
.inline-btn:hover { color:#edcfaa; text-decoration:underline }
.touch-controls { position:absolute; bottom:max(12px,env(safe-area-inset-bottom)); left:14px; right:14px; display:flex; justify-content:space-between; pointer-events:none; touch-action:none; user-select:none }
.dpad { display:grid; grid-template-columns:repeat(3,41px); gap:2px }.dpad button:first-child { grid-column:2 }.dpad button:nth-child(2) { grid-column:1 }
.touch-controls button { pointer-events:auto; touch-action:none; background:#263128bb; border:1px solid #a4af9860; border-radius:4px; color:#eee9d6; min-height:38px }
.touch-controls button:active { background:#5d6955e0 }.touch-actions { display:flex; align-items:flex-end; gap:6px }.touch-actions button { padding:0 12px }
.duel-pads {
  position:absolute; inset:auto max(10px,env(safe-area-inset-right)) max(9px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  display:flex; align-items:end; justify-content:space-between; pointer-events:none; touch-action:none; user-select:none;
}
.duel-pad { display:flex; align-items:center; gap:clamp(3px,1vw,9px) }
.duel-pad:last-child { flex-direction:row-reverse }
.duel-pad button { display:grid; place-items:center; padding:0; pointer-events:auto; touch-action:none; border:1px solid #d5dec078; border-radius:50%; background:#1d3026b8; color:var(--p) }
.duel-pad .duel-stick { width:clamp(55px,11vmin,76px); aspect-ratio:1; background:radial-gradient(circle,#405044ab 34%,#26392dbe 36%); border-color:var(--p) }
.duel-stick span { display:block; pointer-events:none; width:43%; aspect-ratio:1; border:1px solid var(--p); border-radius:50%; background:#586650; transform:translate(var(--stick-x,0px),var(--stick-y,0px)) }
.duel-pad [data-pad-action] { width:clamp(36px,7vmin,48px); aspect-ratio:1 }
.duel-pad [data-pad-action=drop] { color:#e0e2d1 }
.duel-pad button:active,.duel-pad button.held { background-color:#596954; border-color:var(--p) }
#battle.has-duel-pads .classic-hud { left:max(12px,env(safe-area-inset-left)); right:max(12px,env(safe-area-inset-right)); bottom:calc(max(9px,env(safe-area-inset-bottom)) + clamp(55px,11vmin,76px) + 6px) }
#battle.has-duel-pads .classic-card { min-width:0; padding:4px 8px; line-height:1.15 }
@media(min-width:640px) and (max-height:540px) {
  #battle.has-duel-pads .duel-pad { gap:4px }
  #battle.has-duel-pads .classic-hud { bottom:max(12px,env(safe-area-inset-bottom)); left:calc(max(10px,env(safe-area-inset-left)) + 149px); right:calc(max(10px,env(safe-area-inset-right)) + 149px) }
  #battle.has-duel-pads .classic-card { max-width:calc(50% - 6px); overflow-wrap:anywhere }
}
dialog[open] { animation:panel-in .18s ease-out }
@supports (transition-behavior:allow-discrete) {
  dialog { opacity:0; transition:opacity .18s ease,overlay .18s allow-discrete,display .18s allow-discrete }
  dialog[open] { opacity:1 }
  dialog::backdrop { opacity:0; transition:opacity .18s ease,overlay .18s allow-discrete,display .18s allow-discrete }
  dialog[open]::backdrop { opacity:1 }
  @starting-style { dialog[open]::backdrop { opacity:0 } }
}
@keyframes scene-in { from{opacity:0}to{opacity:1} }
@keyframes panel-in { from{opacity:0;translate:0 4px}to{opacity:1;translate:0 0} }
#battle.has-touch-pad .field-loadout { bottom:calc(max(12px,env(safe-area-inset-bottom)) + 88px) }
#battle.has-touch-pad .field-keys,#battle.has-duel-pads .field-keys { display:none }
@media(max-width:680px) { .field-header { inset:9px 9px auto; gap:5px }.field-identity { padding:5px 7px;gap:5px }.field-identity h1 { font-size:.85rem }.field-identity small { font-size:.6rem }.hud-tool { min-width:31px;padding:0 6px }.field-tools,.field-status { min-height:32px }#timer { padding:0 5px;font-size:.78rem }#alive { font-size:.66rem }.field-keys { display:none }.phase-banner { top:58px }.field-roster { right:9px; top:51px }.classic-card { min-width:80px }.result .form-actions { flex-wrap:wrap }.field-status .ic { width:13px } }
@media(prefers-reduced-motion:reduce) { *,*::after,*::before { animation-duration:.01ms!important; transition-duration:.01ms!important } }
