:root {
  font-family: 'Avenir Next', Avenir, 'Trebuchet MS', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: #253440; background: #f3eee5; font-synthesis: none;
  --ink: #253440; --muted: #59646b; --paper: #fffaf0; --line: #d3cec4;
  --coral: #bd4058; --sky: #23718b;
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; font-weight: 600; }
button:hover { background: #eee8dc; }
button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid #257d9b; outline-offset: 3px; }
[hidden] { display: none !important; }
#app { height: 100dvh; min-height: 640px; position: relative; isolation: isolate; }
#world { position: absolute; inset: 100px 0 65px 380px; z-index: -1; }
#world canvas { width: 100%; height: 100%; display: block; }
.masthead { position: absolute; inset: 24px 32px auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 900; letter-spacing: -.8px; color: var(--ink); text-decoration: none; }
.brand-mark { position: relative; display: grid; place-items: center; width: 38px; height: 38px; background: var(--ink); color: var(--paper); border-radius: 7px; font-size: 27px; }
.brand-mark span { position: absolute; bottom: 2px; right: 3px; color: #ff99aa; font-size: 18px; }
.brand em { font-size: 17px; font-style: normal; }
.brand-dot { color: var(--coral); }
nav { display: flex; align-items: center; gap: 7px; }
.nav-button { min-height: 36px; padding: 0 12px; font-size: 12px; white-space: nowrap; }
.build-label { font-size: 12px; color: var(--muted); margin-right: 12px; }
.shift-lock { display: none; }
.shift-lock[aria-pressed='true'], #sound-toggle[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: white; }
.lobby { position: absolute; width: 310px; left: 40px; top: 50%; transform: translateY(-44%); }
h1 { font-size: 40px; line-height: 1.1; letter-spacing: -1.6px; margin: 0 0 12px; }
.intro { font-size: 17px; line-height: 1.6; color: var(--muted); margin: 0 0 30px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.name-field input, .join-row input { width: 100%; min-width: 0; height: 44px; padding: 10px 12px; background: var(--paper); border: 1px solid #b2b4b0; border-radius: 5px; font-size: 15px; }
.primary { display: flex; align-items: center; justify-content: center; width: 100%; height: 46px; margin-top: 12px; color: white; background: var(--ink); border-color: var(--ink); font-size: 15px; }
.primary:hover { background: #3c5362; }
.form-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 12px 0 24px; }
.join-label { border-top: 1px solid var(--line); padding-top: 22px; }
.join-row { display: flex; gap: 8px; }
.join-row input { width: 55%; letter-spacing: 1.5px; text-transform: uppercase; }
.join-row input::placeholder { font-size: 11px; letter-spacing: .8px; }
.join-row button { flex: 1; font-size: 13px; }
.new-room { border: 0; background: transparent; padding: 8px 0; margin-top: 8px; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.lobby-foot { font-size: 11px; color: var(--muted); margin: 25px 0 0; }
.error { color: #ad263c; font-size: 13px; line-height: 1.5; }
.error:empty { display: none; }
.map-label { position: absolute; bottom: 34px; left: 420px; display: flex; gap: 12px; align-items: baseline; }
.map-label strong { font-size: 14px; }
.map-label span { font-size: 12px; color: var(--muted); }
.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 14px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.controls > span:first-child, .key-row { display: flex; gap: 2px; }
.controls i { height: 14px; border-left: 1px solid var(--line); margin: 0 4px; }
.controls-extra b { margin: 0 6px; }
.live-dot, .dot { display: inline-block; width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; }
.live-dot { background: #447a56; }
.coral { background: var(--coral); }
.sky { background: var(--sky); }
.purple { background: var(--ink); }
kbd { display: inline-block; font-weight: 600; font-family: inherit; font-size: 10px; border: 1px solid #aeb4b4; border-bottom-width: 2px; padding: 2px 5px; border-radius: 3px; color: var(--ink); background: #fffdf6; }
body.playing #world { inset: 0; }
body.looking #world { cursor: none; }
body.playing .lobby, body.playing .map-label, body.playing .brand, body.playing .build-label { display: none; }
body.playing .masthead { inset: 20px 20px auto auto; }
body.playing .shift-lock { display: block; }
.scoreboard { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 16px; padding: 10px 14px; background: #fffaf0f2; border: 1px solid var(--line); border-radius: 8px; }
.team-score { width: 105px; }
.team-score > span { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 800; }
.team-score small { font-size: 9px; font-weight: 600; }
.team-score strong { display: block; font-size: 23px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.team-score strong small { font-size: 12px; margin-left: 2px; }
.coral-team { color: var(--coral); }
.sky-team { color: var(--sky); text-align: right; }
.meter { height: 3px; background: #e1ddd3; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: #e6617a; transition: width .15s; }
.sky-team .meter i { background: #389cbd; margin-left: auto; }
.match-clock { min-width: 90px; text-align: center; }
.match-clock > span { font-size: 10px; font-weight: 700; display: block; }
.match-clock strong { display: block; font-size: 25px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.match-clock small { font-size: 9px; color: var(--muted); display: block; margin-top: 2px; }
.room-panel { position: absolute; left: 20px; top: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; width: 230px; padding: 9px 11px; background: #fffaf0ef; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.room-panel strong { letter-spacing: 1px; }
.room-panel button { font-size: 11px; padding: 4px 7px; }
.room-panel #network-label { width: 155px; color: var(--muted); font-size: 10px; }
.room-panel .leave-button { min-height: 32px; padding: 5px 10px; }
.players { position: absolute; left: 20px; top: 106px; background: #fffaf0ef; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; min-width: 92px; }
.players summary { padding: 7px 10px; }
.roster { display: flex; flex-direction: column; gap: 10px; padding: 5px 12px 12px; }
.roster-row { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.roster-row strong { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-row small { font-size: 9px; color: var(--muted); }
.roster-row.out { opacity: .45; }
.role-panel { position: absolute; left: 20px; bottom: 20px; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 40px); background: #fffaf0f2; border: 1px solid var(--line); border-left: 4px solid #e6617a; border-radius: 6px; padding: 12px 14px; }
.role-panel > div { display: flex; flex-direction: column; gap: 4px; }
.role-panel small { font-size: 10px; color: var(--muted); }
.role-panel strong { font-size: 15px; }
.role-panel span { font-size: 12px; color: var(--muted); }
.role-panel button { padding: 10px 12px; font-size: 12px; background: var(--ink); color: white; border-color: var(--ink); }
.role-panel button kbd { margin-left: 5px; }
.bonus-chip { position: absolute; right: 20px; bottom: 26px; padding: 10px 12px; background: #fffaf0ef; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; }
.bonus-chip b { margin-left: 8px; }
.bonus-chip.captured { border-color: #ae9966; background: #f5e7ba; }
.spectate-panel { position: absolute; right: 20px; top: 110px; width: 225px; padding: 15px; background: #fffaf0f2; border: 1px solid var(--line); border-radius: 6px; }
.spectate-panel strong { font-size: 14px; }
.spectate-panel p { font-size: 13px; line-height: 1.6; color: var(--muted); }
.spectate-panel button { padding: 8px; font-size: 12px; }
.aim-reticle { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 24px; line-height: 1; color: white; filter: drop-shadow(0 1px 2px #253440); pointer-events: none; }
.round-overlay { position: absolute; inset: 150px 0 120px; display: grid; place-items: center; pointer-events: none; z-index: 3; }
.round-card { padding: 24px 32px; text-align: center; background: #fffaf0f5; border: 1px solid var(--line); border-radius: 8px; }
.round-card > span { font-size: 11px; color: var(--muted); font-weight: 700; }
.round-card h2 { font-size: 30px; margin: 10px 0; }
.round-card p { font-size: 14px; }
.round-card > strong { display: block; font-size: 36px; }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); padding: 28px; width: calc(100% - 40px); max-width: 820px; max-height: calc(100dvh - 48px); overflow-y: auto; }
dialog::backdrop { background: #17273299; }
.dialog-close { position: absolute; right: 14px; top: 12px; border: 0; background: transparent; padding: 0; width: 32px; height: 32px; font-size: 25px; }
dialog h2 { font-size: 27px; margin: 4px 0 12px; }
dialog > p { font-size: 14px; line-height: 1.65; color: var(--muted); }
.skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0 18px; }
.skin-card { padding: 12px 8px; border: 2px solid var(--line); background: #eee9df; display: flex; flex-direction: column; align-items: center; gap: 7px; overflow: hidden; }
.skin-card.selected { border-color: var(--ink); background: #e1e9e9; }
.skin-portrait { display: block; width: 100%; height: 176px; object-fit: contain; }
.skin-card strong { font-size: 12px; }
.skin-card small { font-size: 12px; font-weight: 400; color: var(--muted); }
.skin-card > span:last-child { font-size: 11px; margin-top: 8px; }
.skin-card.selected > span:last-child { font-weight: 800; }
.dialog-note { color: var(--muted); font-size: 12px; }
.help-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin: 22px 0; }
.help-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 4px; color: white; font-size: 11px; font-weight: 700; }
.help-columns h3 { margin: 12px 0 8px; font-size: 16px; }
.help-columns p, .help-detail { font-size: 14px; line-height: 1.65; color: var(--muted); }
.help-detail { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.help-detail b { color: var(--ink); }
.toast { position: absolute; bottom: 115px; left: 50%; transform: translateX(-50%); max-width: min(560px, 90vw); background: var(--ink); color: white; padding: 12px 18px; border-radius: 5px; font-size: 13px; line-height: 1.5; text-align: center; z-index: 20; }
@media (max-width: 1100px) {
  .scoreboard { top: 78px; }
  .players { top: 110px; }
  .spectate-panel { top: 170px; }
  .lobby { left: 28px; width: 290px; }
  #world { left: 330px; }
  .map-label { left: 360px; }
  .bonus-chip { bottom: 108px; }
  .role-panel span { max-width: 260px; line-height: 1.4; }
}
@media (max-height: 680px) and (min-width: 701px) {
  #app { min-height: 580px; }
  .lobby { top: 108px; transform: none; }
  h1 { font-size: 32px; }
  .intro { margin-bottom: 18px; }
  .lobby-foot { margin-top: 16px; }
}
@media (max-width: 700px) {
  body { overflow: auto; }
  #app { min-height: 940px; }
  .masthead { inset: 16px 16px auto; flex-wrap: wrap; gap: 14px; }
  .brand { font-size: 19px; }
  nav { gap: 6px; }
  .build-label { display: none; }
  #world { inset: 110px -10px auto; height: 300px; }
  .lobby { top: 420px; left: 24px; width: calc(100% - 48px); transform: none; }
  h1 { font-size: 34px; }
  .intro { margin-bottom: 22px; }
  .map-label { top: 380px; bottom: auto; left: 24px; }
  body.playing { overflow: hidden; }
  body.playing #app { min-height: 560px; }
  body.playing #world { inset: 0; height: auto; }
  body.playing .masthead { inset: 12px 12px auto auto; }
  .nav-button { font-size: 11px; padding: 0 8px; min-height: 34px; }
  .room-panel { left: 12px; top: 55px; width: 216px; }
  .players { left: 12px; top: 141px; }
  .scoreboard { top: 180px; gap: 12px; padding: 8px 10px; }
  .team-score { width: 86px; }
  .match-clock { min-width: 80px; }
  .role-panel { left: 12px; right: 12px; bottom: 12px; max-width: none; flex-wrap: wrap; gap: 9px; padding: 10px; }
  .role-panel > div { width: 100%; }
  .role-panel span { max-width: none; }
  .role-panel button { padding: 8px 10px; }
  .bonus-chip { bottom: 158px; right: 12px; font-size: 11px; }
  .spectate-panel { top: 280px; right: 12px; width: 205px; padding: 12px; }
  .round-overlay { inset: 275px 0 160px; }
  .round-card { padding: 20px; }
  dialog { padding: 24px 20px; width: calc(100% - 24px); }
  .skin-grid { grid-template-columns: repeat(2, 1fr); }
  .skin-portrait { height: 160px; }
  .help-columns { grid-template-columns: 1fr; gap: 16px; }
  .help-number { float: left; margin-right: 10px; }
  .help-columns h3 { margin: 3px 0 10px; }
  .help-columns p { margin: 0; }
  .toast { bottom: 175px; }
}

.lobby-modes { display:flex; gap:8px; margin:12px 0 18px; }
.lobby-modes button { flex:1; padding:10px 8px; font-size:13px; }
.combat-feedback { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; pointer-events:none; }

body.practicing .team-score { display:none; }
body.practicing .match-clock { min-width:140px; }

.room-tools { position:absolute; left:20px; top:20px; display:flex; flex-direction:column; align-items:flex-start; gap:8px; z-index:4; }
.room-tools .room-panel, .room-tools .players { position:static; }
@media(max-width:700px){ .room-tools {left:12px;top:55px;} .scoreboard {top:235px;} }

/* Keep Korean words together; allow long help copy to wrap at spaces. */
:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }
html:lang(ko) h1 { font-size: 36px; line-height: 1.25; letter-spacing: -1px; }
html:lang(ko) .room-panel strong { letter-spacing: 0; }
@media (min-width: 1101px) and (max-width: 1350px) {
  body.playing .scoreboard { top: 78px; }
}
@media (max-width: 700px) {
  nav { flex-wrap: wrap; }
  html:lang(ko) h1 { font-size: 32px; }
}

body.warming-up .team-score, body.warming-up #timer { display:none; }
body.warming-up .match-clock { min-width:150px; }
.warmup-note { max-width:230px; margin:0; padding:10px; background:#fffaf0ef; border:1px solid var(--line); border-radius:5px; font-size:12px; line-height:1.5; }
#lobby-team { max-width:230px; padding:9px 12px; font-size:12px; }
#guest-id:empty { display:none; }
#guest-id { margin-bottom:-18px; overflow-wrap:anywhere; }
@media(max-width:700px){body.warming-up .scoreboard {top:310px;} .warmup-note {font-size:11px;padding:7px;} }

.ad-contact { margin: 20px 0 0; }
.ad-contact button { display: inline-block; padding: 8px 0; font-size: 18px; font-weight: 700; color: var(--ink); text-underline-offset: 4px; text-decoration: underline; background: none; border: 0; cursor: pointer; }

.intro > span { display: block; }
.intro > span + span { margin-top: 6px; }
