* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #f1eee5; color: #171717; font-family: 'Courier New', Courier, monospace; overflow: hidden; }
body { display: flex; align-items: center; justify-content: center; }
#ui { position: relative; width: 100%; max-width: 100%; height: 100vh; height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px; overflow-x: hidden; background-image: radial-gradient(#b8b2a7 0.6px, transparent 0.6px); background-size: 15px 15px; }
.hidden { display: none !important; }

/* Menu */
.menu-shell { width: min(1080px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; padding: clamp(1.1rem, 3.5vw, 2.4rem); border: 2px solid #171717; background: #fbfaf6; box-shadow: 9px 9px 0 #171717; text-align: left; }
.menu-brand { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1.3rem; border-bottom: 2px solid #171717; }
.brand-kicker, .card-kicker { font-size: 0.68rem; font-weight: bold; letter-spacing: 2px; text-transform: uppercase; }
.menu-brand h1 { margin: 0.15rem 0 0.1rem; font-size: clamp(2.4rem, 7vw, 4rem); line-height: 1; letter-spacing: 0.16em; text-transform: uppercase; }
.subtitle { font-size: 0.78rem; opacity: 0.7; }
.brand-stamp { display: grid; width: 72px; height: 72px; flex: 0 0 auto; place-items: center; border: 3px double #c81e1e; border-radius: 50%; color: #c81e1e; font-weight: bold; font-size: 1.1rem; transform: rotate(-12deg); }
.menu-grid { display: grid; grid-template-columns: minmax(265px, 0.78fr) minmax(0, 1.5fr); align-items: start; gap: 1rem; margin-top: 1.1rem; }
.player-account-column { display: grid; min-width: 0; gap: 0.65rem; }
.profile-strip { display: grid; gap: 0.5rem; padding: 0.8rem; border: 1px solid #c9c3b7; background: #f6f2e9; }
.profile-strip { position: relative; isolation: isolate; overflow: hidden; border-color: #c8bfae; background-color: #f6f2e9; background-image: radial-gradient(rgba(142,32,30,0.11) 0.65px, transparent 0.65px), linear-gradient(135deg, rgba(255,255,255,0.42), transparent 58%); background-size: 13px 13px, 100% 100%; }
.profile-strip::before { position: absolute; z-index: 0; top: 12%; right: 8%; display: grid; width: 108px; aspect-ratio: 1; place-items: center; border: 3px double rgba(142,32,30,0.14); border-radius: 50%; color: rgba(142,32,30,0.13); content: "B/N"; font-size: 1.25rem; font-weight: bold; letter-spacing: 0.12em; transform: rotate(-12deg); pointer-events: none; }
.profile-strip::after { position: absolute; z-index: 0; right: -18px; bottom: 20%; width: 150px; height: 1px; background: repeating-linear-gradient(90deg, rgba(142,32,30,0.18) 0 5px, transparent 5px 10px); content: ""; transform: rotate(-28deg); pointer-events: none; }
.profile-strip > * { position: relative; z-index: 1; }
.profile-name { min-width: 0; }
.profile-name .field-label { margin-top: 0; }
.profile-summary { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.profile-detail { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; gap: 0.15rem; font-size: 0.8rem; }
.profile-detail strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-caption { color: #8e201e; font-size: 0.6rem; font-weight: bold; letter-spacing: 0.12em; white-space: nowrap; }
.identity-badge { display: inline-flex; width: fit-content; max-width: 100%; padding: 0.2rem 0.35rem; border: 1px solid #8e201e; color: #8e201e; font-size: 0.52rem; font-weight: bold; line-height: 1.25; letter-spacing: 0.035em; }
.identity-badge.is-account { border-color: #0f766e; color: #0f766e; }
.profile-strip > .btn { width: 100%; }
.account-panel { min-width: 0; padding: 0.8rem; border: 2px solid #171717; background: #fff; box-shadow: 3px 3px 0 #d9d4c8; }
.account-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.account-panel-heading h2 { margin-top: 0.2rem; font-size: 1.1rem; }
.account-mark { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; border: 1px solid #8e201e; color: #8e201e; }
.account-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.account-intro { margin: 0.45rem 0 0.65rem; color: #5d5a54; font-size: 0.63rem; line-height: 1.45; }
.account-footnote { margin: -0.35rem 0 0.55rem; color: #8e201e; font-size: 0.53rem; line-height: 1.35; }
.account-controls { display: grid; gap: 0.28rem; }
.account-controls label { margin-top: 0.1rem; font-size: 0.62rem; font-weight: bold; }
.account-controls input { padding: 0.42rem 0.5rem; font-size: 0.7rem; }
.account-buttons, .account-status { grid-column: 1 / -1; }
.account-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.account-status { min-height: 1rem; font-size: 0.59rem; line-height: 1.4; color: #5d5a54; }
.account-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.3rem; margin-top: 0.7rem; }
.account-stats > div { display: flex; min-width: 0; flex-direction: column; gap: 0.12rem; padding: 0.38rem; border: 1px dashed #c9c3b7; background: #fbfaf6; }
.account-stats span { color: #716d65; font-size: 0.48rem; font-weight: bold; letter-spacing: 0.06em; }
.account-stats strong { font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.account-stat-total, .account-stat-rate { grid-column: span 1; }
.account-history { margin-top: 0.7rem; }
.account-history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 0.3rem; padding-bottom: 0.3rem; border-bottom: 1px solid #d9d4c8; }
.account-history-heading strong { color: #8e201e; font-size: 0.56rem; letter-spacing: 0.08em; }
.account-history-heading span { color: #716d65; font-size: 0.49rem; }
.account-history ol { display: grid; gap: 0.18rem; margin-top: 0.3rem; list-style: none; }
.account-history-item { display: grid; grid-template-columns: 3.1rem minmax(0, 1fr) auto; align-items: center; gap: 0.3rem; min-width: 0; padding: 0.25rem 0.35rem; border-left: 2px solid #aaa397; background: #fbfaf6; }
.account-history-item.is-win { border-left-color: #0f766e; }
.account-history-item.is-loss { border-left-color: #8e201e; }
.account-history-item strong { font-size: 0.5rem; }
.account-history-item.is-win strong { color: #0f766e; }
.account-history-item.is-loss strong { color: #8e201e; }
.account-history-item span { overflow: hidden; color: #5d5a54; font-size: 0.5rem; text-overflow: ellipsis; white-space: nowrap; }
.account-history-item time { color: #716d65; font-size: 0.48rem; font-variant-numeric: tabular-nums; }
.account-history-empty { padding: 0.45rem; color: #716d65; font-size: 0.56rem; text-align: center; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(210px, 0.8fr); align-items: stretch; gap: 0.75rem; }
.menu-card { display: flex; flex-direction: column; align-items: flex-start; padding: 1.25rem; border: 2px solid #171717; background: #fff; box-shadow: 4px 4px 0 #d9d4c8; }
.menu-card h2 { margin: 0.45rem 0; font-size: 1.35rem; letter-spacing: 0.02em; }
.card-kicker { color: #8e201e; }
.card-copy { min-height: 2.6rem; margin-bottom: 1rem; font-size: 0.78rem; line-height: 1.5; opacity: 0.72; }
.field-label { display: block; margin: 0.25rem 0 0.4rem; font-size: 0.72rem; font-weight: bold; letter-spacing: 0.04em; }
.row { margin: 0.55rem 0; display: flex; gap: 0.6rem; justify-content: center; align-items: center; flex-wrap: wrap; }
label { font-size: 0.85rem; }
input, select { width: 100%; max-width: 100%; padding: 0.65rem 0.7rem; border: 2px solid #171717; background: #fff; color: #171717; font-family: inherit; font-size: 0.85rem; outline: none; }
input:focus, select:focus { box-shadow: 3px 3px 0 #171717; }
.online-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; width: 100%; margin: 0.8rem 0 1rem; }
.join-room { width: 100%; padding-top: 0.7rem; border-top: 1px dashed #aaa397; }
.join-actions { display: flex; gap: 0.5rem; }
.join-actions input { min-width: 0; text-transform: uppercase; }
.join-actions .btn { flex: 0 0 auto; }
.bot-card { background: #f6f2e9; }
.bot-start { width: 100%; margin-top: 0.9rem; }
.bot-note { margin-top: 0.7rem; font-size: 0.68rem; opacity: 0.65; }
.menu-footer { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-top: 0.9rem; }
.profile-mark { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid #c81e1e; color: #c81e1e; }
.profile-mark canvas { display: block; width: 28px; height: 28px; }
.btn { padding: 0.62rem 0.85rem; font-family: inherit; font-size: 0.8rem; border: 2px solid #171717; background: #fff; color: #171717; cursor: pointer; text-transform: uppercase; letter-spacing: 0.07em; transition: background 0.12s, color 0.12s, transform 0.08s; }
.with-icon { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; }
.btn-icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: #171717; color: #fff; }
.btn.primary { background: #171717; color: #fff; }
.btn.primary:hover { background: #8e201e; border-color: #8e201e; }
.btn:active { transform: translate(1px, 1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .sym-btn:focus-visible, .color-btn:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: #fff; color: #000; }
.btn.ghost { border-style: dashed; }
.btn.small { padding: 0.35rem 0.6rem; font-size: 0.72rem; letter-spacing: 0.5px; }
.btn.danger { border-color: #c81e1e; color: #c81e1e; }
.btn.danger:hover { background: #c81e1e; color: #fff; }
.status { margin-top: 0.9rem; min-height: 1.2rem; font-size: 0.74rem; opacity: 0.78; }

/* Game Layout */
#game { width: 100%; min-width: 0; max-width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; overflow-x: hidden; }
#hud { width: 100%; max-width: 1180px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.hud-info { display: flex; align-items: center; gap: 1.2rem; font-size: 0.82rem; }
.hud-info strong { text-transform: uppercase; letter-spacing: 1px; }
.hud-weather { position: relative; display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 0.35rem; padding: 0.28rem 0.5rem; border: 1px solid #c9c3b7; background: #fbfaf6; cursor: help; }
.hud-weather-label { color: #8e201e; font-size: 0.64rem; font-weight: bold; letter-spacing: 0.08em; text-transform: uppercase; }
.wind-info-icon { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wind-tooltip { position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; width: min(290px, calc(100vw - 28px)); padding: 0.65rem 0.75rem; border: 1px solid #8e201e; background: #171717; color: #fff; font-size: 0.68rem; line-height: 1.45; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 0.12s, transform 0.12s, visibility 0.12s; }
.hud-weather:hover .wind-tooltip, .hud-weather:focus .wind-tooltip, .hud-weather:focus-within .wind-tooltip { opacity: 1; visibility: visible; transform: translateY(0); }
.hud-weather small { grid-column: 1 / -1; min-height: 0.8rem; color: #8e201e; font-size: 0.62rem; }
.hud-actions { display: flex; min-width: 0; max-width: 100%; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.turn-clock { display: flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.48rem; border: 2px solid #171717; background: #fff; }
.turn-clock span { font-size: 0.58rem; font-weight: bold; letter-spacing: 0.08em; }
.turn-clock strong { min-width: 1.45rem; color: #8e201e; font-size: 0.9rem; text-align: center; font-variant-numeric: tabular-nums; }
.turn-clock.urgent { border-color: #c81e1e; background: #fff1ef; animation: timerPulse 0.9s ease-in-out infinite; }
.base-placement-panel { position: fixed; top: clamp(74px, 11vh, 112px); left: 50%; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(800px, calc(100vw - 32px)); padding: 0.65rem 0.8rem; border: 2px solid #8e201e; background: #fff4ed; box-shadow: 4px 4px 0 rgba(142,32,30,0.2); transform: translateX(-50%); }
.base-placement-panel strong, .checkpoint-mode-label { color: #8e201e; font-size: 0.65rem; font-weight: bold; letter-spacing: 0.1em; }
.base-placement-panel p { margin: 0.2rem 0 0; font-size: 0.75rem; line-height: 1.35; }
.base-placement-countdown { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.arena { display: flex; min-width: 0; max-width: 100%; align-items: center; justify-content: center; gap: 16px; width: 100%; overflow-x: hidden; }
.player-column { position: relative; z-index: 1; display: grid; min-width: 0; flex: 0 0 198px; grid-template-columns: minmax(0, 1fr) 40px; grid-template-areas: "panel modes" "skills skills"; align-items: start; gap: 0.5rem; }
.player-column:hover, .player-column:focus-within { z-index: 8; }
.player-panel { grid-area: panel; position: relative; width: 100%; border: 2px solid #000; padding: 0.7rem 0.6rem; display: flex; flex-direction: column; gap: 0.55rem; align-items: center; background: #fff; transition: box-shadow 0.15s, transform 0.15s; }
.player-panel.active { box-shadow: 5px 5px 0 #000; transform: translate(-2px, -2px); }
.player-panel.dead { opacity: 0.4; filter: grayscale(1); }
.pp-head { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 0.4rem; }
.pp-name { font-size: 0.85rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 95px; }
.pp-badge { font-size: 0.6rem; border: 1px solid #000; padding: 0.1rem 0.3rem; opacity: 0; text-transform: uppercase; }
.player-panel.active .pp-badge { opacity: 1; background: #000; color: #fff; }
.player-skills { width: 100%; padding: 0.4rem; border: 1.5px solid #171717; background: rgba(255,255,255,0.94); }
.checkpoint-mode-control { grid-area: modes; display: flex; flex-direction: column; gap: 0.3rem; width: 40px; }
.checkpoint-mode-button { position: relative; display: grid; width: 40px; height: 40px; flex: 0 0 40px; place-items: center; padding: 3px; border: 1.5px solid #171717; border-radius: 7px; background: linear-gradient(145deg, #fff 0%, #f4f0e7 100%); color: #171717; cursor: pointer; font: inherit; transition: background 0.12s, color 0.12s, box-shadow 0.12s, transform 0.12s; }
.checkpoint-mode-button:hover:not(:disabled), .checkpoint-mode-button:focus-visible { outline: 2px solid #8e201e; outline-offset: 2px; }
.checkpoint-mode-button.selected { background: linear-gradient(145deg, #333 0%, #171717 100%); color: #fff; box-shadow: 2px 2px 0 #8e201e, inset 0 0 0 1px rgba(255,255,255,0.16); transform: translateY(-1px); }
.checkpoint-mode-button:disabled { opacity: 0.48; cursor: not-allowed; }
.checkpoint-mode-title { display: none; }
.checkpoint-mode-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.checkpoint-mode-icon--permanent { color: #8e201e; }
.checkpoint-mode-icon--linked { color: #315e7a; }
.checkpoint-mode-button.selected .checkpoint-mode-icon { color: #fff; }
.checkpoint-mode-count { position: absolute; right: 1px; bottom: 1px; min-width: 13px; padding: 0 2px; border: 1px solid #171717; background: #fff; color: #171717; font-size: 0.52rem; font-weight: bold; line-height: 1.1; text-align: center; font-variant-numeric: tabular-nums; }
.checkpoint-mode-tooltip { position: absolute; top: 50%; left: calc(100% + 0.45rem); z-index: 20; width: 220px; padding: 0.55rem 0.65rem; border: 1px solid #8e201e; background: #171717; color: #fff; font-size: 0.67rem; font-weight: normal; line-height: 1.4; text-align: left; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-50%) translateX(-4px); transition: opacity 0.12s, transform 0.12s, visibility 0.12s; }
.focus-tooltip::before, .checkpoint-mode-tooltip::before { display: block; margin-bottom: 0.25rem; color: #f0b4a6; font-size: 0.58rem; font-weight: bold; letter-spacing: 0.12em; }
.focus-tooltip::before { content: "KỸ NĂNG"; }
.checkpoint-mode-tooltip::before { content: "LOẠI CỨ ĐIỂM"; }
.focus-tooltip::after, .checkpoint-mode-tooltip::after { display: block; margin-bottom: 0.3rem; color: #fff; content: attr(data-tooltip-title); font-size: 0.78rem; font-weight: bold; }
.checkpoint-mode-control--p2 .checkpoint-mode-tooltip { right: calc(100% + 0.45rem); left: auto; transform: translateY(-50%) translateX(4px); }
.checkpoint-mode-button:hover .checkpoint-mode-tooltip, .checkpoint-mode-button:focus-visible .checkpoint-mode-tooltip { opacity: 1; visibility: visible; transform: translateY(-50%); }
.player-skills { grid-area: skills; }
.player-skills-title { margin: 0 0 0.35rem; color: #8e201e; font-size: 0.53rem; font-weight: bold; letter-spacing: 0.14em; }
.player-skill-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
.focus-skill-slot { position: relative; z-index: 4; display: flex; justify-content: center; width: 100%; }
.focus-skill-slot--compact { display: none; width: auto; }
.focus-skill-button { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; align-items: center; gap: 0.35rem; width: 100%; min-height: 46px; padding: 0.35rem 0.4rem; border: 1.5px solid #8e201e; background: #fffaf7; color: #171717; cursor: pointer; font-family: inherit; text-align: left; transition: background 0.12s, color 0.12s, box-shadow 0.12s; }
.focus-skill-button:hover:not(:disabled), .focus-skill-button:focus-visible { background: #f7e8e4; outline: 2px solid #8e201e; outline-offset: 2px; }
.focus-skill-button:disabled { opacity: 0.6; cursor: not-allowed; }
.focus-skill-button.armed { background: #8e201e; color: #fff; box-shadow: 3px 3px 0 #171717; }
.focus-skill-icon { width: 23px; height: 23px; fill: none; stroke: #8e201e; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.focus-skill-button.armed .focus-skill-icon { stroke: #fff; }
.focus-skill-copy { display: flex; min-width: 0; flex-direction: column; gap: 0.08rem; line-height: 1.1; }
.focus-skill-copy strong { font-size: 0.64rem; letter-spacing: 0.12em; }
.focus-skill-copy small { font-size: 0.58rem; opacity: 0.76; white-space: nowrap; }
.focus-skill-count { font-weight: bold; font-variant-numeric: tabular-nums; }
.focus-skill-status { max-width: 48px; color: #8e201e; font-size: 0.48rem; font-weight: bold; line-height: 1.15; text-align: right; }
.focus-skill-button.armed .focus-skill-status { color: #fff; }
.match-skill-symbol { display: grid; width: 23px; height: 23px; place-items: center; border: 1px solid #8e201e; border-radius: 50%; color: #8e201e; font-size: 0.8rem; font-weight: bold; }
.focus-skill-button.armed .match-skill-symbol { border-color: #fff; color: #fff; }
.focus-tooltip { position: absolute; top: 50%; z-index: 20; width: 220px; padding: 0.55rem 0.65rem; border: 1px solid #8e201e; background: #171717; color: #fff; font-size: 0.67rem; line-height: 1.4; text-align: left; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.12s, transform 0.12s, visibility 0.12s; }
#playerSkillsP1 .focus-tooltip { top: auto; bottom: calc(100% + 0.45rem); left: calc(100% + 0.55rem); transform: translateX(-4px); }
#playerSkillsP2 .focus-tooltip { top: auto; right: calc(100% + 0.55rem); bottom: calc(100% + 0.45rem); transform: translateX(4px); }
.focus-skill-slot:hover .focus-tooltip, .focus-skill-button:focus-visible + .focus-tooltip { opacity: 1; visibility: visible; }
#playerSkillsP1 .focus-skill-slot:hover .focus-tooltip, #playerSkillsP1 .focus-skill-button:focus-visible + .focus-tooltip { transform: translateX(0); }
#playerSkillsP2 .focus-skill-slot:hover .focus-tooltip, #playerSkillsP2 .focus-skill-button:focus-visible + .focus-tooltip { transform: translateX(0); }
.focus-skill-slot--compact .focus-skill-button { width: auto; min-width: 132px; }
.focus-skill-slot--compact .focus-tooltip { top: auto; right: auto; bottom: calc(100% + 0.45rem); left: 50%; width: min(240px, 75vw); transform: translate(-50%, 4px); }
.focus-skill-slot--compact:hover .focus-tooltip, .focus-skill-button:focus-visible + .focus-tooltip { transform: translate(-50%, 0); }
.skill-draft-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.45rem; margin: 0.65rem 0; }
.skill-draft-option { display: grid; grid-template-columns: 25px minmax(0, 1fr); align-items: start; gap: 0.35rem; min-height: 70px; padding: 0.45rem; border: 1.5px solid #171717; background: #fff; color: #171717; cursor: pointer; font-family: inherit; text-align: left; transition: background 0.12s, transform 0.12s; }
.skill-draft-option:hover:not(:disabled), .skill-draft-option:focus-visible { background: #f7e8e4; outline: 2px solid #8e201e; outline-offset: 2px; transform: translateY(-2px); }
.skill-draft-option:disabled { opacity: 0.55; cursor: not-allowed; }
.skill-draft-icon { display: grid; width: 26px; height: 26px; place-items: center; border: 1px solid #8e201e; border-radius: 50%; color: #8e201e; font-weight: bold; }
.skill-draft-copy { display: flex; flex-direction: column; gap: 0.2rem; }
.skill-draft-copy strong { font-size: 0.68rem; }
.skill-draft-copy small { font-size: 0.57rem; line-height: 1.3; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.pp-symbol canvas { display: block; }
.pp-stats { width: 100%; display: flex; justify-content: space-between; font-size: 0.75rem; border-top: 1px dashed #000; padding-top: 0.4rem; }
.pp-stats strong { font-variant-numeric: tabular-nums; }
.pp-capacity-meter { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; width: 100%; height: 7px; }
.pp-capacity-segment { border: 1px solid var(--player-color, #171717); background: transparent; }
.pp-capacity-segment.is-filled { background: var(--player-color, #171717); }

.board-frame { position: relative; min-width: 0; border: 3px solid #000; background: #fff; box-shadow: 10px 10px 0 rgba(0,0,0,0.12); line-height: 0; flex: 0 1 auto; max-width: calc(100vw - 24px); }
#gameCanvas { display: block; width: min(800px, calc(100vw - 440px), calc(133.333vh - 240px)); height: auto; cursor: crosshair; touch-action: none; }
.hud-status { width: 100%; min-height: 1rem; text-align: right; font-size: 0.75rem; opacity: 0.8; }
.game-instruction { display: flex; align-items: flex-start; gap: 0.6rem; width: min(800px, calc(100vw - 32px)); padding: 0.6rem 0.8rem; border: 1px dashed #aaa397; background: rgba(251,250,246,0.9); font-size: 0.74rem; line-height: 1.4; }
.instruction-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: #8e201e; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.board-notice { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: clamp(0.7rem, 3vw, 1.4rem); background: rgba(23,23,23,0.46); line-height: 1.35; overflow-y: auto; }
.board-notice:not(.hidden) { animation: noticeVeil 0.22s ease-out both; }
.board-notice.is-draft #boardNoticeMessage { white-space: pre-line; }
.notice-card { width: min(680px, 100%); max-height: calc(100dvh - 2rem); overflow-y: auto; padding: clamp(0.8rem, 2vw, 1.25rem); border: 2px solid #171717; background: rgba(251,250,246,0.99); box-shadow: 7px 7px 0 rgba(23,23,23,0.8); text-align: center; pointer-events: auto; animation: noticeEnter 0.3s ease-out both; }
.notice-kicker { margin-bottom: 0.45rem; color: #8e201e; font-size: 0.68rem; font-weight: bold; letter-spacing: 0.18em; }
.notice-card h2 { margin: 0 0 0.6rem; font-size: clamp(1.15rem, 3vw, 1.7rem); letter-spacing: 0.08em; line-height: 1.2; }
.notice-card p:not(.notice-kicker) { margin: 0 auto 1rem; max-width: 34rem; font-size: clamp(0.76rem, 1.8vw, 0.9rem); }
.ready-cta { width: min(330px, 100%); min-height: 58px; border-width: 3px; font-size: clamp(0.9rem, 2.4vw, 1.1rem); letter-spacing: 0.14em; animation: readyPulse 1.8s ease-in-out infinite; }

@keyframes noticeVeil { from { opacity: 0; } to { opacity: 1; } }
@keyframes noticeEnter { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes readyPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,30,30,0.2); } 50% { box-shadow: 0 0 0 7px rgba(200,30,30,0.18); } }
@keyframes timerPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,30,30,0.12); } 50% { box-shadow: 0 0 0 4px rgba(200,30,30,0.18); } }
@keyframes placementPulse { 0%, 100% { box-shadow: 4px 4px 0 rgba(142,32,30,0.16); } 50% { box-shadow: 4px 4px 0 rgba(142,32,30,0.16), 0 0 0 4px rgba(200,30,30,0.12); } }
.base-placement-action { position: absolute; z-index: 9; max-width: calc(100% - 8px); line-height: normal; }
.base-placement-action .btn { max-width: calc(100vw - 24px); white-space: normal; box-shadow: 3px 3px 0 rgba(23,23,23,0.7); }
.measurement-tool-wrap { position: relative; }
.measurement-panel { position: fixed; top: clamp(72px, 12vh, 108px); right: 12px; z-index: 30; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 92px); overflow-y: auto; padding: 0.8rem; border: 2px solid #171717; background: rgba(251,250,246,0.98); box-shadow: 5px 5px 0 rgba(23,23,23,0.75); line-height: 1.35; pointer-events: none; }
.measurement-panel button, .measurement-panel input { pointer-events: auto; }
.measurement-panel details { pointer-events: auto; }
.measurement-readout div:first-child { border: 2px solid #8e201e; background: #fff4ed; }
.measurement-readout div:first-child dd { color: #8e201e; font-size: 0.95rem; }
.measurement-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; color: #8e201e; font-size: 0.68rem; letter-spacing: 0.08em; }
.measurement-close { width: 28px; height: 28px; border: 1px solid #171717; background: #fff; color: #171717; cursor: pointer; font-family: inherit; font-size: 1.1rem; font-weight: bold; }
.measurement-power { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.55rem 0; font-size: 0.68rem; font-weight: bold; }
.measurement-power span { display: flex; justify-content: space-between; }
.measurement-power input { width: 100%; padding: 0; accent-color: #8e201e; }
.measurement-prompt { min-height: 1.2rem; margin: 0.45rem 0; font-size: 0.68rem; }
.measurement-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem; }
.measurement-readout div { min-width: 0; padding: 0.35rem 0.45rem; border: 1px dashed #aaa397; background: #fff; }
.measurement-readout dt { color: #666; font-size: 0.58rem; font-weight: bold; text-transform: uppercase; }
.measurement-readout dd { overflow-wrap: anywhere; font-size: 0.7rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.measurement-notes, .measurement-terrain { margin-top: 0.5rem; font-size: 0.6rem; }
.measurement-formula { margin-top: 0.55rem; padding: 0.45rem 0.55rem; border: 1px solid #c9c3b7; background: #f6f2e9; font-size: 0.63rem; line-height: 1.45; }
.measurement-formula summary { color: #8e201e; cursor: pointer; font-weight: bold; }
.measurement-formula p { margin-top: 0.4rem; }
.measurement-terrain { padding-top: 0.4rem; border-top: 1px dashed #aaa397; }

/* Overlays */
.overlay { position: absolute; inset: 0; background: rgba(251,250,246,0.97); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 20; padding: 1.5rem; overflow: auto; text-align: center; }
.overlay h2 { font-size: 1.8rem; letter-spacing: 3px; margin-bottom: 0.6rem; text-transform: uppercase; }
.overlay p { margin-bottom: 1rem; font-size: 0.95rem; max-width: 560px; line-height: 1.4; }
.overlay-sub { opacity: 0.7; font-size: 0.8rem; margin-bottom: 0.5rem; }

/* Customize */
.customize-grid { display: flex; gap: 1.4rem; margin: 1rem 0 1.4rem; flex-wrap: wrap; justify-content: center; }
.custom-card { border: 2px solid #000; padding: 1rem; width: min(370px, 100%); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; background: #fff; }
.custom-card h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 1px; }
.c-name { width: 100%; text-align: center; }
.c-symbols { display: flex; gap: 0.45rem; justify-content: center; flex-wrap: wrap; }
.sym-btn { width: 38px; height: 38px; border: 2px solid #000; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.sym-btn.selected { background: #000; }
.sym-btn.selected canvas { filter: invert(1); }
.c-colors { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.color-btn { width: 28px; height: 28px; border: 2px solid #000; cursor: pointer; padding: 0; }
.color-btn.selected { outline: 2px solid #000; outline-offset: 2px; }
.c-preview { border: 2px solid #000; background: #fff; }

/* Rules */
.rules { text-align: left; max-width: 620px; margin: 0 0 1.2rem; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.85rem; line-height: 1.4; }
#help { position: fixed; inset: 0; z-index: 1100; justify-content: flex-start; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
#help h2 { flex: 0 0 auto; margin-top: 0.25rem; }
#help .quick-start { width: min(620px, 100%); flex: 0 0 auto; margin: 0 auto 1rem; padding: 0.8rem 0.9rem; border: 1px solid #c9c3b7; background: linear-gradient(135deg, #fffdf7, #f4efe4); text-align: left; }
#help .quick-start h3 { margin: 0 0 0.55rem; color: #8e201e; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
#help .quick-start ol { display: grid; gap: 0.4rem; margin: 0; padding-left: 1.2rem; font-size: 0.78rem; line-height: 1.45; }
#help .quick-start li { padding-left: 0.15rem; }
#help .quick-start p { margin: 0.6rem 0 0; color: #5d5a54; font-size: 0.7rem; line-height: 1.4; }
#help .rules { width: min(620px, 100%); flex: 0 0 auto; margin: 0 auto 1rem; }
#help #btnCloseHelp { flex: 0 0 auto; margin: 0 auto; }

@media (max-width: 980px) {
  #ui { justify-content: flex-start; overflow-y: auto; }
  #game { height: auto; min-height: calc(100dvh - 28px); flex: 0 0 auto; justify-content: flex-start; }
  .board-notice { align-items: center; overflow-y: auto; }
  .arena { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "board board" "player-one player-two"; align-items: start; gap: 8px; }
  .player-column { display: grid; flex: initial; width: 100%; grid-template-columns: minmax(0, 1fr); grid-template-areas: "modes" "skills"; }
  .player-column:first-child { grid-area: player-one; }
  .player-column:last-child { grid-area: player-two; }
  .player-panel { display: none; }
  .board-frame { grid-area: board; justify-self: center; width: auto; }
  .player-skills .focus-skill-slot:not(.match-skill-slot) { display: none; }
  .focus-skill-slot--compact { display: flex; }
  .checkpoint-mode-control { flex-direction: row; justify-content: center; gap: 0.35rem; width: 100%; }
  .checkpoint-mode-control { flex-wrap: wrap; }
  .checkpoint-mode-title { display: block; flex: 0 0 100%; color: #8e201e; font-size: 0.58rem; font-weight: bold; letter-spacing: 0.08em; line-height: 1.2; text-align: center; }
  .checkpoint-mode-button { width: 38px; height: 38px; flex-basis: 38px; }
  .checkpoint-mode-tooltip, .checkpoint-mode-control--p2 .checkpoint-mode-tooltip { position: fixed; top: 50%; right: 12px; bottom: auto; left: 12px; width: auto; max-width: 360px; transform: translateY(calc(-50% + 4px)); }
  .checkpoint-mode-button:hover .checkpoint-mode-tooltip, .checkpoint-mode-button:focus-visible .checkpoint-mode-tooltip { transform: translateY(-50%); }
  #gameCanvas { width: min(800px, calc(100vw - 40px), max(260px, calc(133.333dvh - 480px))); max-width: 100%; }
  #hud { align-items: flex-start; }
  .hud-info { width: 100%; justify-content: center; }
  .hud-actions { display: grid; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); justify-content: stretch; align-items: stretch; gap: 0.35rem; }
  .hud-actions > *, .hud-actions .measurement-tool-wrap { min-width: 0; width: 100%; }
  .hud-actions > .btn, .hud-actions .measurement-tool-wrap > .btn { min-height: 44px; justify-content: center; }
  .hud-actions .focus-skill-slot--compact .focus-skill-button { width: 100%; min-width: 0; grid-template-columns: 22px minmax(0, 1fr); }
  .hud-actions .focus-skill-slot--compact .focus-skill-status { display: none; }
  .hud-status { text-align: center; }
}

@media (max-width: 900px) {
  .menu-grid { grid-template-columns: 1fr; }
  .player-account-column { grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr); align-items: start; }
}

@media (max-width: 700px) {
  .player-account-column, .play-grid { grid-template-columns: 1fr; }
  .profile-strip { grid-template-columns: 1fr; align-items: stretch; }
  .card-copy { min-height: auto; }
}

@media (max-width: 480px) {
  #ui { padding: 8px; }
  .menu-shell { max-height: calc(100vh - 16px); padding: 1rem; box-shadow: 5px 5px 0 #171717; }
  .menu-brand { padding-bottom: 1rem; }
  .brand-stamp { width: 52px; height: 52px; border-width: 2px; font-size: 0.85rem; }
  .menu-card { padding: 0.9rem; }
  .menu-card h2 { font-size: 1.15rem; }
  .online-actions { grid-template-columns: 1fr; }
  .join-actions { flex-direction: column; }
  .join-actions .btn { width: 100%; }
  .menu-footer { align-items: flex-start; flex-direction: column; }
  .profile-summary { display: grid; grid-template-columns: 34px minmax(0, 1fr); width: 100%; }
  .profile-summary .btn { grid-column: 1 / -1; width: 100%; }
  .base-placement-panel { align-items: stretch; flex-direction: column; }
  .base-placement-countdown { align-self: flex-start; }
  .checkpoint-mode-button { width: 36px; height: 36px; flex-basis: 36px; }
  #game { gap: 6px; }
  #hud { gap: 0.4rem; }
  .hud-info { gap: 0.7rem; font-size: 0.72rem; }
  .hud-actions { gap: 0.25rem; }
  .turn-clock { gap: 0.25rem; padding: 0.25rem 0.35rem; }
  .turn-clock span { font-size: 0.5rem; }
  .hud-weather small { font-size: 0.55rem; }
  .btn.small { padding: 0.3rem 0.42rem; font-size: 0.65rem; }
  .focus-skill-button { min-height: 40px; }
  .focus-skill-icon { width: 20px; height: 20px; }
  .skill-draft-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skill-draft-option { grid-template-columns: 22px minmax(0, 1fr); gap: 0.3rem; min-height: 86px; padding: 0.35rem; }
  .skill-draft-icon { width: 21px; height: 21px; }
  #gameCanvas { width: min(800px, calc(100vw - 40px), max(250px, calc(133.333dvh - 480px))); }
  .notice-card { box-shadow: 4px 4px 0 rgba(23,23,23,0.8); }
}

/* Menu refinement: retain the ink-and-paper look while making account details legible. */
.menu-shell { width: min(1200px, 100%); padding: clamp(1.15rem, 3vw, 2.2rem); border-color: #25231f; background: #fcfbf8; box-shadow: 8px 8px 0 #25231f; }
.menu-grid { grid-template-columns: minmax(310px, 0.86fr) minmax(0, 1.55fr); gap: 1.1rem; }
.menu-brand { padding-bottom: 1.1rem; }
.brand-kicker, .card-kicker { font-size: 0.72rem; letter-spacing: 0.14em; }
.subtitle { font-size: 0.88rem; line-height: 1.5; }
.profile-strip, .account-panel, .menu-card { border-radius: 4px; }
.profile-strip { gap: 0.65rem; padding: 1rem; }
.profile-caption { font-size: 0.7rem; }
.identity-badge { font-size: 0.64rem; }
.account-panel { padding: 1rem; }
.account-intro { font-size: 0.78rem; line-height: 1.55; }
.account-footnote { font-size: 0.68rem; }
.account-controls { gap: 0.42rem; }
.account-controls { grid-template-columns: minmax(110px, 0.38fr) minmax(0, 1fr); align-items: center; }
.account-controls label { font-size: 0.74rem; }
.account-controls input { padding: 0.55rem 0.65rem; font-size: 0.82rem; }
.account-status { min-height: 1.3rem; font-size: 0.72rem; }
.account-stats { gap: 0.4rem; margin-top: 0.85rem; }
.account-stats > div { gap: 0.2rem; padding: 0.5rem; }
.account-stats span { font-size: 0.62rem; letter-spacing: 0.08em; }
.account-stats strong { font-size: 1rem; }
.account-history { margin-top: 0.85rem; }
.account-history-heading strong { font-size: 0.68rem; }
.account-history-heading span { font-size: 0.63rem; }
.account-history ol { gap: 0.25rem; margin-top: 0.4rem; }
.account-history-item { grid-template-columns: 3.6rem minmax(0, 1fr) auto; gap: 0.45rem; padding: 0.38rem 0.45rem; }
.account-history-item strong, .account-history-item span, .account-history-item time { font-size: 0.65rem; }
.account-history-empty { font-size: 0.7rem; }
.menu-card { padding: clamp(1rem, 2vw, 1.4rem); }
.menu-card h2 { font-size: clamp(1.2rem, 1.8vw, 1.55rem); }
.card-copy { font-size: 0.86rem; }
.bot-note { font-size: 0.76rem; }
.menu-footer { margin-top: 1.1rem; }

@media (max-width: 980px) {
  .menu-grid { grid-template-columns: 1fr; }
  .player-account-column { grid-template-columns: minmax(230px, 0.78fr) minmax(0, 1.22fr); align-items: stretch; }
  .play-grid { grid-template-columns: minmax(0, 1.2fr) minmax(230px, 0.8fr); }
}

@media (max-width: 700px) {
  .player-account-column, .play-grid { grid-template-columns: 1fr; }
  .account-controls { grid-template-columns: 1fr; align-items: stretch; }
}

@media (max-width: 480px) {
  .menu-shell { padding: 1rem; }
  .account-stats span { font-size: 0.56rem; }
  .account-history-item { grid-template-columns: 3.1rem minmax(0, 1fr); }
  .account-history-item time { display: none; }
}

/* Keep the menu actions in view; account and lifetime stats live in focused dialogs. */
#ui.menu-view { justify-content: center; overflow: hidden; }
.menu-shell { display: flex; height: min(700px, calc(100dvh - 28px)); max-height: calc(100dvh - 28px); flex-direction: column; overflow: hidden; }
.menu-grid { flex: 1 1 auto; min-height: 0; grid-template-columns: minmax(250px, 0.72fr) minmax(0, 1.55fr); align-items: center; }
.player-account-column { display: block; }
.profile-menu-actions { display: flex; gap: 0.5rem; margin-top: 0.65rem; }
.profile-menu-actions .btn { flex: 1; }
.play-grid { grid-template-columns: minmax(0, 1.2fr) minmax(190px, 0.8fr); }
.menu-card { height: 100%; }
.menu-footer { flex: 0 0 auto; margin-top: 0.55rem; }
.menu-shell > .status { flex: 0 0 auto; min-height: 0; margin-top: 0.25rem; }

.popup-overlay { position: fixed; z-index: 1000; padding: 1rem; background: rgba(23, 23, 23, 0.56); backdrop-filter: blur(3px); }
.popup-card { position: relative; width: min(590px, 100%); max-height: min(88dvh, 760px); overflow-y: auto; padding: 1.35rem; border: 2px solid #171717; border-radius: 5px; background: #fcfbf8; box-shadow: 8px 8px 0 rgba(23, 23, 23, 0.7); text-align: left; }
.popup-card.account-panel { height: min(600px, calc(100dvh - 2rem)); min-height: min(440px, calc(100dvh - 2rem)); margin: 0; }
.popup-card.stats-card { display: block; height: min(600px, calc(100dvh - 2rem)); min-height: min(440px, calc(100dvh - 2rem)); }
.reset-password-card { display: grid; gap: 0.55rem; }
.reset-password-card p { margin: 0; }
.reset-password-card label { font-size: 0.78rem; font-weight: bold; }
.reset-password-card .account-status { min-height: 1.2rem; }
.popup-card .account-panel-heading { padding-right: 2.2rem; }
.popup-card .account-panel-heading h2, .popup-card > h2 { margin: 0.2rem 0 0.5rem; font-size: 1.4rem; letter-spacing: 0.02em; text-transform: none; }
.popup-close { position: absolute; top: 0.7rem; right: 0.7rem; width: 36px; height: 36px; padding: 0; font-size: 1.4rem !important; line-height: 1; }
.stats-card .account-stats { margin-top: 1rem; }
.stats-card .account-stats span { font-size: 0.68rem; }
.stats-card .account-stats strong { font-size: 1.25rem; }
.stats-card .account-history-item strong, .stats-card .account-history-item span, .stats-card .account-history-item time { font-size: 0.75rem; }
.stats-leaderboard { margin-top: 1rem; padding: 0.85rem; border: 1px dashed #c9c3b7; background: linear-gradient(135deg, #f8f4eb, #f1eadc); }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; }
.leaderboard-heading h3 { color: #8e201e; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; }
.leaderboard-heading p { margin: 0.3rem 0 0; color: #5d5a54; font-size: 0.72rem; line-height: 1.4; }
.leaderboard-heading .btn { width: 36px; min-width: 36px; height: 36px; padding: 0; font-size: 1.1rem; }
.leaderboard-list { display: grid; gap: 0.3rem; max-height: 260px; margin-top: 0.7rem; overflow-y: auto; list-style: none; }
.leaderboard-item { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: 0.55rem; min-width: 0; padding: 0.42rem 0.55rem; border: 1px solid #e3ddcf; background: rgba(255,255,255,0.76); }
.leaderboard-item.is-top-1 { border-color: #c79b3b; background: #fff8e7; }
.leaderboard-item.is-top-2 { border-color: #9b9b96; }
.leaderboard-item.is-top-3 { border-color: #ae7652; }
.leaderboard-rank { color: #8e201e; font-size: 0.72rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.leaderboard-player { display: grid; min-width: 0; gap: 0.08rem; }
.leaderboard-player strong { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-player small { color: #716d65; font-size: 0.64rem; }
.leaderboard-wins { min-width: 2.2rem; color: #8e201e; font-size: 0.74rem; text-align: right; }
.leaderboard-empty { padding: 0.75rem 0.5rem; color: #716d65; font-size: 0.72rem; text-align: center; }
.leaderboard-status { min-height: 1em; margin: 0.4rem 0 0 !important; color: #716d65; font-size: 0.62rem !important; }

@media (max-width: 980px) {
  #ui.menu-view { justify-content: center; overflow: hidden; }
  .menu-grid { grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr); }
  .player-account-column { display: block; }
  .play-grid { grid-template-columns: minmax(0, 1.15fr) minmax(175px, 0.85fr); }
}

@media (max-width: 700px) {
  .menu-shell { height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); padding: 0.85rem; box-shadow: 5px 5px 0 #25231f; }
  .menu-brand { padding-bottom: 0.55rem; }
  .menu-brand h1 { font-size: clamp(2rem, 8vw, 2.7rem); }
  .subtitle { font-size: 0.72rem; }
  .menu-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); align-items: stretch; gap: 0.5rem; margin-top: 0.55rem; }
  .profile-strip { gap: 0.3rem; padding: 0.55rem; }
  .profile-strip .field-label { margin: 0; }
  .profile-strip input { padding: 0.4rem 0.5rem; }
  .profile-strip > .btn { padding: 0.42rem; }
  .profile-menu-actions { margin-top: 0.35rem; }
  .profile-menu-actions .btn { padding: 0.38rem; }
  .play-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 0.45rem; }
  .menu-card { min-width: 0; padding: 0.65rem; }
  .menu-card h2 { font-size: 1rem; }
  .card-copy, .bot-note { display: none; }
  .online-actions { grid-template-columns: 1fr; gap: 0.35rem; margin: 0.45rem 0; }
  .join-room { padding-top: 0.4rem; }
  .join-actions { flex-direction: column; gap: 0.35rem; }
  .join-actions .btn { width: 100%; }
  .bot-start { margin-top: 0.5rem; }
  .menu-footer { margin-top: 0.35rem; }
  .menu-footer .btn { padding: 0.42rem 0.55rem; }
}

@media (max-height: 680px) {
  .menu-shell { height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); padding-top: 0.75rem; padding-bottom: 0.65rem; }
  .menu-brand { padding-bottom: 0.55rem; }
  .menu-brand h1 { font-size: clamp(2rem, 6vh, 3rem); }
  .menu-grid { margin-top: 0.55rem; gap: 0.6rem; }
  .profile-strip { gap: 0.35rem; padding: 0.55rem; }
  .menu-card { padding: 0.8rem; }
  .menu-footer { margin-top: 0.35rem; }
}

.player-account-column { display: flex; height: 100%; flex-direction: column; gap: 0.65rem; }
.player-account-column .profile-strip { flex: 1 1 auto; align-content: center; }
.profile-summary { flex-wrap: wrap; }
.profile-detail { flex: 1 1 120px; }
.profile-menu-actions { flex: 0 0 auto; margin-top: auto; }
.profile-menu-actions .btn { min-width: 0; justify-content: center; }
.account-panel-heading { justify-content: flex-start; gap: 0.75rem; }
.account-panel-heading > div { min-width: 0; }
.account-mark { width: 42px; height: 42px; }
.account-mark svg { width: 24px; height: 24px; }
.account-panel .identity-badge { margin: 0.25rem 0 0.45rem; }
.popup-close { display: grid; place-items: center; border-style: solid !important; font-family: Arial, sans-serif !important; font-size: 1.55rem !important; font-weight: 400; }

@media (max-width: 700px) {
  .player-account-column { height: auto; gap: 0.35rem; }
  .player-account-column .profile-strip { flex: initial; }
  .profile-menu-actions { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .board-notice:not(.hidden), .notice-card, .ready-cta, .turn-clock.urgent, .base-placement-panel { animation: none !important; }
}

/* Balance the profile column with the play cards on the desktop menu. */
@media (min-width: 781px) {
  .menu-grid { align-items: stretch; grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.8fr); }
  .player-account-column { display: flex; height: auto; min-height: 100%; flex-direction: column; }
  .player-account-column .profile-strip { flex: 1 1 auto; align-content: center; gap: 0.8rem; padding: clamp(1rem, 2vw, 1.35rem); }
  .profile-summary { flex-wrap: nowrap; }
  .profile-detail { flex-basis: auto; }
  .profile-menu-actions { margin-top: 0; }
  .play-grid { align-items: stretch; }
  .menu-card { min-height: 300px; justify-content: center; }
}

@media (max-width: 780px) and (min-width: 701px) {
  .menu-grid { grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr); }
  .play-grid { grid-template-columns: minmax(0, 1.15fr) minmax(175px, 0.85fr); }
}

@media (max-width: 700px) {
  .profile-menu-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .profile-menu-actions .btn { min-height: 42px; }
}

/* Compact battle layout for short landscape touch screens. */
@media (max-width: 980px) and (orientation: landscape) and (max-height: 540px) {
  #ui:not(.menu-view) { justify-content: flex-start; overflow: hidden; padding: 6px 10px; }
  #game { height: 100%; min-height: 0; flex: 1 1 auto; justify-content: flex-start; gap: 4px; overflow: hidden; }
  #hud { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 2px 8px; flex: 0 0 auto; }
  .hud-info { grid-column: 1; grid-row: 1; min-width: 0; width: auto; flex-wrap: nowrap; justify-content: flex-start; gap: 0.5rem; font-size: 0.68rem; }
  .hud-weather { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 0.25rem; padding: 0.15rem 0.3rem; }
  .hud-weather-label { font-size: 0.52rem; }
  .hud-weather small { display: none; }
  .wind-info-icon { width: 14px; height: 14px; }
  .hud-actions { display: flex; grid-column: 2; grid-row: 1; width: auto; max-width: 100%; flex-wrap: nowrap; justify-content: flex-end; gap: 5px; }
  .hud-actions > *, .hud-actions .measurement-tool-wrap { min-width: 0; width: auto; }
  .hud-actions > .btn { display: inline-flex; flex: 0 0 40px; width: 40px; min-width: 40px; height: 40px; min-height: 40px; justify-content: center; padding: 0.3rem; }
  .hud-actions > #btnReady { flex: 0 0 auto; width: auto; min-width: 40px; padding-inline: 0.45rem; }
  .hud-actions .measurement-tool-wrap { flex: 0 0 auto; }
  .hud-actions .measurement-tool-wrap > .btn { display: inline-flex; width: auto; min-width: 70px; height: 40px; min-height: 40px; justify-content: center; padding: 0.3rem 0.45rem; }
  .hud-actions > .btn .button-label, .hud-actions .measurement-tool-wrap > .btn .button-label,
  .player-skills .focus-skill-copy, .player-skills .focus-skill-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .hud-actions .measurement-tool-wrap > .btn .button-label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: nowrap; }
  .hud-actions .turn-clock { min-height: 42px; }
  .hud-actions .focus-skill-slot--compact { display: none; }
  .hud-status { grid-column: 1 / -1; grid-row: 2; min-height: 0.75rem; overflow: hidden; font-size: 0.6rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  .arena { display: grid; flex: 1 1 auto; grid-template-columns: minmax(76px, 0.75fr) minmax(0, 4fr) minmax(76px, 0.75fr); grid-template-areas: "player-one board player-two"; align-items: center; gap: 6px; min-height: 0; overflow: hidden; }
  .player-column { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr); grid-template-areas: "modes" "skills"; align-self: center; gap: 0.35rem; }
  .player-column:first-child, .player-column:last-child { grid-area: auto; }
  .checkpoint-mode-control { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  .checkpoint-mode-title { display: block; grid-column: 1 / -1; font-size: 0.46rem; }
  .checkpoint-mode-button { width: 100%; height: 42px; min-width: 0; }
  .checkpoint-mode-tooltip, .checkpoint-mode-control--p2 .checkpoint-mode-tooltip { display: none; }
  .player-skills { padding: 0.25rem; }
  .player-skills-title { display: block; margin: 0 0 0.2rem; font-size: 0.48rem; text-align: center; }
  .player-skill-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
  .player-skills .focus-skill-slot:not(.match-skill-slot) { display: flex; }
  .player-skills .focus-skill-button { display: flex; width: 42px; min-width: 42px; height: 42px; min-height: 42px; justify-content: center; padding: 0.25rem; }
  .player-skills .focus-skill-button:disabled:not(.armed) { border-color: #b8b1a6; background: #f1eee5; color: #736f68; opacity: 1; }
  .player-skills .focus-skill-button:disabled:not(.armed) .focus-skill-icon,
  .player-skills .focus-skill-button:disabled:not(.armed) .match-skill-symbol { border-color: #817d75; color: #817d75; stroke: #817d75; }
  .checkpoint-mode-button:disabled:not(.selected) { background: #f1eee5; color: #736f68; opacity: 0.86; }
  .player-skills .focus-skill-icon { width: 23px; height: 23px; }
  .board-frame { width: min(100%, calc(100vw - 190px), calc((100dvh - 88px) * 1.333333)); max-width: 100%; justify-self: center; }
  #gameCanvas { width: 100%; max-width: 100%; height: auto; }
  #game .game-instruction { display: none; }
  .base-placement-panel { top: 58px; width: min(560px, calc(100vw - 24px)); padding: 0.4rem 0.55rem; }
  .base-placement-panel p { font-size: 0.67rem; }
  .board-notice { padding: 0.5rem; overflow-y: auto; }
  .notice-card { width: min(620px, 100%); max-height: 100%; overflow-y: auto; padding: 0.65rem; }
  .notice-card h2 { margin: 0.2rem 0; font-size: 1rem; }
  .notice-card p { margin: 0.2rem 0; font-size: 0.68rem; }
  .skill-draft-options { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.25rem; margin: 0.35rem 0; }
  .skill-draft-option { min-height: 54px; padding: 0.25rem; }
}

@media (hover: none) and (pointer: coarse) {
  .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
  #playerSkillsP1 .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
  #playerSkillsP2 .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
  .checkpoint-mode-button:hover .checkpoint-mode-tooltip:not(.touch-tooltip-open) { opacity: 0; visibility: hidden; }
}
.touch-tooltip-modality .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality .focus-skill-button:focus-visible + .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality #playerSkillsP1 .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality #playerSkillsP1 .focus-skill-button:focus-visible + .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality #playerSkillsP2 .focus-skill-slot:hover .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality #playerSkillsP2 .focus-skill-button:focus-visible + .focus-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality .checkpoint-mode-button:hover .checkpoint-mode-tooltip:not(.touch-tooltip-open),
.touch-tooltip-modality .checkpoint-mode-button:focus-visible .checkpoint-mode-tooltip:not(.touch-tooltip-open) { opacity: 0; visibility: hidden; }
.focus-tooltip.touch-tooltip-open, .checkpoint-mode-tooltip.touch-tooltip-open {
  position: fixed !important;
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 50% !important;
  z-index: 1500 !important;
  display: block !important;
  width: min(340px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
  max-height: min(62dvh, 420px);
  overflow-y: auto;
  padding: 0.9rem 1rem;
  border: 2px solid #c85649;
  background: #171717;
  box-shadow: 0 12px 38px rgba(0,0,0,0.42);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.55;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transform: translate(-50%, -50%) !important;
  transition: opacity 0.1s ease, visibility 0.1s ease;
}

@media (max-width: 980px) and (orientation: landscape) and (max-height: 380px) {
  #ui:not(.menu-view) { padding-top: 3px; padding-bottom: 3px; }
  #game { gap: 2px; }
  #hud { gap: 1px 5px; }
  .hud-info { gap: 0.3rem; font-size: 0.6rem; }
  .hud-actions { gap: 3px; }
  .hud-actions > .btn { flex-basis: 36px; width: 36px; min-width: 36px; height: 36px; min-height: 36px; }
  .hud-actions .measurement-tool-wrap > .btn { min-width: 64px; height: 36px; min-height: 36px; }
  .hud-actions .turn-clock { min-height: 38px; padding: 0.2rem; }
  .arena { grid-template-columns: minmax(64px, 0.7fr) minmax(0, 4fr) minmax(64px, 0.7fr); gap: 4px; }
  .checkpoint-mode-button, .player-skills .focus-skill-button { height: 38px; min-height: 38px; }
  .player-skills .focus-skill-button { width: 38px; min-width: 38px; }
  .board-frame { width: min(100%, calc(100vw - 180px), calc((100dvh - 96px) * 1.333333)); }
}

@media (max-width: 650px) and (orientation: landscape) and (max-height: 540px) {
  .hud-room { display: none; }
  .hud-info { gap: 0.3rem; font-size: 0.62rem; }
}

@media (max-width: 700px) {
  #ui.menu-view { align-items: stretch; justify-content: flex-start; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; padding: 8px; }
  .menu-shell { width: 100%; height: auto; min-height: calc(100dvh - 16px); max-height: none; flex: 0 0 auto; overflow: visible; }
  .menu-grid { min-height: 0; flex: 0 0 auto; grid-template-rows: auto auto; align-items: start; }
  .player-account-column { height: auto; }
  .play-grid { grid-template-columns: minmax(0, 1fr); }
  .menu-card { height: auto; min-height: 0; }
  .menu-footer { flex-direction: row; flex-wrap: wrap; align-items: center; }
}

@media (max-width: 980px) {
  #btnReady { display: none !important; }
}


/* Menu profile summary and compact touch layouts. */
.profile-overview-stats { display: grid; grid-template-columns: minmax(0, 1.15fr) auto minmax(0, 1fr); gap: 0.45rem; }
.profile-overview-stats > div { display: flex; min-width: 0; flex-direction: column; gap: 0.2rem; padding: 0.5rem 0.6rem; border: 1px dashed #b8afa0; background: rgba(255,255,255,0.72); }
.profile-overview-stats span { color: #8e201e; font-size: 0.57rem; font-weight: bold; letter-spacing: 0.09em; }
.profile-overview-stats strong { overflow: hidden; font-size: 0.95rem; text-overflow: ellipsis; white-space: nowrap; }
.friends-panel { min-width: 0; padding: 0.8rem; border: 1px dashed #aaa294; background: rgba(255,255,255,0.72); }
.friends-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.friends-heading h2 { color: #8e201e; font-size: 0.72rem; letter-spacing: 0.12em; }
.friends-coming-soon { padding: 0.15rem 0.35rem; border: 1px solid #aaa294; color: #716d65; font-size: 0.52rem; font-weight: bold; letter-spacing: 0.08em; }
.friends-empty { margin-top: 0.5rem; color: #716d65; font-size: 0.66rem; line-height: 1.45; }
.nickname-card { position: relative; width: min(420px, 100%); }
.nickname-card > label { display: block; margin: 0.9rem 0 0.35rem; font-size: 0.7rem; font-weight: bold; }
.nickname-card > input { width: 100%; }
.nickname-card .name-input-row { display: flex; gap: 0.4rem; align-items: center; }
.nickname-card .name-input-row input { flex: 1; min-width: 0; }
.nickname-card .name-input-row .icon-btn { flex-shrink: 0; font-size: 1.2rem; padding: 0.4rem 0.6rem; line-height: 1; }
.nickname-card .name-hint { font-size: 0.68rem; color: var(--muted, #888); margin: 0.3rem 0 0; }
.nickname-card .row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
.nickname-card .row .btn { flex: 1 1 130px; }

@media (max-width: 980px) and (orientation: landscape) and (max-height: 540px) {
  #ui.menu-view { align-items: stretch; justify-content: flex-start; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; padding: 6px 10px; }
  .menu-shell { width: 100%; height: auto; min-height: calc(100dvh - 12px); max-height: none; flex: 0 0 auto; overflow: visible; padding: 0.7rem 0.85rem; box-shadow: 4px 4px 0 #25231f; }
  .menu-brand { padding-bottom: 0.45rem; }
  .brand-kicker, .subtitle, .brand-stamp { display: none; }
  .menu-brand h1 { margin: 0; font-size: clamp(1.5rem, 5vw, 2.1rem); }
  .menu-grid { grid-template-columns: minmax(210px, 0.8fr) minmax(0, 1.5fr); align-items: stretch; gap: 0.55rem; margin-top: 0.55rem; }
  .player-account-column { display: grid; height: auto; grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .profile-strip { align-content: start; gap: 0.4rem; padding: 0.55rem; }
  .profile-summary { gap: 0.4rem; }
  .profile-mark { width: 28px; height: 28px; }
  .profile-detail { font-size: 0.7rem; }
  .profile-caption { font-size: 0.52rem; }
  .profile-strip > .btn { min-height: 36px; padding: 0.35rem; }
  .profile-overview-stats > div { padding: 0.35rem; }
  .profile-overview-stats span { font-size: 0.48rem; }
  .profile-overview-stats strong { font-size: 0.78rem; }
  .friends-panel { padding: 0.5rem; }
  .friends-empty { margin-top: 0.25rem; font-size: 0.58rem; }
  .profile-menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; margin: 0; }
  .profile-menu-actions .btn { min-height: 36px; padding: 0.3rem; font-size: 0.6rem; }
  .play-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .menu-card { height: auto; min-height: 0; padding: 0.7rem; }
  .menu-card h2 { margin: 0.25rem 0; font-size: 1rem; }
  .menu-card .card-copy, .bot-note { display: none; }
  .online-actions { margin-top: 0.45rem; }
  .join-room { margin-top: 0.45rem; }
}

@media (max-width: 980px) {
  .measurement-tool-wrap { display: none !important; }
}

@media (max-width: 980px) {
  .brand-kicker, .subtitle, .brand-stamp { display: none; }
  .menu-brand { padding-bottom: 0.55rem; }
  .menu-brand h1 { margin: 0; font-size: clamp(1.7rem, 6vw, 2.5rem); }
}


.menu-header-actions { display: flex; align-items: center; gap: 0.4rem; }
.friends-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.friends-panel > .btn { width: 100%; min-width: 0; }
.friends-count, .rank-level-badge { min-width: 1.5rem; padding: 0.12rem 0.3rem; border: 1px solid #8e201e; color: #8e201e; font-size: 0.62rem; font-weight: bold; text-align: center; font-variant-numeric: tabular-nums; }
.friends-popup-card { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 0.65rem; width: min(650px, 100%); height: min(600px, calc(100dvh - 2rem)); min-height: min(440px, calc(100dvh - 2rem)); overflow: hidden; }
.friends-popup-card > h2 { margin: -0.25rem 0 0.15rem; font-size: 1.45rem; }
#friendsContent { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 0.55rem; min-height: 0; }
.friends-tab-panel { min-height: 0; overflow-y: auto; align-content: start; overscroll-behavior: contain; }
.friends-guest-gate { display: grid; gap: 0.8rem; padding: 1rem; border: 1px dashed #b8afa0; background: #f6f2e9; }
.friends-guest-gate p, .friends-status { color: #5d5a54; font-size: 0.75rem; line-height: 1.5; }
.friends-search-form { display: grid; gap: 0.35rem; }
.friends-search-form label { font-size: 0.7rem; font-weight: bold; }
.friends-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem; }
.friends-search-row input { min-width: 0; }
.friends-search-row .btn { min-width: 76px; }
.friends-status { min-height: 1em; margin: 0 !important; }
.friends-section { display: grid; gap: 0.35rem; }
.friends-section h3, .friends-outgoing summary { color: #8e201e; font-size: 0.65rem; font-weight: bold; letter-spacing: 0.08em; }
.friends-section h3 span, .friends-outgoing summary span { color: #171717; }
.friends-list { display: grid; gap: 0.3rem; max-height: 150px; overflow-y: auto; list-style: none; }
.friends-row { display: flex; align-items: center; justify-content: space-between; gap: 0.55rem; min-width: 0; padding: 0.4rem 0.5rem; border: 1px solid #e1dbd0; background: #fff; }
.friends-row-identity { display: grid; min-width: 0; gap: 0.12rem; }
.friends-row-identity strong { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.friends-row-identity small, .friends-relation { color: #716d65; font-size: 0.61rem; }
.friends-row-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 0.3rem; }
.friends-row-actions .btn { min-height: 34px; padding: 0.28rem 0.42rem; font-size: 0.58rem; }
.friends-list-empty { padding: 0.45rem; color: #716d65; font-size: 0.67rem; text-align: center; }
.friends-outgoing { padding-top: 0.35rem; border-top: 1px dashed #c9c3b7; }
.friends-outgoing summary { cursor: pointer; }
.friends-outgoing .friends-list { margin-top: 0.4rem; }

@media (max-width: 980px) {
  .menu-brand { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
  .menu-brand > div:first-child { min-width: 0; }
  .menu-header-actions { flex: 0 0 auto; gap: 0.3rem; }
  .menu-header-actions .btn { display: grid; width: 40px; min-width: 40px; height: 40px; min-height: 40px; place-items: center; padding: 0; }
  .menu-header-actions .button-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .menu-header-actions .btn-icon { width: 19px; height: 19px; }
  .friends-popup-card { height: min(640px, calc(100dvh - 1.25rem)); min-height: min(400px, calc(100dvh - 1.25rem)); max-height: none; padding: 0.9rem; }
  .friends-list { max-height: 110px; }
}
@media (max-width: 700px) {
  .menu-header-actions .btn { width: 36px; min-width: 36px; height: 36px; min-height: 36px; }
  .menu-header-actions .btn-icon { width: 17px; height: 17px; }
  .friends-row { align-items: flex-start; flex-direction: column; }
  .friends-popup-card { grid-template-rows: auto auto minmax(0, 1fr); }
  .friends-row-actions { width: 100%; justify-content: flex-start; }
  .friends-row-actions .btn { flex: 1 1 auto; }
}


.friends-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.28rem; padding-bottom: 0.4rem; border-bottom: 1px solid #c9c3b7; }
.friends-tab { display: flex; min-width: 0; min-height: 42px; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.35rem 0.25rem; border: 1px solid transparent; background: transparent; color: #5d5a54; font: inherit; font-size: 0.68rem; font-weight: bold; letter-spacing: 0.04em; cursor: pointer; }
.friends-tab:hover { border-color: #c9c3b7; background: #f6f2e9; }
.friends-tab.is-active { border-color: #8e201e; background: #8e201e; color: #fff; }
.friends-tab:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.friends-tab-count { display: inline-grid; min-width: 1.25rem; height: 1.25rem; place-items: center; padding: 0 0.18rem; border: 1px solid currentColor; border-radius: 99px; font-size: 0.6rem; font-variant-numeric: tabular-nums; }
.friends-tab-panel { display: grid; gap: 0.7rem; min-height: 100px; }
.friends-tab-panel[hidden] { display: none !important; }
.friends-panel > .friends-empty { margin-top: 0; }
.friends-popup-card > .card-kicker { padding-right: 2.4rem; }
@media (max-width: 700px) {
  .friends-popup-card { gap: 0.5rem; }
  .friends-tabs { gap: 0.15rem; }
  .friends-tab { min-height: 40px; gap: 0.2rem; padding-inline: 0.1rem; font-size: 0.59rem; letter-spacing: 0; }
  .friends-tab-count { min-width: 1.1rem; height: 1.1rem; font-size: 0.55rem; }
}

.friends-recent { padding-top: 0.35rem; border-top: 1px dashed #c9c3b7; }
.friends-recent summary { color: #8e201e; font-size: 0.65rem; font-weight: bold; letter-spacing: 0.08em; cursor: pointer; }
.friends-recent summary span { color: #171717; }
.friends-recent .friends-list { margin-top: 0.4rem; }
.friends-row-identity small.is-online { color: #0f766e; font-weight: bold; }

.room-invite-section { display: grid; gap: 0.35rem; max-width: 34rem; margin: 0 auto 0.8rem; padding: 0.55rem; border: 1px dashed #b8afa0; background: #fff; text-align: left; }
.room-invite-section h3 { margin: 0; color: #8e201e; font-size: 0.63rem; letter-spacing: 0.08em; }
.room-invite-section .friends-list { max-height: 130px; }
.room-invite-section .friends-row { padding: 0.3rem 0.4rem; }
.room-invite-section .friends-row-actions .btn { min-height: 32px; }
@media (max-width: 700px) {
  .popup-card.account-panel, .popup-card.stats-card { height: min(640px, calc(100dvh - 1.25rem)); min-height: min(400px, calc(100dvh - 1.25rem)); }
}

.board-notice.is-room-created .notice-card { min-height: min(400px, calc(100dvh - 3rem)); }

.room-copy-button { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0 auto 0.75rem; }

.skill-draft-countdown { display: inline-block; margin: -0.45rem auto 0.55rem; padding: 0.28rem 0.55rem; border: 1px solid #8e201e; background: #fff4ed; color: #8e201e; font-size: 0.7rem; font-weight: bold; font-variant-numeric: tabular-nums; letter-spacing: 0.08em; }
.friend-invite-notice { position: relative; animation: friendInvitePulse 1.15s ease-in-out infinite; }
.friend-invite-count { position: absolute; top: -0.42rem; right: -0.42rem; display: grid; min-width: 1.15rem; height: 1.15rem; place-items: center; padding: 0 0.2rem; border: 2px solid #fcfbf8; border-radius: 999px; background: #c81e1e; color: #fff; font-size: 0.62rem; font-weight: bold; line-height: 1; }
@keyframes friendInvitePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,30,30,0.35); } 50% { box-shadow: 0 0 0 6px rgba(200,30,30,0.08); } }
@media (prefers-reduced-motion: reduce) { .friend-invite-notice { animation: none; } }
@media (max-width: 980px) { .friend-invite-notice .friend-invite-count { top: -0.38rem; right: -0.38rem; } }

/* Rank, Level & Leaderboard popup */
.rank-popup-card { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); gap: 0.6rem; width: min(650px, 100%); height: min(620px, calc(100dvh - 2rem)); min-height: min(440px, calc(100dvh - 2rem)); overflow: hidden; }
.rank-popup-card > .card-kicker { padding-right: 2.4rem; }
.rank-popup-card > h2 { margin: -0.25rem 0 0.1rem; font-size: 1.45rem; }
.rank-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.28rem; padding-bottom: 0.4rem; border-bottom: 1px solid #c9c3b7; }
.rank-tab { display: flex; min-width: 0; min-height: 42px; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.35rem 0.4rem; border: 1px solid transparent; background: transparent; color: #5d5a54; font: inherit; font-size: 0.68rem; font-weight: bold; letter-spacing: 0.04em; cursor: pointer; }
.rank-tab:hover { border-color: #c9c3b7; background: #f6f2e9; }
.rank-tab.is-active { border-color: #8e201e; background: #8e201e; color: #fff; }
.rank-tab:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.rank-tab-panel { display: grid; gap: 0.75rem; min-height: 0; overflow-y: auto; align-content: start; overscroll-behavior: contain; }
.rank-tab-panel[hidden] { display: none !important; }
.progression-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.progression-card { display: grid; gap: 0.45rem; padding: 0.75rem; border: 1px solid #c9c3b7; background: #fff; text-align: left; }
.progression-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.progression-card-head > div { display: grid; gap: 0.1rem; min-width: 0; }
.progression-kicker { color: #8e201e; font-size: 0.58rem; font-weight: bold; letter-spacing: 0.1em; }
.progression-main { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progression-pill { display: inline-grid; min-width: 2.3rem; height: 1.75rem; place-items: center; padding: 0 0.45rem; border: 2px solid #171717; background: #f6f2e9; color: #171717; font-size: 0.74rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.progression-bar { position: relative; width: 100%; height: 9px; border: 1px solid #171717; background: #f2ede2; overflow: hidden; }
.progression-bar-fill { display: block; height: 100%; width: 0%; background: #8e201e; transition: width 0.25s ease; }
.progression-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem; font-size: 0.68rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.progression-rule { margin: 0; color: #716d65; font-size: 0.62rem; line-height: 1.35; }
.rank-tiers-section { display: grid; gap: 0.45rem; text-align: left; }
.rank-tiers-section h3 { margin: 0; color: #8e201e; font-size: 0.66rem; font-weight: bold; letter-spacing: 0.08em; }
.rank-tiers-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.rank-tier-item { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "badge name" "badge threshold"; align-items: center; column-gap: 0.45rem; row-gap: 0.05rem; padding: 0.45rem 0.55rem; border: 1px solid #d8d1c4; background: #fff; }
.rank-tier-item.is-current { border: 2px solid var(--tier-color, #8e201e); background: #fff9f2; box-shadow: 2px 2px 0 rgba(23,23,23,0.14); }
.rank-tier-badge { grid-area: badge; display: grid; width: 26px; height: 26px; place-items: center; border: 1.5px solid var(--tier-color, #171717); color: var(--tier-color, #171717); font-size: 0.66rem; font-weight: bold; }
.rank-tier-item strong { grid-area: name; font-size: 0.72rem; color: var(--tier-color, #171717); }
.rank-tier-item small { grid-area: threshold; font-size: 0.6rem; color: #716d65; font-variant-numeric: tabular-nums; }
.rank-tab-panel .stats-leaderboard { margin-top: 0; border-top: 0; padding-top: 0; }
.post-match-rewards { display: grid; gap: 0.55rem; width: min(460px, 100%); margin: 0 0 1rem; padding: 0.7rem 0.85rem; border: 1.5px solid #171717; background: #fff; box-shadow: 3px 3px 0 rgba(23,23,23,0.14); text-align: center; }
.reward-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.35rem; }
.reward-pill { padding: 0.2rem 0.5rem; border: 1px solid #171717; background: #f6f2e9; font-size: 0.68rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.reward-pill.is-xp { border-color: #1d4ed8; color: #1d4ed8; background: #eff6ff; }
.reward-pill.is-rp-up { border-color: #0f766e; color: #0f766e; background: #f0fdfa; }
.reward-pill.is-rp-down { border-color: #8e201e; color: #8e201e; background: #fef2f2; }
.reward-pill.is-bonus, .reward-pill.is-promo { border-color: #b45309; color: #b45309; background: #fffbeb; }
.reward-pill.is-shield { border-color: #5b6770; color: #374151; background: #f3f4f6; }
.reward-progress-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem; padding-top: 0.45rem; border-top: 1px dashed #c9c3b7; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.room-preset-popup-card { width: min(460px, 100%); }
.room-preset-options { display: grid; gap: 0.45rem; margin: 0.35rem 0 0.9rem; }
.room-preset-option { display: grid; gap: 0.15rem; padding: 0.65rem 0.75rem; border: 1.5px solid #c9c3b7; background: #fff; color: #171717; text-align: left; font: inherit; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.room-preset-option:hover { border-color: #171717; background: #f6f2e9; }
.room-preset-option.is-selected { border: 2px solid #8e201e; background: #fff9f2; box-shadow: 3px 3px 0 rgba(142,32,30,0.16); }
.room-preset-option strong { font-size: 0.85rem; }
.room-preset-option small { color: #5d5a54; font-size: 0.68rem; line-height: 1.35; }
.room-preset-popup-card .row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.room-preset-popup-card .row .btn { flex: 1 1 130px; }
.pp-rank { width: 100%; font-size: 0.62rem; font-weight: bold; color: #5d5a54; text-align: left; }
.rank-quests-section, .rank-achievements-section { display: grid; gap: 0.45rem; text-align: left; }
.rank-quests-section h3, .rank-achievements-section h3 { margin: 0; color: #8e201e; font-size: 0.66rem; font-weight: bold; letter-spacing: 0.08em; }
.quests-list, .achievements-list { display: grid; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.quest-item { display: grid; gap: 0.2rem; padding: 0.55rem 0.65rem; border: 1px solid #d8d1c4; background: #fff; }
.quest-item.is-done { border-color: #0f766e; background: #f0fdfa; }
.quest-head { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; font-size: 0.76rem; }
.quest-reward { padding: 0.12rem 0.4rem; border: 1px solid currentColor; font-size: 0.6rem; font-weight: bold; color: #1d4ed8; }
.quest-item.is-done .quest-reward { color: #0f766e; }
.quest-item small { color: #5d5a54; font-size: 0.66rem; }
.quest-progress { font-size: 0.64rem; font-weight: bold; color: #171717; font-variant-numeric: tabular-nums; }
.achievements-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.achievement-item { display: flex; align-items: flex-start; gap: 0.45rem; padding: 0.5rem 0.6rem; border: 1px solid #d8d1c4; background: #fff; opacity: 0.68; }
.achievement-item.is-unlocked { border-color: #b45309; background: #fffbeb; opacity: 1; }
.achievement-mark { font-size: 1rem; line-height: 1; color: #b45309; }
.achievement-item strong { display: block; font-size: 0.72rem; }
.achievement-item small { display: block; color: #5d5a54; font-size: 0.62rem; line-height: 1.3; }

@media (max-width: 700px) {
  .rank-popup-card { height: min(640px, calc(100dvh - 1.25rem)); min-height: min(400px, calc(100dvh - 1.25rem)); padding: 0.9rem; }
  .progression-cards { grid-template-columns: 1fr; }
}
