:root {
  --navy: #061018;
  --deep: #0a1c28;
  --panel: rgba(8, 18, 26, 0.78);
  --gold: #d7b56a;
  --gold-2: #f3e0a6;
  --gold-dim: #8a6e3a;
  --ink: #e8dfc8;
  --muted: #b7aa8c;
  --hit: #e85d04;
  --sunk: #9b2226;
  --miss: #d8eef2;
  --water: #0b5c6b;
  --water-2: #083f4c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  --frame:
    linear-gradient(#2a2114, #2a2114) padding-box,
    linear-gradient(160deg, #f3e0a6, #9a7436 40%, #f8e7b0 70%, #6e5424) border-box;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Outfit, sans-serif;
  color: var(--ink);
  background: #04090d;
  overflow: hidden;
}

button, input { font-family: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

#app {
  height: 100%;
  position: relative;
}

.bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 10, 14, 0.35), rgba(4, 10, 14, 0.72)),
    url("../assets/menu-hero.jpg") center/cover no-repeat;
  transform: scale(1.04);
  filter: saturate(1.05);
  z-index: 0;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 70%, transparent 20%, rgba(0, 0, 0, 0.45) 100%);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.screen.active { display: flex; animation: fadein 0.45s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.ornament {
  width: min(520px, 80vw);
  height: 14px;
  background:
    linear-gradient(90deg, transparent, var(--gold), transparent);
  position: relative;
  opacity: 0.85;
}
.ornament::before,
.ornament::after {
  content: "◆";
  position: absolute;
  top: -10px;
  color: var(--gold);
  font-size: 14px;
}
.ornament::before { left: 18%; }
.ornament::after { right: 18%; }

.title {
  font-family: "Cinzel Decorative", Cinzel, serif;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 10px 0 0;
  text-align: center;
  background: linear-gradient(180deg, #fff6d2, #d7b56a 55%, #8a6e3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
}
.title.xl { font-size: clamp(42px, 8vw, 92px); }
.title.lg { font-size: clamp(28px, 4vw, 48px); }
.subtitle {
  font-family: Cinzel, serif;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin: 6px 0 28px;
  font-size: 13px;
}

.menu-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(420px, 92vw);
}

.gold-btn {
  appearance: none;
  border: 1px solid #f0d78a;
  background: linear-gradient(180deg, #f6e7b4 0%, #d7b56a 42%, #a07d36 100%);
  color: #1b1408;
  font-family: Cinzel, serif;
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 18px;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 230, 0.55);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.gold-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.gold-btn.ghost {
  background: rgba(8, 16, 22, 0.55);
  border: 1px solid var(--gold-dim);
  color: var(--gold-2);
  box-shadow: none;
}
.gold-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.top-tools {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--gold-dim);
  background: rgba(6, 14, 20, 0.7);
  color: var(--gold-2);
  font-size: 16px;
}
body.ingame .rank-chip { display: none; }
.rank-chip {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(6, 14, 20, 0.7);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  font-size: 13px;
  color: var(--gold-2);
}
.rank-chip b { color: var(--gold); font-family: Cinzel, serif; }

.panel {
  width: min(1100px, 96vw);
  background: var(--panel);
  border: 1px solid transparent;
  background-image: var(--frame);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  width: min(1100px, 96vw);
}

.card {
  background: rgba(6, 14, 20, 0.72);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s;
  text-align: left;
  color: inherit;
  padding: 0;
}
.card:hover, .card.selected {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 12px 30px rgba(215, 181, 106, 0.18);
}
.card img, .card .thumb {
  width: 100%;
  height: 148px;
  object-fit: cover;
  display: block;
}
.card .body { padding: 12px 14px 16px; }
.card h3 {
  margin: 0 0 4px;
  font-family: Cinzel, serif;
  font-size: 18px;
  color: var(--gold-2);
}
.card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.card .meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.portrait {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  filter: saturate(1.05);
}

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1100px, 96vw);
  margin-bottom: 16px;
}
.screen-head h2 {
  font-family: Cinzel, serif;
  margin: 0;
  letter-spacing: 0.14em;
  color: var(--gold-2);
}

