:root {
  color-scheme: dark;
  --page: #0d2025;
  --header: #102a30;
  --panel: #15353b;
  --panel-raised: #1c434a;
  --line: #315760;
  --text: #f0f4ed;
  --muted: #9cb3b5;
  --aqua: #69d1c4;
  --gold: #efba4e;
  --red: #e36b61;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; overflow: hidden; background: var(--page); }
body, button { color: var(--text); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button svg, a svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
[hidden] { display: none !important; }

.game-app { display: grid; width: 100%; height: 100dvh; grid-template-rows: 64px minmax(0, 1fr); background: var(--page); user-select: none; }
.topbar { position: relative; z-index: 20; display: grid; grid-template-columns: 42px minmax(180px, 1fr) minmax(520px, 720px) minmax(98px, 1fr); align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--header); }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: #e1ece9; background: var(--panel); cursor: pointer; text-decoration: none; }
.icon-button:disabled { opacity: .4; cursor: default; }
.icon-button .play-icon, .icon-button.is-paused .pause-icon, .mute-line { display: none; }
.icon-button.is-paused .play-icon, .icon-button.is-muted .mute-line { display: block; }
.icon-button.is-muted .sound-wave { display: none; }
.brand { display: flex; min-width: 0; align-items: center; gap: 10px; }
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 16px; }
.brand small, .metrics span, .dock-header span, .screen-content > p { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; font-weight: 700; }
.brand-mark { position: relative; display: block; width: 35px; height: 29px; flex: 0 0 auto; }
.brand-mark::before { position: absolute; top: 4px; left: 4px; width: 27px; height: 17px; border: 2px solid var(--aqua); clip-path: polygon(50% 0,100% 100%,72% 100%,62% 70%,38% 70%,28% 100%,0 100%); content: ""; }
.brand-mark::after { position: absolute; right: 0; bottom: 0; left: 0; height: 5px; border-top: 2px solid #e5f4f0; border-radius: 50%; content: ""; }
.metrics { display: grid; height: 100%; grid-template-columns: repeat(4, minmax(78px, 1fr)) minmax(110px, 1.25fr); border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
.metrics > div { display: grid; min-width: 0; align-content: center; gap: 3px; padding: 0 13px; border-right: 1px solid var(--line); }
.metrics > div:last-child { border-right: 0; }
.metrics strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 16px; font-variant-numeric: tabular-nums; }
.harbor-bar { display: block; width: 86px; height: 11px; border: 1px solid #638087; background: #24444a; }
.harbor-bar i { display: block; width: 100%; height: 100%; background: var(--aqua); }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

.workspace { display: grid; min-width: 0; min-height: 0; grid-template-columns: minmax(0, 1fr) 310px; }
.battlefield { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #247887; isolation: isolate; }
#gameCanvas { display: block; width: 100%; height: 100%; }
.battle-message { position: absolute; top: 16px; left: 50%; z-index: 7; min-width: 210px; padding: 10px 16px; border: 1px solid #bd8c34; border-radius: 4px; color: #2b210d; background: #f0c45f; font-weight: 800; text-align: center; transform: translateX(-50%); }
.screen-layer { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(9, 37, 43, .68); }
.screen-layer.is-hidden { pointer-events: none; opacity: 0; transition: opacity 180ms ease; }
.screen-content { display: grid; width: min(440px, calc(100% - 32px)); justify-items: center; text-align: center; }
.screen-content > p { margin: 0 0 13px; color: #82e3d5; }
.screen-content h1 { margin: 0; font-size: clamp(40px, 7vh, 66px); line-height: 1; }
.screen-content > span { margin: 14px 0 23px; color: #d5e4e1; font-size: 14px; }
.result { display: grid; width: min(300px, 100%); margin-bottom: 20px; grid-template-columns: 1fr 1fr; border-top: 1px solid #718b8e; border-bottom: 1px solid #718b8e; }
.result div { display: grid; gap: 3px; padding: 12px; }
.result div + div { border-left: 1px solid #617c7f; }
.result small { color: #afc4c3; }
.result strong { font-family: "SFMono-Regular", Consolas, monospace; font-size: 20px; }
.primary-button { display: flex; height: 46px; align-items: center; gap: 9px; padding: 0 22px; border: 1px solid #ae8030; border-radius: 5px; color: #281e0b; background: var(--gold); font-weight: 800; cursor: pointer; }

.dock { display: grid; min-width: 0; min-height: 0; grid-template-rows: 62px minmax(0, 1fr) 42px; border-left: 1px solid var(--line); background: #10282d; }
.dock-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.dock-header > div { display: grid; gap: 3px; }
.dock-header > div > span { color: #e2ece9; font-size: 12px; }
.dock-header strong { color: var(--muted); font-size: 10px; font-weight: 500; }
.dock-funds { display: flex; align-items: center; gap: 6px; color: var(--gold) !important; }
.dock-funds i { font-style: normal; }
.dock-funds b { font-family: "SFMono-Regular", Consolas, monospace; font-size: 15px; }
.ship-list { display: grid; align-content: start; overflow-y: auto; }
.ship-item { display: grid; min-height: 82px; grid-template-columns: 44px minmax(0, 1fr) 26px 48px; align-items: center; gap: 9px; padding: 10px 12px; border: 0; border-bottom: 1px solid #29474d; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.ship-item:hover:not(:disabled) { background: #17373d; }
.ship-item:disabled { opacity: .42; cursor: default; }
.ship-icon { position: relative; display: block; width: 42px; height: 42px; border: 1px solid #45656b; border-radius: 5px; background: var(--panel-raised); }
.ship-icon::before { position: absolute; top: 5px; left: 14px; width: 14px; height: 32px; background: #69d1c4; clip-path: polygon(50% 0,100% 28%,88% 100%,12% 100%,0 28%); content: ""; }
.ship-icon::after { position: absolute; top: 15px; left: 19px; width: 4px; height: 14px; background: #23434a; content: ""; }
.galley-icon::before, .fuchuan-icon::before, .paddle-sailer-icon::before, .ship-line-icon::before { top: 10px; left: 6px; width: 30px; height: 24px; background: #8f603d; clip-path: polygon(50% 0,100% 25%,82% 100%,18% 100%,0 25%); }
.galley-icon::after, .fuchuan-icon::after, .paddle-sailer-icon::after, .ship-line-icon::after { top: 5px; left: 19px; width: 3px; height: 28px; background: #4b3427; }
.galley-icon i::before, .fuchuan-icon i::before, .paddle-sailer-icon i::before, .ship-line-icon i::before { position: absolute; z-index: 2; top: 6px; left: 21px; width: 14px; height: 13px; background: #e8cf86; clip-path: polygon(0 0,100% 22%,80% 100%,0 78%); content: ""; }
.fuchuan-icon::before { background: #9d6640; }
.fuchuan-icon i::before { width: 16px; height: 16px; background: #d9b45e; }
.paddle-sailer-icon i::after { position: absolute; z-index: 3; top: 23px; left: 5px; width: 9px; height: 9px; border: 2px solid #d9b45e; border-radius: 50%; content: ""; }
.ship-line-icon::before { top: 6px; height: 31px; background: #684739; }
.ship-line-icon i::before { left: 20px; width: 17px; height: 18px; background: #ead89b; }
.torpedo-icon::before { left: 16px; width: 10px; background: #85ddd0; }
.submarine-icon::before { top: 9px; left: 11px; width: 20px; height: 25px; border-radius: 50%; clip-path: none; background: #52777b; }
.submarine-icon::after { top: 10px; left: 19px; width: 4px; height: 9px; }
.cruiser-icon::before { left: 12px; width: 18px; background: #9eb6b2; }
.battleship-icon::before { top: 3px; left: 10px; width: 22px; height: 36px; background: #d8ddd4; }
.battleship-icon::after { top: 11px; left: 18px; width: 6px; height: 20px; }
.carrier-icon::before { top: 3px; left: 8px; width: 26px; height: 36px; clip-path: polygon(30% 0,80% 0,100% 16%,86% 100%,8% 100%,0 18%); background: #a6b9b4; }
.carrier-icon::after { top: 7px; left: 19px; width: 2px; height: 28px; background: #e9c56a; }
.supply-icon::before { left: 12px; width: 18px; background: #76a7a0; }
.supply-icon i::before, .supply-icon i::after { position: absolute; z-index: 2; top: 20px; left: 12px; width: 18px; height: 4px; background: #f1d979; content: ""; }
.supply-icon i::after { transform: rotate(90deg); }
.ship-copy { display: grid; min-width: 0; gap: 4px; }
.ship-copy strong { font-size: 13px; }
.ship-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.ship-count { color: #cbdcda; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; text-align: center; }
.buy-mark { display: grid; height: 28px; place-items: center; border: 1px solid #8d6c2e; border-radius: 4px; color: #f0c660; font-size: 10px; }
.dock-feedback { display: grid; margin: 0; place-items: center start; padding: 0 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.dock-feedback.is-error { color: #ef8b80; }

@media (max-width: 980px) {
  .game-app { grid-template-rows: 104px minmax(0, 1fr); }
  .topbar { grid-template-columns: 38px minmax(0, 1fr) auto; grid-template-rows: 54px 50px; gap: 0 9px; padding: 0 12px; }
  .icon-button { width: 34px; height: 34px; }
  .brand-mark { width: 29px; }
  .brand strong { font-size: 14px; }
  .metrics { grid-area: 2 / 1 / 3 / 4; width: calc(100% + 24px); height: 50px; margin-left: -12px; grid-template-columns: repeat(4, minmax(52px, 1fr)) minmax(82px, 1.25fr); }
  .metrics > div { gap: 2px; padding: 0 7px; }
  .metrics strong { font-size: 13px; }
  .harbor-bar { width: min(70px, 100%); }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(280px, 1fr) 218px; }
  .dock { grid-template-rows: 40px minmax(0, 1fr) 30px; border-top: 1px solid var(--line); border-left: 0; }
  .dock-header { padding: 0 10px; }
  .dock-header strong { display: none; }
  .ship-list { display: flex; overflow-x: auto; overflow-y: hidden; }
  .ship-item { min-width: 176px; min-height: 146px; grid-template-columns: 42px minmax(0, 1fr); grid-template-rows: 52px 30px; gap: 6px 8px; border-right: 1px solid #29474d; border-bottom: 0; padding: 10px; }
  .ship-count { grid-area: 2 / 1; }
  .buy-mark { grid-area: 2 / 2; }
  .dock-feedback { padding: 0 10px; }
}

@media (max-width: 540px) {
  .brand-mark, .brand small { display: none; }
  .metrics span { font-size: 8px; }
  .metrics strong { font-size: 12px; }
  .workspace { grid-template-rows: minmax(230px, 1fr) 204px; }
  .screen-content h1 { font-size: 40px; }
  .screen-content { transform: translateY(-8px); }
}
