/* ===== Battleship v2 — HUD + menus over the 3D stage ===== */

:root,
[data-theme="atlantic"] {
    --bg: #041426;
    --glass: rgba(6, 24, 42, 0.72);
    --glass-strong: rgba(4, 18, 33, 0.9);
    --line: rgba(167, 215, 224, 0.22);
    --line-strong: rgba(167, 215, 224, 0.45);
    --text: #e8f2f4;
    --muted: #9cc3cc;
    --accent: #a7d7e0;
    --accent-2: #c8a24a;
    --accent-ink: #041426;
    --enemy: #e86a5c;
    --good: #2fd0a8;
    --warn: #ffc457;
    --hit: #ff4d3d;
    --font-display: "Orbitron", system-ui, sans-serif;
    --font-body: "Outfit", system-ui, sans-serif;
    --radius: 16px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

[data-theme="brass"] {
    --bg: #030b14;
    --glass: rgba(14, 22, 34, 0.74);
    --glass-strong: rgba(10, 16, 26, 0.92);
    --line: rgba(242, 213, 156, 0.22);
    --line-strong: rgba(242, 213, 156, 0.5);
    --text: #f7f5ef;
    --muted: #d9c7a2;
    --accent: #f2d59c;
    --accent-2: #c8a24a;
    --accent-ink: #1a1206;
    --enemy: #ff7a5c;
}

[data-theme="regatta"] {
    --bg: #0a1e3f;
    --glass: rgba(10, 30, 63, 0.7);
    --glass-strong: rgba(8, 24, 52, 0.9);
    --line: rgba(127, 227, 210, 0.25);
    --line-strong: rgba(127, 227, 210, 0.5);
    --text: #f7f1e1;
    --muted: #c9d4e8;
    --accent: #7fe3d2;
    --accent-2: #20bfa8;
    --accent-ink: #062320;
    --enemy: #ff4d3d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#stage {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    touch-action: none;
    outline: none;
}

.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- brand ----- */
.eyebrow {
    margin: 0;
    font-size: 0.72rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
}
.logo {
    margin: 0.2rem 0 0;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.6rem, 9vw, 5.2rem);
    letter-spacing: 0.14em;
    line-height: 1;
    background: linear-gradient(180deg, #ffffff 0%, var(--accent) 70%, var(--accent-2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.5));
}
.logo-sub {
    margin: 0.35rem 0 0;
    font-family: var(--font-display);
    letter-spacing: 0.5em;
    text-transform: uppercase;
    font-size: clamp(0.8rem, 2.4vw, 1.05rem);
    color: var(--text);
}
.v2-badge {
    display: inline-block;
    margin-left: 0.3em;
    padding: 0.12em 0.5em;
    letter-spacing: 0.1em;
    border-radius: 6px;
    background: var(--accent-2);
    color: #12100a;
    font-weight: 800;
    font-size: 0.8em;
    vertical-align: 0.1em;
}

/* ----- boot ----- */
.boot {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: radial-gradient(ellipse at 50% 30%, #0f2f4a 0%, var(--bg) 70%);
    z-index: 50;
    transition: opacity 0.6s ease;
    text-align: center;
}
.boot.fade { opacity: 0; pointer-events: none; }
.boot-bar {
    width: min(260px, 70vw);
    height: 3px;
    margin: 1.6rem auto 0.8rem;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.boot-bar span {
    display: block;
    width: 40%;
    height: 100%;
    background: var(--accent);
    animation: bootbar 1.1s ease-in-out infinite;
}
@keyframes bootbar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.boot-msg { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ----- screens & panels ----- */
.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
    overflow-y: auto;
}

.panel {
    width: min(560px, 100%);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 20px 22px 24px;
    border-radius: var(--radius);
    background: var(--glass);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    animation: rise 0.45s cubic-bezier(.2, .9, .3, 1.2) both;
}
.panel.wide { width: min(860px, 100%); }
.panel.narrow { width: min(420px, 100%); text-align: center; }
.panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }

.panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.head-meta { margin-left: auto; color: var(--warn); font-family: var(--font-display); font-size: 0.85rem; }
.sub-head {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 22px 0 10px;
}

/* ----- menu ----- */
.menu-wrap {
    width: min(760px, 100%);
    text-align: center;
    animation: rise 0.6s cubic-bezier(.2, .9, .3, 1.1) both;
}
.menu-brand { margin-bottom: clamp(18px, 4vh, 36px); }
.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.mode-btn {
    position: relative;
    display: grid;
    justify-items: start;
    gap: 4px;
    padding: 16px 16px 14px;
    text-align: left;
    border-radius: 14px;
    background: var(--glass);
    border: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    overflow: hidden;
}
.mode-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.12), transparent 55%);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.mode-btn:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.mode-btn:hover::after { opacity: 1; }
.mode-btn i { font-size: 1.3rem; color: var(--accent); margin-bottom: 4px; }
.mode-btn b { font-family: var(--font-display); font-size: 0.86rem; letter-spacing: 0.08em; text-transform: uppercase; }
.mode-btn span { font-size: 0.82rem; color: var(--muted); }
.mode-btn.featured {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 26%, transparent), var(--glass));
    border-color: var(--line-strong);
}
.menu-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.chip-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    background: var(--glass);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    font-size: 0.86rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.chip-btn:hover { border-color: var(--line-strong); }
.theme-row { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.theme-dot-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    font-size: 0.78rem;
}
.theme-dot-btn.active { border-color: var(--accent); }
.theme-dot { width: 14px; height: 14px; border-radius: 50%; }
.theme-dot.atlantic { background: linear-gradient(135deg, #1f6f8b, #a7d7e0); }
.theme-dot.brass { background: linear-gradient(135deg, #0a2342, #c8a24a); }
.theme-dot.regatta { background: linear-gradient(135deg, #122a52, #ff4d3d 60%, #20bfa8); }

/* ----- controls ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
    color: var(--accent-ink);
    border-color: transparent;
    box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000)); }
.btn.danger { border-color: color-mix(in srgb, var(--enemy) 60%, transparent); color: var(--enemy); }
.btn.big { width: 100%; padding: 14px; font-size: 1rem; font-family: var(--font-display); letter-spacing: 0.1em; margin-top: 18px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn[aria-pressed="false"] i { opacity: 0.5; }

.field { margin: 14px 0; }
.field-label {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}
.seg {
    display: flex;
    padding: 4px;
    gap: 4px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
}
.seg button {
    flex: 1;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
}
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.seg button small { display: block; font-weight: 400; font-size: 0.7rem; opacity: 0.8; }

.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rule-toggle {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22);
    text-align: left;
}
.rule-toggle i { color: var(--muted); width: 18px; text-align: center; }
.rule-toggle b { font-size: 0.88rem; display: block; }
.rule-toggle small { font-size: 0.74rem; color: var(--muted); display: block; line-height: 1.3; }
.rule-toggle .sw {
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    position: relative;
    transition: background 0.2s;
}
.rule-toggle .sw::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.rule-toggle[aria-pressed="true"] { border-color: var(--line-strong); background: color-mix(in srgb, var(--accent) 12%, rgba(0, 0, 0, 0.2)); }
.rule-toggle[aria-pressed="true"] i { color: var(--accent); }
.rule-toggle[aria-pressed="true"] .sw { background: var(--accent); }
.rule-toggle[aria-pressed="true"] .sw::after { transform: translateX(14px); background: var(--accent-ink); }

.text-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
}
.text-input.code {
    font-family: var(--font-display);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    text-align: center;
}
.online-actions { display: grid; gap: 10px; margin-top: 18px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.online-status {
    margin-top: 16px;
    padding: 14px;
    border-radius: 12px;
    border: 1px dashed var(--line-strong);
    text-align: center;
}
.room-code {
    font-family: var(--font-display);
    font-size: 2rem;
    letter-spacing: 0.35em;
    color: var(--warn);
    margin: 6px 0;
}

/* ----- campaign ----- */
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mission {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.22);
    text-align: left;
}
.mission:hover:not(:disabled) { border-color: var(--line-strong); }
.mission:disabled { opacity: 0.45; cursor: not-allowed; }
.mission .portrait {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}
.mission b { display: block; font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.06em; }
.mission small { color: var(--muted); font-size: 0.78rem; }
.stars { color: var(--warn); font-size: 0.8rem; white-space: nowrap; }
.stars .off { color: rgba(255, 255, 255, 0.18); }

/* ----- records ----- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat {
    padding: 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--line);
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.3rem; }
.stat span { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ach {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.2);
    opacity: 0.45;
}
.ach.on { opacity: 1; border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.ach i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(255, 255, 255, 0.07); color: var(--warn); }
.ach b { display: block; font-size: 0.86rem; }
.ach small { color: var(--muted); font-size: 0.76rem; }

/* ----- settings ----- */
.settings-body { display: grid; gap: 4px; }
.set-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }
.set-row b { display: block; font-size: 0.92rem; font-weight: 600; }
.set-row small { color: var(--muted); font-size: 0.78rem; }
.set-row input[type="range"] { width: 140px; accent-color: var(--accent); }
.set-row .seg { min-width: 200px; }

/* ----- how to ----- */
.howto { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.howto section {
    padding: 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--line);
}
.howto h3 { margin: 0 0 6px; font-size: 0.92rem; display: flex; gap: 8px; align-items: center; }
.howto h3 i { color: var(--accent); }
.howto p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.howto kbd {
    font-family: var(--font-display);
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 5px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
}

/* ===== HUD ===== */
.hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: calc(10px + var(--safe-t)) 14px 10px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent);
    pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-title { display: grid; line-height: 1.15; }
.hud-mode { font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
.hud-sub { font-size: 0.78rem; color: var(--muted); }
.turn-banner {
    justify-self: center;
    padding: 9px 20px;
    border-radius: 999px;
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    font-family: var(--font-display);
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    text-align: center;
    max-width: 100%;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    transition: border-color 0.3s, color 0.3s, box-shadow 0.3s;
}
.turn-banner.you { border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), 0 8px 30px rgba(0, 0, 0, 0.35); }
.turn-banner.enemy { border-color: var(--enemy); color: var(--enemy); }
.turn-banner.pop { animation: pop 0.45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { 0% { transform: scale(0.85); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }
.hud-tools { display: flex; gap: 6px; }

.fleet-card {
    position: absolute;
    top: calc(70px + var(--safe-t));
    width: 196px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--glass);
    border: 1px solid var(--line);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    font-size: 0.8rem;
}
.fleet-card.home { left: 14px; }
.fleet-card.enemy { right: 14px; }
.fleet-card h3 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.fleet-card.enemy h3 { color: var(--enemy); }
.ship-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; padding: 3px 0; }
.ship-row.sunk .ship-name { text-decoration: line-through; opacity: 0.45; }
.ship-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { display: flex; gap: 3px; }
.pip { width: 9px; height: 9px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 70%, transparent); }
.pip.hit { background: var(--hit); box-shadow: 0 0 6px var(--hit); }
.pip.unknown { background: rgba(255, 255, 255, 0.16); }
.pip.dead { background: rgba(255, 255, 255, 0.1); }
.armor-tag { color: #7fe3ff; margin-left: 4px; }

.admiral {
    position: absolute;
    top: calc(70px + var(--safe-t));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(440px, calc(100vw - 440px));
    min-width: 220px;
    padding: 8px 14px 8px 8px;
    border-radius: 14px;
    background: var(--glass-strong);
    border: 1px solid var(--line);
    animation: rise 0.35s ease both;
}
.admiral-portrait {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.07);
    font-size: 1.1rem;
}
.admiral-text b { display: block; font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.admiral-text span { font-size: 0.9rem; }

.log-panel {
    position: absolute;
    right: 14px;
    bottom: 150px;
    width: 240px;
    max-height: 40vh;
    overflow-y: auto;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--glass-strong);
    border: 1px solid var(--line);
}
.log-panel h3 { margin: 0 0 8px; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.log-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.8rem; }
.log-panel li { display: flex; gap: 6px; align-items: baseline; }
.log-side { font-family: var(--font-display); font-size: 0.64rem; padding: 1px 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); }
.log-panel li.them .log-side { color: var(--enemy); }
.tag { font-weight: 700; font-size: 0.72rem; }
.tag.hit, .tag.sunk { color: var(--hit); }
.tag.miss { color: var(--muted); }
.tag.info { color: var(--accent); }
.tag.warn { color: var(--warn); }

.hud-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 14px calc(12px + var(--safe-b));
    display: grid;
    justify-items: center;
    gap: 8px;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.5), transparent);
    pointer-events: none;
}
.hud-bottom > * { pointer-events: auto; }
.hint {
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
    min-height: 1.1em;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}
.bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
    background: var(--glass-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}
.dock { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dock-chip {
    display: grid;
    gap: 4px;
    justify-items: center;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.74rem;
    min-width: 74px;
}
.dock-chip .len { display: flex; gap: 2px; }
.dock-chip .len i { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); display: block; }
.dock-chip.current { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.dock-chip.placed { opacity: 0.45; }
.dock-chip.placed .len i { background: var(--good); }
.bar-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.tool-btn {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 3px;
    min-width: 62px;
    padding: 7px 8px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.7rem;
    color: var(--text);
}
.tool-btn i { font-size: 1rem; }
.tool-btn:hover:not(:disabled) { border-color: var(--line-strong); }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tool-btn.active, .tool-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.tool-btn .cd {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--enemy);
    color: #fff;
    font-style: normal;
    font-size: 0.66rem;
    font-weight: 700;
    display: grid;
    place-items: center;
}
.tool-btn .cd:empty { display: none; }
.tool-btn .key {
    position: absolute;
    bottom: -5px;
    right: 4px;
    font-size: 0.56rem;
    color: var(--muted);
    font-family: var(--font-display);
}
.abilities { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.fire-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 14px;
    border: 0;
    background: linear-gradient(180deg, #ff6a4d, #c9321f);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    box-shadow: 0 8px 26px rgba(255, 77, 61, 0.35);
}
.fire-btn.active { outline: 2px solid #fff; outline-offset: 2px; }
.fire-btn:disabled { filter: grayscale(0.7); opacity: 0.5; cursor: not-allowed; }
.emotes { display: flex; gap: 4px; }
.emote-btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 6px 8px; font-size: 0.78rem; }
.replay-tag { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.1em; color: var(--warn); padding: 0 6px; }
body.busy #action-bar { opacity: 0.6; }

/* ----- toasts ----- */
.toast-stack {
    position: fixed;
    top: calc(64px + var(--safe-t));
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    display: grid;
    gap: 6px;
    justify-items: center;
    pointer-events: none;
}
.toast {
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    font-size: 0.88rem;
    animation: toastIn 0.3s ease both;
}
.toast.ach { border-color: var(--warn); }
.toast.ach i { color: var(--warn); }
.toast.bad { border-color: var(--enemy); }
.toast.out { animation: toastOut 0.3s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ----- big callout (HIT! SUNK!) ----- */
.callout {
    position: fixed;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%);
    z-index: 30;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2rem, 8vw, 4.4rem);
    letter-spacing: 0.12em;
    pointer-events: none;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
    animation: callout 1.25s cubic-bezier(.2, .9, .3, 1.2) both;
    white-space: nowrap;
}
.callout.hit { color: var(--hit); }
.callout.sunk { color: #fff; -webkit-text-stroke: 2px var(--hit); }
.callout.miss { color: #dff3f7; font-size: clamp(1.4rem, 5vw, 2.6rem); }
.callout.info { color: var(--warn); font-size: clamp(1.4rem, 5vw, 2.6rem); }
@keyframes callout {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    30% { transform: translate(-50%, -50%) scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}

/* ----- modal / curtain ----- */
.modal, .curtain {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(1, 8, 16, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.curtain { background: rgba(1, 8, 16, 0.96); z-index: 46; }
.modal-card, .curtain-card {
    width: min(480px, 100%);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 22px;
    border-radius: 18px;
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    text-align: center;
    animation: rise 0.4s cubic-bezier(.2, .9, .3, 1.2) both;
}
.modal-card h2, .curtain-card h2 {
    margin: 8px 0 6px;
    font-family: var(--font-display);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.modal-card p, .curtain-card p { color: var(--muted); margin: 6px 0; }
.result-icon { font-size: 2.6rem; color: var(--warn); }
.result-icon.lose { color: var(--enemy); }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.result-stats div { padding: 10px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.result-stats b { display: block; font-family: var(--font-display); font-size: 1.1rem; }
.result-stats span { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.result-stars { font-size: 1.8rem; color: var(--warn); letter-spacing: 0.2em; }
.result-stars .off { color: rgba(255, 255, 255, 0.15); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.brief-rules { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 12px 0; }
.rule-chip { font-size: 0.74rem; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05); }
.rule-chip i { color: var(--accent); margin-right: 4px; }
.tip { font-size: 0.86rem; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid var(--line); color: var(--text) !important; text-align: left; }
.tip i { color: var(--warn); margin-right: 6px; }
.upgrade-grid { display: grid; gap: 8px; margin-top: 14px; }
.upgrade {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px;
    text-align: left;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}
.upgrade:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.upgrade i { font-size: 1.2rem; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: rgba(255, 255, 255, 0.07); color: var(--accent); }
.upgrade b { display: block; }
.upgrade small { color: var(--muted); }
.mods-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.share-grid { font-size: 0.7rem; line-height: 1; letter-spacing: 0; white-space: pre; margin: 10px auto; display: inline-block; text-align: left; }

/* ===== responsive ===== */
@media (max-width: 1100px) {
    .fleet-card { width: 170px; }
    .admiral { max-width: calc(100vw - 380px); }
}
@media (max-width: 860px) {
    .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fleet-card { top: auto; bottom: 150px; width: auto; max-width: 46vw; padding: 8px 10px; font-size: 0.72rem; }
    .fleet-card .ship-name { display: none; }
    .fleet-card .ship-row { grid-template-columns: auto auto; justify-content: start; }
    .fleet-card h3 { margin-bottom: 4px; }
    .admiral { max-width: calc(100vw - 32px); min-width: 0; }
    .log-panel { left: 14px; right: 14px; width: auto; bottom: 200px; }
    .hud-top { grid-template-columns: auto 1fr auto; }
    .hud-title { display: none; }
    .rule-grid, .mission-list, .ach-grid, .howto { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .logo { letter-spacing: 0.08em; }
    .mode-btn { padding: 12px; }
    .mode-btn span { font-size: 0.74rem; }
    .turn-banner { font-size: 0.72rem; padding: 7px 12px; }
    .hud-tools .icon-btn { width: 36px; height: 36px; }
    .hud-tools #hud-settings { display: none; }
    .tool-btn { min-width: 52px; padding: 6px; font-size: 0.62rem; }
    .tool-btn span { display: none; }
    .dock-chip { min-width: 0; padding: 6px 8px; }
    .dock-chip span { display: none; }
    .fire-btn { padding: 11px 14px; }
    .bar { gap: 6px; padding: 6px; }
    .fleet-card { bottom: 132px; }
    .set-row { grid-template-columns: 1fr; }
    .set-row .seg { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

#menu { background: radial-gradient(ellipse at 50% 48%, rgba(2, 10, 20, 0.62) 0%, rgba(2, 10, 20, 0.25) 55%, transparent 80%); }