.cmd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  width: min(1100px, 96vw);
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-bottom: 8px;
}
.cmd-card .portrait { height: 210px; aspect-ratio: auto; }
.cmd-card.selected { outline: 2px solid var(--gold); }

.detail-bar {
  width: min(1100px, 96vw);
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: rgba(6, 14, 20, 0.7);
  border: 1px solid var(--gold-dim);
  padding: 12px 16px;
  border-radius: 8px;
}
.detail-bar p { margin: 0; color: var(--muted); }

.arena-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  width: min(1100px, 96vw);
  max-height: calc(100vh - 210px);
  overflow: auto;
}
.arena-card .thumb { height: 120px; }

.hud-play {
  width: min(1520px, 99vw);
  height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}
#screen-place .hud-play {
  width: min(1100px, 98vw);
  grid-template-rows: auto 1fr;
}

.battle-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pilot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.pilot img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px #1b1408;
}
.pilot .who { font-family: Cinzel, serif; color: var(--gold-2); }
.pilot .navy { font-size: 12px; color: var(--muted); }
.ships-row { display: flex; gap: 6px; margin-top: 4px; }
.pip {
  width: 18px;
  height: 8px;
  border-radius: 2px;
  background: var(--gold);
}
.pip.dead { background: #5a2a28; opacity: 0.7; }

.turn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 160px;
}
.turn-banner {
  font-family: Cinzel Decorative, serif;
  color: var(--gold-2);
  letter-spacing: 0.16em;
  text-align: center;
}
.turn-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 140px;
}
.turn-clock-bar {
  width: 140px;
  height: 5px;
  border-radius: 99px;
  background: rgba(20, 28, 32, 0.7);
  border: 1px solid var(--gold-dim);
  overflow: hidden;
}
.turn-clock-bar i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #c9a36a, #fff6d2);
  box-shadow: 0 0 8px rgba(255, 230, 160, 0.45);
}
.turn-clock span {
  font-family: Cinzel, serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--gold-2);
}
.turn-clock.urgent .turn-clock-bar i {
  background: linear-gradient(90deg, #9b2226, #ffb703);
}
.turn-clock.urgent span {
  color: #ffd39a;
}

.battle-mid {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(420px, 1.58fr);
  grid-template-areas: "own enemy";
  gap: 14px;
  min-height: 0;
}
.battle-mid .board-wrap.own { grid-area: own; }
.battle-mid .board-wrap.enemy { grid-area: enemy; }
.board-wrap.own {
  max-width: 360px;
}
.board-wrap.enemy {
  min-width: 0;
}
.battle-mid.defending {
  grid-template-areas: "enemy own";
}
.battle-mid.defending .board-wrap.own {
  max-width: none;
}
.battle-mid.defending .board-wrap.enemy {
  max-width: 360px;
}
.board-wrap {
  background: rgba(5, 12, 16, 0.55);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.board-wrap h3 {
  margin: 0 0 8px;
  font-family: Cinzel, serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.board-frame {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
  min-height: 0;
}
.tracer-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: visible;
}
.tracer-bolt {
  position: absolute;
  height: 4px;
  width: var(--len);
  transform-origin: 0 50%;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent 0%, #fff6d2 28%, #ffb703 100%);
  box-shadow: 0 0 10px #ffe08a, 0 0 18px rgba(255, 200, 80, 0.55);
  animation: tracer-fly 0.42s ease-out forwards;
}
@keyframes tracer-fly {
  0% { transform: rotate(var(--ang)) scaleX(0); opacity: 1; }
  72% { transform: rotate(var(--ang)) scaleX(1); opacity: 1; }
  100% { transform: rotate(var(--ang)) scaleX(1); opacity: 0.15; }
}
.tracer-impact {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6d2 0%, rgba(255, 183, 3, 0.45) 42%, transparent 70%);
  animation: tracer-boom 0.45s ease-out forwards;
}
@keyframes tracer-boom {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.grid {
  display: grid;
  gap: 2px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(8, 40, 48, 0.5), rgba(4, 18, 24, 0.65));
  border: 2px solid var(--gold-dim);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.4);
  transform-origin: center bottom;
}
.board-wrap.own .board-with-axes { transform: rotateX(8deg); }
.board-wrap.enemy .board-with-axes { transform: none; }
.battle-mid.defending .board-wrap.own .board-with-axes { transform: none; }
.battle-mid.defending .board-wrap.enemy .board-with-axes { transform: rotateX(8deg); }
.cell {
  width: 28px;
  height: 28px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(28, 130, 142, 0.42), rgba(8, 50, 60, 0.78));
  border: 1px solid rgba(180, 220, 230, 0.14);
  cursor: pointer;
  box-shadow: inset 0 0 8px rgba(0, 30, 40, 0.35);
}
.cell:hover { outline: 2px solid var(--gold-2); outline-offset: -2px; }
.cell.blocked {
  background: linear-gradient(180deg, #6b5b48, #3a3228);
  cursor: default;
  box-shadow: inset 0 0 8px #1a140e;
}
.cell.ship {
  background:
    linear-gradient(90deg, rgba(255, 220, 150, 0.12), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.25)),
    repeating-linear-gradient(90deg, #8b6234 0 3px, #6e4a24 3px 6px);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, 0.4), inset 0 -2px 0 #3a2414;
  border-color: #c9a36a;
  overflow: hidden;
}
.cell.ship.hull-n { border-top-color: transparent; }
.cell.ship.hull-s { border-bottom-color: transparent; }
.cell.ship.hull-e { border-right-color: transparent; }
.cell.ship.hull-w { border-left-color: transparent; }
.cell.ship.hull-feat::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 18%;
  height: 55%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #f3e0a6, #6e5424);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
  z-index: 1;
  pointer-events: none;
}
.cell.navy-harwick.ship,
.cell.model-sail.ship {
  background:
    linear-gradient(180deg, rgba(255, 236, 190, 0.2), transparent 40%),
    repeating-linear-gradient(90deg, #8b6234 0 4px, #6a451f 4px 7px);
  border-color: #d8c48a;
}
.cell.navy-reinhardt.ship,
.cell.model-steel.ship {
  background:
    linear-gradient(180deg, #8a93a0, #3d4450 55%, #2a3038);
  border-color: #c5d0d8;
}
.cell.model-steel.hull-feat::before {
  width: 28%;
  height: 42%;
  top: 6%;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #2a2e34, #6d7682);
}
.cell.navy-vescari.ship,
.cell.model-italy.ship {
  background:
    linear-gradient(90deg, #c45c4a 0 14%, transparent 14%),
    linear-gradient(180deg, #8d9196, #5a5e64 60%, #3a3e44);
  border-color: #d88a7a;
}
.cell.navy-astrid.ship,
.cell.model-viking.ship {
  background:
    repeating-linear-gradient(90deg, #3a2618 0 5px, #5a3a22 5px 8px);
  border-color: #c9a36a;
}
.cell.model-viking.hull-tip:not(.hull-feat)::before {
  content: "";
  position: absolute;
  inset: 22% 8% auto auto;
  width: 38%;
  height: 38%;
  background: #c9a36a;
  clip-path: polygon(0 80%, 100% 50%, 0 0);
  z-index: 1;
  pointer-events: none;
}
.cell.navy-hale.ship,
.cell.model-frigate.ship {
  background:
    linear-gradient(180deg, #e6c36a 0 12%, #7a5328 12% 88%, #e6c36a 88%);
  border-color: #f0d78a;
}
.cell.navy-morel.ship,
.cell.model-iron.ship {
  background:
    radial-gradient(circle at 30% 30%, #6a5a3a 1px, transparent 2px),
    linear-gradient(180deg, #3a3a40, #1c1c20);
  background-size: 7px 7px, auto;
  border-color: #c4a35a;
}
.cell.model-iron.hull-feat::before {
  width: 34%;
  height: 36%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8d08a, #8a6e3a);
}
.cell.navy-lysandra.ship,
.cell.model-trireme.ship {
  background:
    repeating-linear-gradient(180deg, #7a2a28 0 3px, #5a3a28 3px 6px);
  border-color: #d4b06a;
}
.cell.skin-ivory { filter: saturate(0.7) brightness(1.25); }
.cell.skin-royal { filter: hue-rotate(200deg) saturate(1.15); }
.cell.skin-night { filter: brightness(0.72) saturate(0.8); }
.cell.skin-brass { filter: sepia(0.55) saturate(1.2); }
.cell.skin-crimson { filter: hue-rotate(-10deg) saturate(1.35); }
.cell.skin-sand { filter: sepia(0.45) brightness(1.15); }
.cell.skin-frost { filter: hue-rotate(180deg) saturate(0.55) brightness(1.2); }
.cell.skin-blood { filter: hue-rotate(-20deg) saturate(1.4); }
.cell.skin-pearl { filter: brightness(1.28) saturate(0.65); }
.cell.skin-emerald { filter: hue-rotate(80deg) saturate(1.2); }
.cell.skin-copper { filter: sepia(0.7) hue-rotate(-10deg); }
.cell.skin-obsidian { filter: brightness(0.55) contrast(1.2); }
.cell.skin-marble { filter: brightness(1.3) saturate(0.4); }
.cell.skin-tyrian { filter: hue-rotate(-40deg) saturate(1.45); }
.cell.ship.wreck {
  filter: grayscale(0.35) brightness(0.55);
}
.cell.preview { outline: 2px solid #f3e0a6; background: rgba(215, 181, 106, 0.45); }
.cell.preview-bad { outline: 2px solid #c45c4a; background: rgba(180, 50, 40, 0.4); }
.cell.miss::after,
.cell.hit::after,
.cell.sunk::after,
.cell.sonar-empty::after,
.cell.sonar-ship::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
}
.cell.miss::after {
  background: radial-gradient(circle, #f4fbff 20%, #9ad 60%, transparent 70%);
  box-shadow: 0 0 8px #bfe;
}
.cell.hit::after {
  background: radial-gradient(circle, #fff3bf, #e85d04 55%, #9b2226);
  box-shadow: 0 0 10px #e85d04;
}
.cell.sunk {
  background: #4a1c1c;
}
.cell.sunk::after {
  background: radial-gradient(circle, #ffb703, #9b2226);
}
.cell.sonar-empty::after {
  border: 2px solid rgba(180, 220, 230, 0.45);
  background: transparent;
  inset: 28%;
}
.cell.sonar-ship::after {
  background: radial-gradient(circle, #f3e0a6, transparent 70%);
}
.cell.mine::before {
  content: "✦";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f3e0a6;
  font-size: 12px;
}
.cell.selected {
  outline: 2px solid #fff6d2;
  outline-offset: -2px;
}
.cell.incoming {
  outline: 3px solid #fff6d2;
  outline-offset: -2px;
  box-shadow: 0 0 18px rgba(255, 246, 210, 0.55), inset 0 0 12px rgba(255, 220, 120, 0.28);
  animation: incoming-flash 1.05s ease-out;
}
@keyframes incoming-flash {
  0% { box-shadow: 0 0 28px rgba(255, 246, 210, 0.95), inset 0 0 16px rgba(255, 230, 150, 0.45); }
  100% { box-shadow: 0 0 14px rgba(255, 240, 180, 0.4), inset 0 0 10px rgba(255, 220, 120, 0.2); }
}

.labels {
  display: grid;
  gap: 2px;
}
.axis-x, .axis-y {
  display: grid;
  color: var(--gold);
  font-family: Cinzel, serif;
  line-height: 1;
  box-sizing: border-box;
}
.axis-x > * {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
}
.axis-y > * {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  box-sizing: border-box;
}
.board-with-axes {
  display: grid;
  grid-template-columns: 28px auto;
  grid-template-rows: 20px auto;
  align-items: start;
  justify-items: start;
  column-gap: 4px;
  transform-origin: center bottom;
}

.ability-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(6, 14, 20, 0.75);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 10px 12px;
}
.energy {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: Cinzel, serif;
  color: var(--gold-2);
}
.orb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d2, #d7b56a 45%, #6e5424);
  box-shadow: 0 0 8px rgba(243, 224, 166, 0.5);
}
.orb.off { filter: grayscale(1) brightness(0.45); }
.abilities { display: flex; flex-wrap: wrap; gap: 8px; }
.ab {
  border: 1px solid var(--gold-dim);
  background: rgba(10, 20, 28, 0.8);
  color: var(--gold-2);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 92px;
  text-align: left;
}
.ab small { display: block; color: var(--muted); font-size: 11px; }
.ab.active, .ab:hover { border-color: var(--gold); background: rgba(40, 30, 12, 0.85); }
.ab:disabled { opacity: 0.35; }

.announce {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}
.announce.show { display: flex; }
.announce span {
  font-family: "Cinzel Decorative", serif;
  font-size: clamp(42px, 7vw, 84px);
  letter-spacing: 0.12em;
  color: var(--gold-2);
  text-shadow: 0 10px 30px #000, 0 0 20px rgba(215, 181, 106, 0.45);
  animation: pop 0.7s ease;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  30% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.dock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.ship-chip {
  border: 1px solid var(--gold-dim);
  background: rgba(10, 18, 24, 0.8);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ship-chip.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.ship-chip.done { opacity: 0.4; }
.blocks { display: flex; gap: 2px; }
.blocks i {
  width: 10px;
  height: 10px;
  background: var(--gold);
  display: block;
}
.shape {
  display: grid;
  gap: 1px;
}
.shape i {
  width: 8px;
  height: 8px;
  background: transparent;
  display: block;
}
.shape i.on { background: var(--gold); }

.pass-card {
  text-align: center;
  width: min(560px, 92vw);
  padding: 36px 28px;
}
.pass-card p { color: var(--muted); }

.result-hero {
  text-align: center;
}
.result-hero img {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--gold);
  margin-bottom: 10px;
}
.stats {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 16px 0 22px;
  color: var(--gold-2);
}
.stats b { display: block; font-size: 22px; font-family: Cinzel, serif; color: var(--gold); }

.medals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  width: min(1000px, 96vw);
  max-height: calc(100vh - 180px);
  overflow: auto;
}
.medal {
  background: rgba(6, 14, 20, 0.75);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 14px;
}
.medal.locked { opacity: 0.4; filter: grayscale(0.8); }
.medal h3 { margin: 0 0 4px; font-family: Cinzel, serif; color: var(--gold-2); font-size: 16px; }
.medal p { margin: 0; color: var(--muted); font-size: 13px; }

.howto {
  width: min(760px, 94vw);
  max-height: calc(100vh - 160px);
  overflow: auto;
  line-height: 1.55;
  color: var(--muted);
}
.howto h3 { color: var(--gold-2); font-family: Cinzel, serif; }
.howto kbd {
  border: 1px solid var(--gold-dim);
  padding: 0 6px;
  border-radius: 4px;
  color: var(--gold-2);
}

.lobby-box {
  width: min(480px, 92vw);
  text-align: center;
}
.room-code {
  font-family: Cinzel, serif;
  font-size: 42px;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin: 10px 0 18px;
}
.lobby-box input {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: rgba(6, 14, 20, 0.8);
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.2em;
  font-size: 20px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.name-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: rgba(6, 14, 20, 0.75);
  color: var(--ink);
}

.toast {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 16, 20, 0.9);
  border: 1px solid var(--gold);
  color: var(--gold-2);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 30;
  display: none;
}
.toast.show { display: block; }

@media (max-width: 980px) {
  .battle-mid,
  .battle-mid.defending {
    grid-template-columns: 1fr;
    grid-template-areas: "own" "enemy";
  }
  .board-wrap.own,
  .battle-mid.defending .board-wrap.enemy { max-width: none; }
  .cell { width: 22px; height: 22px; }
  .grid,
  .board-wrap.own .board-with-axes,
  .board-wrap.enemy .board-with-axes,
  .battle-mid.defending .board-wrap.own .board-with-axes,
  .battle-mid.defending .board-wrap.enemy .board-with-axes { transform: none; }
  .cmd-card .portrait { height: 150px; }
}

@media (max-width: 640px) {
  .title.xl { letter-spacing: 0.08em; }
  .subtitle { letter-spacing: 0.18em; }
  .cell { width: 18px; height: 18px; }
  .pilot { min-width: 0; }
}

.auth-card {
  width: min(420px, 92vw);
  background: rgba(6, 14, 20, 0.82);
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  text-align: left;
}
.auth-card h3 {
  margin: 0 0 10px;
  font-family: Cinzel, serif;
  color: var(--gold-2);
  letter-spacing: 0.08em;
}
.auth-card .row { display: flex; gap: 8px; margin-bottom: 8px; }
.auth-card input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: rgba(6, 14, 20, 0.75);
  color: var(--ink);
}
.discord-btn {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  background: #5865f2;
  color: #fff;
  font-family: Cinzel, serif;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.discord-btn:hover { filter: brightness(1.08); }
.discord-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.auth-split {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 8px 0 12px;
}
.auth-split::before, .auth-split::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gold-dim);
}
.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.account-chip img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  background: #1b1408;
}
.account-chip .who { font-family: Cinzel, serif; color: var(--gold-2); }
.account-chip .meta { font-size: 12px; color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
#rankChip img.mini-ava {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}
.gold-count {
  color: var(--gold);
  font-family: Cinzel, serif;
}
.card.locked { position: relative; }
.card.locked .lock-veil {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 12, 0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--gold-2);
  font-family: Cinzel, serif;
  text-align: center;
  padding: 12px;
}
.card.locked .lock-veil small { color: var(--muted); font-family: Outfit, sans-serif; }
.shop-lead {
  width: min(1100px, 96vw);
  color: var(--muted);
  margin: 0 0 16px;
}
.unlock-btn {
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #f6e7b4, #c9a24a);
  color: #1b1408;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: Cinzel, serif;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#screen-shop,
#screen-missions,
#screen-ranks,
#screen-howto,
#screen-medals,
#screen-tos {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 36px;
}
.menu-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.text-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--gold);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.legal a { color: var(--gold); }
.tos-accept {
  width: min(1100px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 28px;
}
.tos-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}
.tos-check input { margin-top: 4px; }
.coupon-bar {
  width: min(1100px, 96vw);
  margin: 0 0 18px;
}
.coupon-bar input {
  flex: 1;
  min-width: 180px;
  background: rgba(4, 10, 14, 0.7);
  border: 1px solid var(--gold-dim);
  color: var(--gold-2);
  padding: 8px 10px;
  border-radius: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.shop-h {
  width: min(1100px, 96vw);
  margin: 22px 0 8px;
  font-family: Cinzel, serif;
  color: var(--gold-2);
  letter-spacing: 0.08em;
}
.invite-box {
  width: 100%;
  margin: 10px 0 16px;
}
.invite-box input {
  width: 100%;
  margin-bottom: 8px;
  background: rgba(4, 10, 14, 0.7);
  border: 1px solid var(--gold-dim);
  color: var(--gold-2);
  padding: 8px 10px;
  border-radius: 6px;
}
.skin-row {
  width: min(1100px, 96vw);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.skin-chip {
  border: 1px solid var(--gold-dim);
  background: rgba(8, 16, 22, 0.85);
  color: var(--gold-2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.skin-chip.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.skin-chip.locked { opacity: 0.55; }
.hull-preview {
  display: flex;
  gap: 2px;
  margin-top: 10px;
}
.hull-preview i {
  width: 22px;
  height: 16px;
  display: block;
  border: 1px solid #c9a36a;
}
.mission-list {
  width: min(720px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mission-card {
  background: rgba(6, 14, 20, 0.78);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 14px 16px;
}
.mission-card h3 {
  margin: 0 0 4px;
  font-family: Cinzel, serif;
  color: var(--gold-2);
}
.mission-card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.mission-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}
.mission-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c9a24a, #f3e0a6);
}
.mission-card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--gold);
  font-size: 12px;
}
.rank-tools {
  width: min(1100px, 96vw);
  margin-bottom: 14px;
}
.rank-tools input {
  flex: 1;
  min-width: 160px;
  background: rgba(4, 10, 14, 0.7);
  border: 1px solid var(--gold-dim);
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 6px;
}
.board-table {
  width: min(1100px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board-row {
  display: grid;
  grid-template-columns: 40px 1fr 80px 90px 80px;
  gap: 8px;
  align-items: center;
  background: rgba(6, 14, 20, 0.72);
  border: 1px solid var(--gold-dim);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--ink);
}
.board-row.head {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.board-row.you { border-color: var(--gold); }
.board-row .who {
  display: flex;
  align-items: center;
  gap: 8px;
}
.board-row img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.sink-cam {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 10, 0.55);
  pointer-events: none;
}
.sink-cam.show { display: flex; }
.sink-stage {
  position: relative;
  width: min(520px, 86vw);
  height: 280px;
  overflow: hidden;
  border: 2px solid var(--gold-dim);
  border-radius: 8px;
  box-shadow: var(--shadow);
  background:
    radial-gradient(ellipse at 50% 120%, #0b5c6b 0%, #061018 70%);
}
.sink-sea {
  position: absolute;
  inset: 55% 0 0;
  background:
    repeating-linear-gradient(90deg, rgba(180, 220, 230, 0.08) 0 12px, transparent 12px 24px),
    linear-gradient(180deg, rgba(12, 80, 90, 0.7), #041016);
}
.sink-hull {
  position: absolute;
  left: 18%;
  bottom: 38%;
  width: 46%;
  height: 54px;
  border-radius: 40% 50% 20% 30%;
  background:
    linear-gradient(180deg, #d8c48a 0 14%, #6a451f 14% 86%, #3a2414 86%);
  box-shadow: 0 0 18px rgba(232, 93, 4, 0.45);
  animation: sinkDrop 1.5s ease forwards;
}
.sink-hull::after {
  content: "";
  position: absolute;
  left: 40%;
  top: -28px;
  width: 8px;
  height: 34px;
  background: #f3e0a6;
}
.sink-hull.model-steel {
  background: linear-gradient(180deg, #8a93a0, #2a3038);
  border-radius: 8px 18px 10px 8px;
}
.sink-hull.model-italy { background: linear-gradient(90deg, #c45c4a 0 16%, #5a5e64 16%); }
.sink-hull.model-viking { background: repeating-linear-gradient(90deg, #3a2618 0 8px, #5a3a22 8px 14px); }
.sink-hull.model-frigate { background: linear-gradient(180deg, #e6c36a 0 14%, #7a5328 14%); }
.sink-hull.model-iron { background: linear-gradient(180deg, #3a3a40, #1c1c20); }
.sink-hull.model-trireme { background: repeating-linear-gradient(180deg, #7a2a28 0 4px, #5a3a28 4px 8px); }
.sink-stage img {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: 2px solid var(--gold);
  border-radius: 4px;
}
.sink-copy {
  position: absolute;
  left: 18px;
  top: 16px;
  color: var(--gold-2);
}
.sink-kicker {
  font-family: "Cinzel Decorative", serif;
  letter-spacing: 0.18em;
  font-size: 13px;
}
.sink-copy h2 {
  margin: 4px 0 0;
  font-family: Cinzel, serif;
  font-size: 28px;
}
.sink-copy p { margin: 4px 0 0; color: var(--muted); }
@keyframes sinkDrop {
  0% { transform: translateY(-18px) rotate(-4deg); opacity: 1; }
  70% { transform: translateY(28px) rotate(8deg); opacity: 1; }
  100% { transform: translateY(70px) rotate(12deg); opacity: 0.15; }
}
.card.sold { opacity: 0.55; cursor: default; }
