:root {
  color-scheme: light;
  --paper: #f6efdf;
  --sheet: #fffaf0;
  --ink: #192e32;
  --muted: #526367;
  --line: #c7c1b2;
  --teal: #0d685f;
  --gold: #f4b747;
  --red: #a13925;
  --display: "Arial Black", "Avenir Next", "Hiragino Kaku Gothic ProN", sans-serif;
  font: 15px/1.5 Inter, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0 }
button, input { font: inherit; color: inherit }
button, summary { cursor: pointer; -webkit-tap-highlight-color: transparent }
button { touch-action: manipulation }
button:disabled { cursor: not-allowed }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid #137bca; outline-offset: 3px; z-index: 1;
}
h1,h2,h3,p,dl,dd { margin: 0 }
a { color: inherit; text-decoration: none }
button, input { border-radius: 3px }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
.button, .join-row button {
  border: 1.5px solid var(--ink); background: var(--sheet); padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 14px; font-weight: 750;
}
.button.primary,.button-gold { background: var(--gold); box-shadow: 2px 3px var(--ink) }
.button.primary, .button.secondary { min-height: 51px }
.button.primary b { font-size: 21px; line-height: 1 }
.button:active:enabled,.join-row button:active:enabled { transform: translateY(1px); box-shadow: none }
.button:disabled { color: #636b65; border-color: #b6b6a9; background: #e2e1d5; box-shadow: none }
@media (hover:hover) {
  .button:hover:enabled, .join-row button:hover { background: #e0ebdd }
  .button.primary:hover, .button-gold:hover:enabled { background: #ffca69 }
  .text-button:hover { text-decoration: underline; text-underline-offset: 4px }
}
.text-button { background: none; border: 0; min-height: 44px; padding: 6px 12px; font-weight: 650 }
.wordmark { display: inline-flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 950; font-style: italic; letter-spacing: -.05em; white-space: nowrap }
.stack-mark { display: inline-block; flex: none; width: 29px; height: 29px; background: currentColor; clip-path: polygon(20% 4%,100% 4%,84% 27%,4% 27%,20% 4%,20% 38%,100% 38%,84% 61%,4% 61%,20% 38%,20% 72%,100% 72%,84% 96%,4% 96%,20% 72%) }
.home-screen { max-width: 1600px; margin: auto; padding: 0 clamp(14px,4vw,70px) 48px }
.home-nav { min-height: 70px; display: flex; align-items: center; justify-content: space-between }
.nav-right { display: flex; gap: 12px }
.hero {
  display: grid; grid-template-columns: 44% minmax(0,1fr); position: relative; isolation: isolate;
  border: 2px solid var(--ink); background: #fbf3df; box-shadow: 5px 6px var(--ink);
}
.hero-copy { min-width: 0; grid-area: 1/1; padding: clamp(25px,3.6vw,65px); align-self: center; position: relative }
.hero-art { grid-area: 1/2; overflow: hidden; min-width: 0; position: relative; border-left: 2px solid var(--ink); background: #277b80 }
.hero-art img { display: block; width: 100%; height: 100%; position: absolute; object-fit: cover; object-position: 52% 51% }
.genre { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 800; letter-spacing: .09em; color: var(--teal) }
.genre span { width: 29px; height: 5px; background: var(--teal); transform: skew(-15deg) }
.hero h1 { font-family: var(--display); font-size: clamp(64px,6.6vw,112px); line-height: .85; letter-spacing: -.073em; font-weight: 1000; font-style: italic; margin: 23px 0 24px; white-space: nowrap }
.hero h1 em { color: #b64127; font-size: .82em }
.hero h2 { font-size: clamp(18px,1.55vw,25px); letter-spacing: .02em; line-height: 1.45 }
.intro { color: var(--muted); max-width: 32em; margin: 8px 0 23px; font-size: 14px; line-height: 1.8 }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px }
.join-row { display: flex; max-width: 380px; border-top: 1px dashed var(--line); margin-top: 20px; padding-top: 14px; gap: 6px }
.join-row input { min-width: 0; width: 100%; border: 1px solid var(--line); background: var(--sheet); padding: 8px 12px; font-size: 16px; text-transform: uppercase }
.join-row button { flex: none; font-size: 13px; padding: 8px 12px; background: transparent }
.home-status:not(:empty) { margin-top: 8px; color: var(--teal); font-weight: 650; font-size: 13px }
.roster { margin-top: clamp(32px,4vw,68px) }
.roster header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 14px }
.roster h2,.station-heading h2 { font-size: clamp(20px,2vw,30px); letter-spacing: -.04em }
.roster header p { color: var(--muted); font-size: 13px }
.roster-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; align-items: start }
.roster-entry { border: 1.5px solid var(--ink); background: var(--sheet) }
.roster-entry summary { display: grid; grid-template-columns: 40% 1fr; align-items: center; position: relative; list-style: none; min-height: 85px }
.roster-entry summary::-webkit-details-marker { display: none }
.roster-entry summary::after { content: '+'; position: absolute; right: 8px; top: 1px; color: var(--muted); font-size: 18px }
.roster-entry[open] summary::after { content: '−' }
.roster-entry img { width: 100%; height: 100%; max-height: 123px; object-fit: cover; object-position: center 25%; border-right: 1px solid var(--ink) }
.roster-entry summary span { padding: 12px }
.roster-entry strong,.roster-entry small { display: block }
.roster-entry strong { font-size: 18px }
.roster-entry small { color: var(--muted); font-size: 12px }
.roster-entry p { padding: 12px; border-top: 1px solid var(--line); font-size: 13px }
.game-screen { max-width: 1780px; margin: auto; padding: 0 clamp(12px,2.6vw,48px) 24px }
.game-header { min-height: 56px; display: flex; gap: 14px; align-items: center; border-bottom: 2px solid var(--ink); margin-bottom: 15px }
.game-header #mode-label,.connection { font-size: 12px; color: var(--muted) }
.connection,.header-actions { display: flex; align-items: center; gap: 5px }
.connection { margin-left: auto }
.live-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--teal) }
.battle-layout { display: grid; grid-template-columns: minmax(0,1fr) clamp(292px,25%,400px); gap: 12px 18px; align-items: start }
.arena-column { min-width: 0 }
.scoreboard { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: clamp(10px,2vw,28px); padding: 0 0 12px }
.score-label,.score-label>span,.economy,.core-row { display: flex; align-items: center; gap: 6px }
.score-label { justify-content: space-between; font-size: 13px }
.score-label small,.economy,.loadout-row { font-size: 11px }
.team-mark { width: 8px; height: 8px; transform: rotate(45deg); background: var(--teal) }
.enemy .team-mark,.enemy .hp-track span { background: var(--red) }
.core-row strong,.wallet,.match-clock strong,.economy b { font-variant-numeric: tabular-nums }
.core-row strong { font-size: 17px }
.hp-track,.progress-track { height: 9px; flex: 1; background: #dad5c5; overflow: hidden }
.hp-track span,.progress-track span { height: 100%; background: var(--teal); display: block }
.economy b { font-size: 14px }
.economy small,.loadout-row { color: var(--muted) }
.match-clock { display: grid; align-content: center; justify-items: center }
.match-clock span { color: var(--muted); font-size: 10px }
.match-clock strong { font-family: var(--display); font-size: clamp(20px,2vw,30px); letter-spacing: -.045em }
.arena-wrap { border: 2px solid var(--ink); background: #21383a; color: var(--sheet); position: relative; overflow: hidden }
.arena-topline,.arena-bottomline { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; gap: 8px; font-size: 12px }
.arena-topline h2 { display: flex; align-items: center; gap: 8px; font-size: 14px }
.arena-dot { width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg) }
#field-forces { margin-left: auto; font-size: 11px }
#blast-alert { position: absolute; z-index: 1; left: 50%; top: 36px; transform: translateX(-50%); width: max-content; max-width: 95%; background: #842e1f; color: white; padding: 6px 12px; border: 1px solid #ffe3aa; font-size: 13px; font-weight: 750 }
#battle-detail { font-size: 11px; color: #d5e4d9 }
#battle-canvas { touch-action: pan-y pinch-zoom; display: block; width: 100%; aspect-ratio: 1400 / 680 }
#battle-canvas.hand-mode { touch-action: none }
.arena-bottomline { color: #f8e9be; min-height: 32px; border-top: 1px solid #59706a }
.countdown { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #173034a8; font-weight: 750 }
.countdown strong { color: var(--gold); font: italic 950 76px/1 var(--display) }
.command-station { grid-column: 2; grid-row: 1/3; border: 2px solid var(--ink); background: var(--sheet); box-shadow: 3px 4px var(--ink); min-width: 0 }
.station-heading { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--ink); color: var(--sheet) }
.station-heading h2 { font-size: 18px }
.wallet { color: var(--gold); font-size: 12px }
.wallet b { font-size: 20px }
.command-deck { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; padding: 12px 10px }
.build-card { min-width: 0; position: relative; overflow: hidden; padding: 0; border: 1.5px solid var(--ink); background: var(--paper); text-align: left }
.build-card img { width: 100%; height: clamp(52px,5vw,82px); display: block; object-fit: cover; object-position: center 26% }
.build-card strong,.card-cost { display: block; padding: 0 6px }
.build-card strong { padding-top: 4px; font-size: 14px }
.card-cost { font-size: 12px; font-weight: 700; padding-bottom: 4px }
.build-card.selected { outline: 3px solid var(--teal); outline-offset: -2px; background: #dcf1e4 }
.build-card.selected::after { content: '✓'; position: absolute; right: 0; top: 0; background: var(--teal); color: white; padding: 1px 5px }
.build-card:disabled img { filter: saturate(.35); opacity: .65 }
.build-card:disabled .card-cost { color: var(--muted) }
.field-controls,.orders { border-top: 1px solid var(--line); padding: 10px 12px }
.command-station h3 { font-size: 13px; letter-spacing: .035em; margin-bottom: 6px }
.stack-floors { display: flex; overflow-x: auto; gap: 6px; padding: 3px; margin: -3px; scrollbar-width: thin }
.stack-floors:not(:empty) { margin-bottom: 6px }
.stack-floors .button { flex: none; gap: 4px; padding: 5px 9px; font-size: 12px }
.stack-floors small { font-size: 10px }
.button[aria-pressed="true"] { background: var(--teal); color: white; border-color: var(--teal) }
#quick-build { width: 100%; margin: 3px 0 }
#stack-selected { font-weight: 750; font-size: 13px }
.stack-action-buttons { display: grid; grid-template-columns: 1fr auto auto; gap: 5px; margin: 5px 0 }
.stack-action-buttons .button,.orders .button { font-size: 12px; padding: 6px 9px }
#upgrade-odds,#hand-status { color: var(--muted); font-size: 11px }
.all-commands,.field-control-heading { display: flex; gap: 7px; align-items: center }
.all-commands .button { flex: 1 }
.field-control-heading { margin-top: 8px }
.game-notice:not(:empty) { background: #e2ebdf; color: #254b42; font-size: 12px; padding: 8px 12px; border-top: 1px solid var(--line) }
.game-notice.error { color: var(--red); background: #f9e4d4 }
.inspector { grid-column: 1; border: 1px solid var(--line); background: var(--sheet); min-width: 0 }
.inspector summary { padding: 12px; min-height: 44px; font-size: 13px; font-weight: 750 }
#inspector-content { padding: 0 14px 14px; font-size: 13px }
.inspect-heading { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--teal) }
.level-badge { font-weight: 800 }
#inspect-name { font-size: 19px; margin: 3px 0 }
.inspect-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px 16px; margin: 8px 0 }
.inspect-stats > div,.production > div:first-child { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px solid var(--line); padding: 3px 0 }
.inspect-stats dt { color: var(--muted) }
.inspect-stats dd { text-align: right; font-weight: 650 }
.production { margin: 6px 0 }
.warning,.blast-note { color: var(--red) }
.upgrade-slot { display: flex; align-items: center; gap: 8px; background: var(--ink); color: white; padding: 8px; font-weight: 700; font-size: 12px; margin-bottom: 5px }
.slot-reels { display: flex; gap: 3px }
.slot-window { height: 26px; width: 24px; line-height: 26px; display: block; overflow: hidden; background: var(--sheet); color: var(--ink); text-align: center }
.slot-strip { display: none }
.upgrade-slot[data-outcome="rolling"] .slot-strip { display: block; animation: roll .24s linear infinite }
.upgrade-slot[data-outcome="rolling"] .slot-window:nth-child(2) .slot-strip { animation-duration: .28s }
.upgrade-slot[data-outcome="rolling"] .slot-window:nth-child(3) .slot-strip { animation-duration: .32s }
.upgrade-slot[data-outcome="rolling"] .slot-symbol { display: none }
.upgrade-slot[data-outcome="success"] .slot-window { background: var(--gold) }
.upgrade-slot.reduced-motion .slot-strip { animation: none }
@keyframes roll { to { transform: translateY(-78px) } }
.modal-overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: #152a30bb; backdrop-filter: blur(4px) }
body:has(.modal-overlay:not([hidden])) { overflow: hidden }
.modal { width: min(100%,460px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain; background: var(--sheet); border: 2px solid var(--ink); box-shadow: 5px 6px var(--ink); padding: clamp(20px,3vw,36px); position: relative }
.modal h2 { font-size: clamp(23px,3vw,34px); letter-spacing: -.05em; margin: 0 26px 8px 0 }
.modal p,.lobby-note { font-size: 13px; color: var(--muted) }
.modal-close { position: absolute; background: transparent; border: 0; right: 4px; top: 4px; width: 44px; height: 44px; font-size: 25px }
.modal .button { width: 100%; margin-top: 10px }
.eyebrow,.room-code-label { font-size: 10px; letter-spacing: .12em; font-weight: 800; color: var(--teal); margin-bottom: 5px }
.loadout-modal { width: min(100%,850px) }
.loadout-cards { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin: 18px 0 12px }
.loadout-card { display: flex; flex-direction: column; align-items: stretch; overflow: hidden; text-align: left; padding: 0 0 9px; border: 1.5px solid #9a9d91; background: var(--paper); min-width: 0 }
.loadout-card.selected { border-color: var(--teal); box-shadow: inset 0 -3px var(--teal) }
.loadout-card.replacement { outline: 3px dashed #a15119; outline-offset: 1px }
.loadout-portrait { position: relative }
.loadout-portrait img { width: 100%; height: auto; aspect-ratio: 1.25; object-fit: cover; object-position: center 30%; display: block }
.loadout-check { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; font-size: 13px; font-weight: 900; min-width: 24px; height: 24px; border: 1px solid var(--ink); background: var(--sheet) }
.selected .loadout-check { background: var(--teal); color: white }
.loadout-card>strong,.loadout-card>small,.loadout-blast { margin: 6px 9px 0 }
.loadout-card>strong { font-size: 16px }
.loadout-card>strong b { font-size: 11px; float: right; margin-top: 4px }
.loadout-card>small,.loadout-blast { font-size: 12px }
.loadout-blast { color: var(--muted) }
.loadout-summary { color: var(--teal); font-weight: 800 }
#loadout-status { min-height: 20px }
.room-code-label { margin-top: 20px }
.room-code { display: block; font: 850 37px/1.3 var(--display); letter-spacing: .12em }
.waiting-label,.lobby-note { display: block; margin-top: 10px }
.waiting-label span { margin-right: 6px }
.result-modal { border-top: 9px solid var(--teal) }
.result-modal.defeat { border-top-color: var(--red) }
.result-modal h2 { font: italic 1000 clamp(40px,6vw,65px)/1.1 var(--display); letter-spacing: -.075em }
.result-summary { display: flex; justify-content: space-between; gap: 10px; margin: 20px 0; padding: 12px 0; border-block: 1px solid var(--line) }
.result-summary small,.result-summary strong { display: block }
.help-modal { width: min(100%,560px) }
.help-steps { padding-left: 23px }
.help-steps li { margin: 14px 0 }
.help-note { padding: 9px; background: #e0eadd; font-size: 13px }
.setting-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; border-bottom: 1px solid var(--line); font-weight: 700 }
.setting-row small { display: block; color: var(--muted); font-size: 12px; font-weight: 400 }
.setting-row input { width: 23px; height: 23px; accent-color: var(--teal) }
.settings-note { margin-top: 15px }
.toast { position: fixed; z-index: 8; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: 92vw; width: max-content; background: var(--ink); color: white; border: 1px solid var(--sheet); padding: 10px 16px; font-size: 14px; pointer-events: none }
@media (max-width:900px) {
  .home-screen { padding-inline: 18px }
  .hero { grid-template-columns: 48% minmax(0,1fr) }
  .hero-copy { padding: 24px }
  .hero-actions .button { padding-inline: 10px; font-size: 14px }
  .roster-list { gap: 8px }
  .roster-entry summary { grid-template-columns: 42% 1fr }
  .roster-entry summary span { padding: 6px }
  .game-header { gap: 7px }
  .battle-layout { grid-template-columns: minmax(0,1fr) 282px; gap: 10px }
}
@media (max-width:720px) {
  .home-screen { padding-inline: 12px }
  .home-nav { min-height: 52px }
  .nav-right { gap: 0 }
  .hero { grid-template-columns: minmax(0,1fr); box-shadow: 3px 4px var(--ink) }
  .hero-art { grid-area: 1/1; height: clamp(165px,47vw,260px); border: 0; border-bottom: 2px solid var(--ink) }
  .hero-art img { object-position: 50% 35% }
  .hero-copy { grid-area: 2/1; padding: 17px 18px 18px }
  .hero h1 { font-size: clamp(29px,8.4vw,61px); margin: 10px 0 7px; line-height: 1 }
  .hero h1 br { display: none }
  .hero h1 em { margin-left: .12em }
  .hero h2 { font-size: 17px }
  .genre,.intro { font-size: 12px }
  .intro { margin: 5px 0 12px }
  .hero-actions { flex-wrap: nowrap }
  .hero-actions .button { flex: 1; min-width: 0; min-height: 46px; gap: 4px; font-size: clamp(12px,3.4vw,14px); padding: 6px }
  .join-row { margin-top: 12px; padding-top: 10px; max-width: none }
  .roster-list { grid-template-columns: 1fr 1fr }
  .roster header { gap: 6px 12px }
  .roster-entry summary { min-height: 66px }
  .roster-entry img { max-height: 78px }
  .game-screen { padding: 0 8px 16px }
  .game-header { min-height: 46px; margin-bottom: 7px; flex-wrap: wrap }
  .game-header .wordmark { font-size: 13px; gap: 4px }
  .game-header .stack-mark { width: 16px; height: 16px }
  .game-header #mode-label { font-size: 10px }
  .game-header .text-button { font-size: 12px; padding: 4px 5px }
  .header-actions { gap: 0 }
  .connection { font-size: 10px }
  .battle-layout { display: flex; flex-direction: column; gap: 8px }
  .arena-column,.command-station,.inspector { width: 100% }
  .scoreboard { padding-bottom: 6px; gap: 8px }
  .score-label { font-size: 11px }
  .score-label small,.economy,.loadout-row { font-size: 10px }
  .economy small { display: none }
  .core-row strong { font-size: 13px }
  .arena-topline,.arena-bottomline { font-size: 11px; padding: 4px 8px }
  .arena-bottomline { min-height: 26px }
  .command-station { box-shadow: none }
  .station-heading { padding: 4px 10px }
  .station-heading h2 { font-size: 15px }
  .wallet b { font-size: 17px }
  .command-deck { padding: 7px; gap: 6px }
  .build-card { display: grid; grid-template-columns: 42% 1fr; align-content: center; min-height: 49px }
  .build-card img { grid-row: span 2; height: 100%; aspect-ratio: 1; object-fit: cover }
  .build-card strong { align-self: end; font-size: 13px }
  .build-card .card-cost { font-size: 10px }
  .field-controls,.orders { padding: 7px 9px }
  .loadout-modal { padding: 18px 14px }
  .loadout-cards { grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0 }
  .loadout-portrait img { height: clamp(68px,24vw,115px); object-position: center 24% }
  .loadout-card>strong { font-size: 14px }
  .loadout-card>small,.loadout-blast { font-size: 11px; line-height: 1.4 }
  .inspect-stats { grid-template-columns: 1fr }
}
@media (max-width:420px) {
  .game-header .wordmark { font-size: 0; gap: 0 }
  .game-header .stack-mark { width: 23px; height: 23px }
  .home-nav .text-button { padding-inline: 8px }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation: none !important; scroll-behavior: auto !important }
}

.intro-return { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 4px 8px; color: var(--teal); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; white-space: nowrap }
.result-modal .intro-return { display: flex; width: fit-content; margin: 6px auto 0 }
@media (max-width: 520px) {
  .home-nav { flex-wrap: wrap }
  .home-nav .nav-right { margin-left: auto }
  .header-actions .intro-return { font-size: 12px; padding-inline: 5px }
}
