* { box-sizing: border-box; }

/* ── 音量控制：浮動開關按鈕 ── */
.btn-volume-toggle {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 9999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.22);
  background: rgba(13, 56, 112, 0.86);
  backdrop-filter: blur(8px);
  color: #eaf2fb;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, border-color 0.18s, transform 0.1s;
  box-shadow: 0 2px 14px rgba(0,0,0,0.4);
}
.btn-volume-toggle:hover { background: rgba(47,143,224,0.72); border-color: rgba(255,255,255,0.4); }
.btn-volume-toggle.panel-open {
  background: rgba(47,143,224,0.65);
  border-color: rgba(255,255,255,0.4);
  transform: scale(0.94);
}

/* ── 音量面板 ── */
.volume-panel {
  position: fixed;
  bottom: 70px;
  right: 18px;
  z-index: 9998;
  background: rgba(10, 40, 88, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 220px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.5);
  transform: translateY(10px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s cubic-bezier(0.34,1.3,0.64,1), opacity 0.18s ease;
  transform-origin: bottom right;
}
.volume-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
.vol-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #5a8ab0;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vol-mute-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  padding: 0;
}
.vol-mute-btn:hover { background: rgba(255,255,255,0.14); }
.vol-mute-btn.muted { background: rgba(220,60,60,0.2); }
.vol-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #7aabcf;
  letter-spacing: 0.5px;
  min-width: 26px;
}
.vol-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: #1a3a60;
  transition: opacity 0.15s;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3a9af0;
  border: 2px solid rgba(255,255,255,0.9);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(58,154,240,0.6);
  transition: transform 0.1s, background 0.1s;
}
.vol-slider::-webkit-slider-thumb:hover { transform: scale(1.25); background: #5ab5ff; }
.vol-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #3a9af0; border: 2px solid rgba(255,255,255,0.9); cursor: pointer;
}
.vol-slider:disabled { opacity: 0.35; cursor: default; }
.vol-slider:disabled::-webkit-slider-thumb { cursor: default; }
.vol-pct {
  flex-shrink: 0;
  font-size: 11px;
  color: #5a8ab0;
  min-width: 28px;
  text-align: right;
}

body {
  margin: 0;
  font-family: "PingFang TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0d3870;
  color: #eaf2fb;
}

.screen { display: none; min-height: 100vh; padding: 24px; }
.screen.active { display: block; }
#screen-battle.active { display: flex; flex-direction: column; padding: 16px; }
.hidden { display: none !important; }

h1, h2, h3 { margin-top: 0; }

.panel-card {
  max-width: 900px;
  margin: 0 auto;
  background: #0f4a88;
  border-radius: 12px;
  padding: 28px 32px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.28);
}

.intro-card { text-align: center; max-width: 600px; }
.subtitle { color: #9fc0e0; }
.hint { font-size: 13px; color: #7f9fc0; margin-top: 24px; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: #2f8fe0; color: white; }
.btn-primary:hover { background: #3fa0f5; }
.btn-secondary { background: #1a6098; color: #eaf2fb; }
.btn-secondary:hover { background: #2272b0; }
.btn-mini { background: #1a6098; color: #eaf2fb; padding: 6px 12px; font-size: 13px; margin-right: 6px; }
.btn-mini:hover { background: #2272b0; }
.btn-block { width: 100%; margin-top: 8px; }

.intro-actions { display: flex; gap: 12px; justify-content: center; margin: 20px 0; }

table { width: 100%; border-collapse: collapse; margin: 16px 0; }
th, td { padding: 8px 10px; text-align: center; border-bottom: 1px solid #1a6098; font-size: 14px; }
th { color: #9fc0e0; font-weight: 600; }

.fleet-cost-bar { font-size: 16px; margin: 12px 0; }
.fleet-table input[type="number"] {
  width: 56px;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid #1a6098;
  background: #0d3870;
  color: #eaf2fb;
  text-align: center;
}
.error-text { color: #ff8080; min-height: 20px; font-size: 14px; }

.ship-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #1258a0;
  color: #a8d4f0;
  font-size: 11px;
  white-space: nowrap;
  cursor: help;
}

.rules-btn { display: block; width: 100%; margin: 10px 0; }
.rules-box { text-align: left; max-width: 640px; }
.rules-content h3 { margin: 16px 0 6px; font-size: 15px; color: #9fc0e0; }
.rules-content h3:first-child { margin-top: 0; }
.rules-content p, .rules-content ul { font-size: 14px; line-height: 1.6; margin: 0 0 8px; }
.rules-content ul { padding-left: 20px; }

.join-room-form { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.join-room-form input {
  width: 160px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #1a6098;
  background: #0d3870;
  color: #eaf2fb;
  font-size: 18px;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
}
.room-code {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 6px;
  color: #ffe066;
  margin: 16px 0;
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #0f4a88;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 720px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }

.roll-box { text-align: center; max-width: 420px; cursor: pointer; }
.roll-portrait-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.roll-portrait-wrap.hidden { display: none; }
.roll-portrait-img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  animation: roll-portrait-in 0.25s ease-out;
}
.roll-portrait-img.roll-portrait-p1 { filter: drop-shadow(0 0 14px rgba(42,138,74,0.65)); }
.roll-portrait-img.roll-portrait-p2 { filter: drop-shadow(0 0 14px rgba(158,54,54,0.65)); }
.roll-portrait-name { font-size: 14px; font-weight: 600; color: #cfe4f7; }
@keyframes roll-portrait-in {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.roll-progress {
  width: 160px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  margin: 14px auto 0;
}
.roll-progress.hidden { display: none; }
.roll-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2f8fe0, #aac4ff);
  border-radius: 2px;
}
@keyframes roll-countdown { from { width: 100%; } to { width: 0%; } }
.roll-progress-fill.roll-progress-anim { animation: roll-countdown linear forwards; }
.roll-hint {
  font-size: 11px;
  letter-spacing: 1px;
  color: #3a6688;
  margin-top: 8px;
}
#btn-toggle-quick-resolve.active {
  color: #ffe066;
  border-color: rgba(255,224,102,0.6);
  background: rgba(255,224,102,0.18);
}
.roll-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.roll-dice-row { margin-bottom: 14px; }
.roll-dice-row.hidden { display: none; }
.roll-dice-label { font-size: 13px; color: #9fc0e0; margin-bottom: 6px; }
.dice-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 28px;
  border-radius: 8px;
  background: #0d3870;
  border: 2px solid #1a6098;
  color: #90c0e0;
  animation: die-pop 0.35s ease-out backwards;
}
.die:nth-child(1) { animation-delay: 0s; }
.die:nth-child(2) { animation-delay: 0.08s; }
.die:nth-child(3) { animation-delay: 0.16s; }
.die:nth-child(4) { animation-delay: 0.24s; }
.die-hit { border-color: #ff9f40; color: #ff9f40; }
.die-evade { border-color: #4fc3f7; color: #4fc3f7; }
.die-rolling { animation: die-shake 0.12s linear infinite; }
.die-settle { animation: die-settle-pop 0.3s ease-out; }
@keyframes die-shake {
  0%   { transform: rotate(0deg)   scale(1);    }
  25%  { transform: rotate(-8deg)  scale(1.05); }
  50%  { transform: rotate(0deg)   scale(0.95); }
  75%  { transform: rotate(8deg)   scale(1.05); }
  100% { transform: rotate(0deg)   scale(1);    }
}
@keyframes die-settle-pop {
  0%   { transform: scale(1.35); }
  60%  { transform: scale(0.9);  }
  100% { transform: scale(1);    }
}
.roll-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #8ab4cc;
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.roll-legend-hit   { color: #ff9f40; }
.roll-legend-evade { color: #4fc3f7; }
.roll-legend-sep   { color: #556677; }
.roll-result {
  font-size: 16px;
  font-weight: 600;
  color: #ffe066;
  margin-top: 4px;
  opacity: 0;
}
.roll-result-play {
  animation: roll-result-in 0.3s ease-out 0.5s forwards;
}

@keyframes die-pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes roll-result-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ======================================================
   戰鬥畫面整體
   ====================================================== */

#screen-battle.active {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 100vh;
  /* HD-2D 大氣：明亮海洋色調 */
  background:
    radial-gradient(ellipse 60% 38% at 50% 118%, rgba(30,120,220,0.55) 0%, transparent 70%),
    radial-gradient(ellipse 42% 30% at  8% 55%,  rgba(10,60,160,0.45) 0%, transparent 60%),
    radial-gradient(ellipse 42% 30% at 92% 55%,  rgba(10,70,180,0.45) 0%, transparent 60%),
    radial-gradient(ellipse 70% 28% at 50% 0%,   rgba(6,30,80,0.6) 0%, transparent 100%),
    linear-gradient(180deg, #082550 0%, #0d3568 42%, #103878 100%);
}

/* ── 頂部旗艦 HUD（三欄） ── */
.battle-hud {
  height: 96px;
  background: rgba(6, 26, 64, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(60, 140, 220, 0.30);
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  align-items: stretch;
  width: 100%;
}

/* ── 旗艦面板（P1 左 / P2 右） ── */
.hud-flagship {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.hud-flagship-p1 { border-right: 1px solid rgba(60, 140, 220, 0.20); }
.hud-flagship-p2 { border-left:  1px solid rgba(60, 140, 220, 0.20); }

.hud-fs-sprite {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.hud-fs-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hud-fs-info-right { text-align: right; }

.hud-fs-nickname {
  font-size: 13px;
  font-weight: 700;
  color: #ddeeff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-fs-ship {
  font-size: 11px;
  color: #7aaac8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-fs-hp { display: flex; gap: 3px; flex-wrap: wrap; }
.hud-fs-hp-right { justify-content: flex-end; }

.hud-hp-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.3);
  flex-shrink: 0;
}
.hud-hp-dot-full    { background: #4fd67a; box-shadow: 0 0 3px rgba(79,214,122,0.5); }
.hud-hp-dot-full-p2 { background: #e05050; box-shadow: 0 0 3px rgba(220,80,80,0.5); }
.hud-hp-dot-empty   { background: rgba(255,255,255,0.1); }

/* ── 中央 HUD ── */
.hud-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 6px 12px;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

/* 遊戲標題 */
.battle-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
}
.bt-grand {
  font-size: 18px; font-weight: 900; letter-spacing: 3px; color: #ddeeff;
  text-shadow: 0 0 16px rgba(100,160,255,0.4);
}
.bt-blue {
  font-size: 18px; font-weight: 900; letter-spacing: 3px; color: #aac4ff;
  text-shadow: 0 0 16px rgba(130,100,255,0.5);
}
.bt-tactical {
  font-size: 9px; font-weight: 700; letter-spacing: 4px; color: #c9a84c;
  text-transform: uppercase; align-self: center;
}

/* 回合徽章 + banner */
.hud-mid-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
}
#turn-info.hud-turn-row { display: flex; align-items: center; }

.hud-turn-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid #3a5a8a;
  transition: border-color 0.3s;
  white-space: nowrap;
}
.hud-turn-badge.hud-p1 { border-left-color: #4fd67a; }
.hud-turn-badge.hud-p2 { border-left-color: #e05050; }

.hud-round-num  { font-size: 11px; color: #4a7ca8; font-weight: 600; }
.hud-player-name { font-size: 14px; font-weight: 800; color: #ddeeff; }

/* Banner */
.battle-hud .banner {
  font-size: 12px; font-weight: 600; color: #7fa8cc;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 260px; transition: color 0.2s;
}
.battle-hud .banner.banner-your-turn    { color: #4fd67a; font-weight: 700; }
.battle-hud .banner.banner-waiting-turn { opacity: 0.5; }

/* 狀態訊息 */
.battle-hud .status-message {
  min-height: 0; font-size: 11px; color: #ffcf5c;
  text-align: center; max-width: 320px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.battle-hud .status-message.status-error { color: #ff8080; }
.battle-hud .status-message.status-tip   { color: #5a8daa; }

/* ── 主戰鬥區三欄佈局 ── */
.battle-layout {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  align-items: flex-start;
}

/* ── 左側面板 ── */
.left-panel {
  width: 156px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ap-gauge-block {
  background: rgba(8, 42, 92, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(50, 130, 220, 0.28);
  border-radius: 12px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.ap-gauge-label {
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
  color: #5aa8d8; font-weight: 700;
}
.ap-gauge-value { display: flex; align-items: baseline; gap: 3px; }
.ap-big-num {
  font-size: 46px; font-weight: 900; color: #ddeeff; line-height: 1;
  text-shadow: 0 0 20px rgba(100,160,255,0.4);
  transition: color 0.3s; min-width: 2ch; text-align: center;
}
.ap-sep     { font-size: 16px; color: #3a6288; }
.ap-max-num { font-size: 16px; color: #5a88b0; font-weight: 600; }

.ap-gauge-block .hud-ap-track {
  width: 120px; height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px; overflow: hidden;
}
.hud-ap-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #2f8fe0, #5ab4ff);
  border-radius: 3px;
  transition: width 0.3s ease, background 0.3s;
}
.hud-ap-fill.hud-ap-low { background: linear-gradient(90deg, #c04040, #ff7070); }

.btn-end-turn-left {
  width: 100%; padding: 8px 0; border: none; border-radius: 7px;
  background: linear-gradient(145deg, #2a65b8, #1b3f7a);
  color: #ddeeff; font-size: 12px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 3px 10px rgba(35,100,210,0.4);
}
.btn-end-turn-left:hover    { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(35,100,210,0.6); }
.btn-end-turn-left:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.fleet-summon-block {
  background: rgba(8, 42, 92, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(50, 130, 220, 0.28);
  border-radius: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
}

/* ── 棋盤區 ── */
.board-area {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 700px;
  position: relative;
  align-self: flex-start;
}

/* HD-2D 景深暈映：棋盤四周暗化，中心清晰 */
.board-area::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 45%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 1;
}

#board-svg {
  background: transparent;
  border-radius: 12px;
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 130px);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    0 0 0 1px rgba(60,100,180,0.22),
    0 0 60px rgba(10,40,100,0.35);
  filter: saturate(1.3) contrast(1.1);
}

/* ── 六角格（浮島效果：無邊線） ── */
.hex { stroke: none; cursor: pointer; }
.hex-neutral { fill: rgba(16, 52, 92, 0.22); }
.hex-p1 { fill: rgba(30, 90, 50, 0.45); }
.hex-p2 { fill: rgba(100, 25, 25, 0.45); }
.hex-reef { fill: rgba(20, 12, 6, 0.30); cursor: not-allowed; }
.hex-highlight { fill: #d4b830; opacity: 0.88; }
.hex-staged { fill: #4fc3f7; opacity: 0.95; }

/* ── 船艦代幣 ── */
.ship-token { stroke: rgba(4,12,28,0.85); stroke-width: 2; cursor: pointer; }
.ship-p1 { fill: #35b05a; }
.ship-p2 { fill: #c44444; }
.ship-selected { stroke: #ffe066; stroke-width: 4; }
.ship-targetable { stroke: #ff9f40; stroke-width: 4; }
.ship-staged-target { stroke: #4fc3f7; stroke-width: 5; }
.ship-flagship { stroke-dasharray: 3 2; }
.ship-locked { opacity: 0.5; }
.ship-immune { opacity: 0.38; stroke: #8a9bb0; stroke-dasharray: 3 2; }
.ship-deadzone { opacity: 0.48; stroke: #b98af2; stroke-width: 3; stroke-dasharray: 3 2; }
.ship-flag-marker { font-size: 14px; fill: #ffe066; pointer-events: none; }
.hp-dot { pointer-events: none; stroke: rgba(0,0,0,0.35); stroke-width: 0.8; }
.hp-dot-full  { fill: #4fd67a; }
.hp-dot-empty { fill: rgba(255,255,255,0.14); }

/* 選取 / 可攻擊目標的光暈 */
.ship-group-selected   {
  filter: drop-shadow(0 0 14px rgba(255,224,102,0.95))
          drop-shadow(0 0  5px rgba(255,224,102,0.6));
}
.ship-group-targetable {
  filter: drop-shadow(0 0 12px rgba(255,140, 40,0.9))
          drop-shadow(0 0  4px rgba(255,140, 40,0.5));
}

/* ── 船艦名稱標籤 ── */
.ship-label {
  font-size: 9.5px;
  font-weight: 700;
  fill: rgba(255,255,255,0.92);
  paint-order: stroke fill;
  stroke: rgba(0,0,0,0.85);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  pointer-events: none;
  font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
}

/* ── 懸浮確認 / 取消按鈕 ── */
#board-action-btns {
  position: absolute;
  display: flex;
  gap: 6px;
  z-index: 20;
  transform: translateX(-50%);
  pointer-events: auto;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.6));
}
.board-btn {
  padding: 7px 16px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.3px; transition: transform 0.1s, box-shadow 0.1s;
}
.board-btn:hover { transform: translateY(-2px); }
.board-btn-confirm {
  background: linear-gradient(135deg, #2a65b8, #1b3f7a);
  color: #ddeeff; box-shadow: 0 3px 12px rgba(35,100,210,0.5);
}
.board-btn-confirm:hover { box-shadow: 0 5px 18px rgba(35,100,210,0.75); }
.board-btn-cancel {
  background: rgba(30,50,80,0.92); color: #9fc0e0;
  border: 1px solid #2e4a6a; padding: 7px 12px;
}
.board-btn-cancel:hover { color: #ddeeff; background: rgba(40,65,100,0.95); }

/* ── Toast 通知 ── */
.toast-container {
  position: absolute;
  bottom: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 5px;
  align-items: center;
  pointer-events: none;
  z-index: 30;
  width: 90%; max-width: 500px;
}
.battle-toast {
  background: rgba(6,24,58,0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(60,140,220,0.28);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: #bdd8f0;
  text-align: center;
  transform: translateY(8px); opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.battle-toast.toast-show { transform: translateY(0); opacity: 1; }

/* ── 特效動畫 ── */
.battle-fx { pointer-events: none; transform-box: fill-box; transform-origin: 50% 50%; opacity: 0; }
@keyframes fx-burst {
  0%   { opacity: 0;   transform: scale(0.25); }
  18%  { opacity: 1;   transform: scale(1.65); }
  55%  { opacity: 0.9; transform: scale(1.15); }
  100% { opacity: 0;   transform: scale(1.95); }
}
.battle-fx-play { animation: fx-burst 0.65s ease-out forwards; }

@keyframes ship-dodge {
  0%   { transform: translate(0, 0); }
  18%  { transform: translate(13px, -6px); }
  42%  { transform: translate(-10px, 4px); }
  68%  { transform: translate(7px, -3px); }
  88%  { transform: translate(-3px, 1px); }
  100% { transform: translate(0, 0); }
}
.ship-dodge { transform-box: fill-box; transform-origin: 50% 50%; animation: ship-dodge 0.52s ease-in-out; }

/* ── 回合交換全螢幕遮罩 ── */
.tc-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 20, 58, 0.85); backdrop-filter: blur(8px);
  cursor: pointer;
}
.tc-overlay.hidden { display: none; }
.tc-box {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 12px; animation: tc-in 0.3s ease-out;
}
@keyframes tc-in {
  from { opacity: 0; transform: scale(0.92) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.tc-flagship {
  width: 128px; height: 128px; image-rendering: pixelated;
  filter: drop-shadow(0 8px 28px rgba(100, 60, 220, 0.65));
}
.tc-title { font-size: 38px; font-weight: 900; letter-spacing: 5px; color: #ddeeff; text-shadow: 0 0 30px rgba(100,160,255,0.45); }
.tc-subtitle { font-size: 13px; letter-spacing: 3px; color: #5a88b0; text-transform: uppercase; }
.tc-progress { width: 180px; height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.tc-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2f8fe0, #aac4ff); border-radius: 2px; }
@keyframes tc-countdown { from { width: 100%; } to { width: 0%; } }
.tc-progress-fill.tc-progress-anim { animation: tc-countdown 2s linear forwards; }
.tc-hint { font-size: 11px; letter-spacing: 1px; color: #3a6688; }

/* ── 右側面板 ── */
.right-panel {
  width: 252px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.right-panel-tools {
  display: flex; gap: 6px; justify-content: flex-end;
}

/* 共用 panel-block */
.panel-block {
  background: rgba(8, 42, 92, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(50, 130, 220, 0.28);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
}
.panel-title {
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
  color: #5aa8d8; margin-bottom: 8px; font-weight: 700;
}
.status-message        { min-height: 0; color: #ffcf5c; font-size: 14px; }
.status-message.status-error { color: #ff8080; }
.status-message.status-tip   { color: #6a9dbf; font-size: 13px; }

/* 選取艦船面板 */
.selected-ship-layout { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.panel-ship-sprite {
  width: 72px; height: 72px; image-rendering: pixelated; flex-shrink: 0;
  border-radius: 8px; background: rgba(0,0,0,0.28); border: 1px solid rgba(70,110,185,0.15);
}
.selected-ship-text { font-size: 14px; line-height: 1.65; }
.panel-stats  { font-size: 13px; color: #6a98bc; line-height: 1.6; }
.panel-tag    { font-size: 12px; color: #9fc0e0; margin-top: 2px; }
.panel-hint   { font-size: 13px; color: #6a9dbf; }
.panel-status-warn { font-size: 13px; color: #ffcf5c; margin-top: 2px; }
.panel-status-info { font-size: 13px; color: #4fc3f7; margin-top: 2px; }
.panel-hp-row { display: flex; gap: 3px; align-items: center; margin: 4px 0; flex-wrap: wrap; }
.panel-hp-dot {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.3); flex-shrink: 0;
}
.panel-hp-dot-full  { background: #4fd67a; box-shadow: 0 0 3px rgba(79,214,122,0.5); }
.panel-hp-dot-empty { background: rgba(255,255,255,0.1); }
.selected-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* 旗艦人像（右側面板） */
.flagship-portrait-section {
  position: relative; width: 100%; height: 190px; overflow: hidden;
  border-radius: 8px; margin-bottom: 10px; background: #082038; flex-shrink: 0;
}
.flagship-portrait-art {
  width: 100%; height: 100%; object-fit: cover; object-position: center 12%;
  filter: saturate(0.8) brightness(0.9);
}
.flagship-portrait-gradient {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, #082038 0%, rgba(8,32,56,0.6) 45%, transparent 100%),
    linear-gradient(to bottom, rgba(8,32,56,0.35) 0%, transparent 30%);
}
.flagship-portrait-meta { position: absolute; bottom: 10px; left: 12px; right: 12px; }
.flagship-portrait-title {
  font-size: 13px; font-weight: 700; color: #e8f4ff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9); letter-spacing: 0.04em; margin-bottom: 5px;
}
.flagship-portrait-hp { display: flex; gap: 3px; flex-wrap: wrap; }

/* 待命艦隊按鈕 */
#reserve-list button { margin: 3px 4px 3px 0; }

/* ── 首頁暱稱輸入區 ── */
.intro-nickname-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
}
.intro-nickname-input {
  text-align: center;
  font-size: 16px;
  width: 220px;
}
.intro-nickname-error {
  font-size: 12px;
  min-height: 16px;
  text-align: center;
}

/* ── 暱稱輸入 ── */
.nickname-input {
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid rgba(60,130,210,0.35);
  background: rgba(255,255,255,0.06); color: #ddeeff;
  font-size: 15px; font-family: inherit; outline: none;
  transition: border-color 0.15s; letter-spacing: 0.03em;
}
.nickname-input:focus { border-color: #3a9af0; background: rgba(255,255,255,0.08); }
.nickname-input::placeholder { color: #3a5878; }
.nickname-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nickname-row-label { font-size: 11px; letter-spacing: 2px; color: #5a88b0; text-transform: uppercase; font-weight: 600; }

/* ── 響應式：中等螢幕 ── */
@media (max-width: 960px) {
  .hud-flagship { width: 200px; }
  .left-panel   { width: 136px; }
  .right-panel  { width: 220px; }
}

/* ── 響應式：小螢幕 ── */
@media (max-width: 720px) {
  .battle-layout { flex-direction: column; align-items: stretch; padding: 8px; gap: 8px; }
  .left-panel  { width: 100%; flex-direction: row; }
  .right-panel { width: 100%; }
  .battle-hud  { height: auto; min-height: 72px; }
  .hud-flagship { width: 160px; }
}

/* ======================================================
   首頁 / 連線對戰選單 — 重設計
   ====================================================== */

#screen-intro.active,
#screen-online-menu.active,
#screen-join-room.active,
#screen-online-wait.active {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 55% at 50% 108%, #2268c8 0%, transparent 65%),
    radial-gradient(ellipse 55% 40% at 12% 60%,  #1050a8 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 88% 60%,  #1060b8 0%, transparent 55%),
    linear-gradient(180deg, #082550 0%, #0d3568 45%, #124090 100%);
}

/* 動態六角格海洋紋理 */
.intro-ocean-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    repeating-linear-gradient(60deg,
      transparent, transparent 34px,
      rgba(255,255,255,0.018) 34px,
      rgba(255,255,255,0.018) 35px),
    repeating-linear-gradient(-60deg,
      transparent, transparent 34px,
      rgba(255,255,255,0.018) 34px,
      rgba(255,255,255,0.018) 35px),
    repeating-linear-gradient(0deg,
      transparent, transparent 58px,
      rgba(255,255,255,0.008) 58px,
      rgba(255,255,255,0.008) 59px);
  animation: ocean-drift 28s linear infinite;
}
@keyframes ocean-drift {
  from { background-position: 0 0, 0 0, 0 0; }
  to   { background-position: 70px 121px, 70px -121px, 0 58px; }
}

/* 左右艦娘裝飾 */
.intro-deco {
  position: absolute;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 0;
  pointer-events: none;
  z-index: 1;
}
.intro-deco-left  { left:  5%; }
.intro-deco-right { right: 5%; }

.intro-deco-ship {
  width: 160px;
  height: 160px;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 32px rgba(110, 70, 220, 0.55));
  animation: deco-bob 4.2s ease-in-out infinite;
}
.intro-deco-squid {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 16px rgba(60, 110, 255, 0.4));
  animation: deco-bob 3.4s ease-in-out infinite;
}
.intro-deco-delay,
.intro-deco-right .intro-deco-ship,
.intro-deco-right .intro-deco-squid {
  animation-delay: -2.1s;
}

@keyframes deco-bob {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-14px); }
}

/* 中央主體 */
.intro-center {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.intro-tagline {
  font-size: 12px;
  letter-spacing: 4px;
  color: #6fa8cc;
  text-transform: uppercase;
  margin-bottom: 22px;
  opacity: 0.85;
}

/* 主 LOGO */
.intro-logo {
  display: flex;
  gap: 18px;
  align-items: baseline;
  line-height: 1;
}
.intro-logo-grand {
  font-size: 76px;
  font-weight: 900;
  letter-spacing: 10px;
  color: #ddeeff;
  text-shadow:
    0 0 30px rgba(100, 160, 255, 0.55),
    0 0 70px rgba(80,  120, 220, 0.25),
    0 2px  6px rgba(0,   0,   0, 0.5);
}
.intro-logo-blue {
  font-size: 76px;
  font-weight: 900;
  letter-spacing: 10px;
  color: #aac4ff;
  text-shadow:
    0 0 30px rgba(130, 100, 255, 0.7),
    0 0 70px rgba(100,  80, 220, 0.35),
    0 2px  6px rgba(0,    0,   0, 0.5);
}

.intro-logo-tactical {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 10px;
  color: #c9a84c;
  text-transform: uppercase;
  margin-top: 6px;
}
.intro-deco-line {
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c9a84c);
}
.intro-logo-tactical .intro-deco-line:last-child {
  background: linear-gradient(90deg, #c9a84c, transparent);
}

.intro-divider {
  width: 260px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, #3a5a8a 20%, #7060b0 50%, #3a5a8a 80%, transparent);
  margin: 28px auto;
}

/* 主按鈕 */
.intro-actions {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-bottom: 16px;
}
.btn-intro {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 14px 34px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  outline: 1px solid rgba(255,255,255,0.08);
  outline-offset: -1px;
}
.btn-intro:hover { transform: translateY(-3px); }

.btn-intro-primary {
  background: linear-gradient(145deg, #2a65b8, #1b3f7a);
  color: #ddeeff;
  box-shadow:
    0 4px 20px rgba(35, 100, 210, 0.45),
    inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-intro-primary:hover {
  box-shadow:
    0 8px 32px rgba(35, 100, 210, 0.65),
    inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-intro-secondary {
  background: linear-gradient(145deg, #5d3a96, #3a1f6a);
  color: #d8c8ff;
  box-shadow:
    0 4px 20px rgba(90, 55, 180, 0.45),
    inset 0 1px 0 rgba(255,255,255,0.10);
}
.btn-intro-secondary:hover {
  box-shadow:
    0 8px 32px rgba(90, 55, 180, 0.65),
    inset 0 1px 0 rgba(255,255,255,0.13);
}
.btn-intro-icon { font-size: 18px; }

.intro-actions-sub { margin-bottom: 28px; }

.intro-footer-hint {
  font-size: 11px;
  letter-spacing: 3px;
  color: #3a5878;
  text-transform: uppercase;
}

/* 房號輸入表單在新背景下的樣式 */
#screen-join-room .join-room-form input {
  background: rgba(255,255,255,0.06);
  border: 1px solid #3a5878;
  color: #ddeeff;
  font-size: 22px;
  letter-spacing: 5px;
}
#screen-join-room .join-room-form input::placeholder {
  color: #3a5878;
}

/* 等待畫面 room-code 在深色背景下 */
#screen-online-wait .room-code {
  font-size: 36px;
  letter-spacing: 8px;
  color: #ffe066;
  text-shadow: 0 0 18px rgba(255, 220, 80, 0.5);
  margin: 10px 0;
}

/* ======================================================
   艦隊編輯器（#screen-fleet 共用）
   ====================================================== */

#screen-fleet.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 50% 110%, #2268c8 0%, transparent 60%),
    linear-gradient(180deg, #082550 0%, #0d3568 45%, #124090 100%);
}

.fe-wrap {
  position: relative;
  width: 100%;
  max-width: 900px;
  padding: 28px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Header ── */
.fe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.fe-header-left { display: flex; align-items: center; }

/* Player tabs */
.fe-tabs {
  display: flex;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.fe-tab {
  padding: 7px 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6a98bc;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.fe-tab.active { background: #1878cc; color: #ddeeff; }
.fe-tab:hover:not(.active) { color: #a0c8e8; }

/* In-game label */
.fe-ingame-label {
  font-size: 17px;
  font-weight: 700;
  color: #ddeeff;
  letter-spacing: 1px;
}

/* Budget display */
.fe-budget { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.fe-budget-text { font-size: 13px; color: #7fa8cc; }
#fe-budget-used { font-size: 22px; font-weight: 800; color: #ffe066; }
.fe-budget-sep { font-size: 13px; }
.fe-budget-track {
  width: 200px;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.fe-budget-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2f8fe0, #5ab4ff);
  border-radius: 4px;
  transition: width 0.2s, background 0.2s;
}
.fe-budget-fill.fe-budget-over { background: linear-gradient(90deg, #d04040, #ff7070); }
@keyframes fe-budget-flash {
  0%, 100% { opacity: 1; }
  40%       { opacity: 0.25; }
}
.fe-budget-fill.fe-budget-flash { animation: fe-budget-flash 0.45s ease; }

/* ── Ship cards grid ── */
.fe-cards-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.fe-card {
  background: rgba(10, 48, 95, 0.88);
  border: 2px solid #1a5888;
  border-radius: 12px;
  padding: 14px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: border-color 0.18s, box-shadow 0.18s;
  cursor: default;
}
.fe-card:hover { border-color: #2a80c0; }
.fe-card.fe-flagship {
  border-color: #c9a84c;
  box-shadow: 0 0 22px rgba(201, 168, 76, 0.22), inset 0 0 18px rgba(201, 168, 76, 0.06);
}

/* Sprite */
.fe-sprite-wrap {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
}
.fe-sprite {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  transition: filter 0.2s;
}
.fe-flagship .fe-sprite {
  filter: drop-shadow(0 3px 10px rgba(201, 168, 76, 0.55));
}

/* Card text */
.fe-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #ddeeff;
  text-align: center;
  line-height: 1.3;
}
.fe-card-role {
  font-size: 10px;
  color: #5a8daa;
  text-align: center;
  line-height: 1.35;
  margin: 2px 0 4px;
  padding: 0 4px;
}
.fe-card-stats {
  font-size: 11px;
  color: #6a98bc;
  text-align: center;
  line-height: 1.45;
}
.fe-card-cost {
  font-size: 17px;
  font-weight: 800;
  color: #ffe066;
  line-height: 1;
  margin: 2px 0;
}
.fe-card-cost span { font-size: 11px; font-weight: 400; color: #7fa8cc; }

/* Counter */
.fe-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.fe-dec, .fe-inc {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
}
.fe-dec { background: rgba(255,255,255,0.07); color: #7fa8cc; }
.fe-dec:hover:not(:disabled) { background: rgba(255,255,255,0.14); color: #ddeeff; }
.fe-dec:disabled { opacity: 0.3; cursor: not-allowed; }
.fe-inc { background: rgba(47,143,224,0.22); color: #5ab4ff; }
.fe-inc:hover { background: rgba(47,143,224,0.42); transform: scale(1.12); }
.fe-count {
  font-size: 22px;
  font-weight: 800;
  color: #ddeeff;
  min-width: 22px;
  text-align: center;
}
.fe-card.fe-has-ships .fe-count { color: #5ab4ff; }

/* Flagship toggle button */
.fe-flagship-btn {
  margin-top: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #3a5a80;
  background: transparent;
  color: #6a98bc;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.fe-flagship-btn:hover:not(.fe-vis-hidden) {
  border-color: #c9a84c;
  color: #c9a84c;
}
.fe-flagship-btn.active {
  background: rgba(201,168,76,0.14);
  border-color: #c9a84c;
  color: #ffe066;
  font-weight: 700;
}
.fe-flagship-btn.fe-vis-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ── Footer ── */
.fe-footer {
  position: relative;
  z-index: 201;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 80px;
}
.fe-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

/* ── 本機對戰選擇 modal ── */
.start-local-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #1a5888;
}
.start-local-row:last-of-type { border-bottom: none; }
.start-local-player-label {
  width: 54px;
  font-weight: 700;
  color: #9fc0e0;
  flex-shrink: 0;
  padding-top: 6px;
  font-size: 15px;
}
.start-local-options { display: flex; gap: 12px; flex-wrap: wrap; }
.start-local-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #1a5888;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.start-local-opt:has(input:checked) {
  border-color: #2f8fe0;
  background: rgba(47,143,224,0.08);
}
.start-local-opt:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.start-local-opt input[type=radio] { margin: 0; accent-color: #2f8fe0; }
.start-local-opt-text { display: flex; flex-direction: column; gap: 3px; }
.start-local-opt-main { font-size: 14px; color: #ddeeff; }

/* Fleet status badges */
.fe-fleet-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  color: #6a98bc;
}
.fe-fleet-badge.has-fleet {
  background: rgba(79,214,122,0.15);
  color: #4fd67a;
}

/* ── 艦隊組建：旗艦預覽（從下方滑出，大圖疊在頁面上） ── */
.fe-flagship-preview {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: min(100vh, 500px);
  background: #061832;
  z-index: 200;
  pointer-events: none;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 15%);
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.52s cubic-bezier(0.15,0,0.1,1), opacity 0.4s ease;
}
.fe-flagship-preview.fe-preview-visible {
  transform: translateY(0);
  opacity: 1;
}
.fe-preview-art-wrap {
  position: absolute;
  inset: 0;
}
.fe-preview-art {
  position: absolute;
  right: 12%;   /* ← 圖片距右邊距，增大往左（往中間）移 */
  bottom: 0;
  height: 110%;
  width: auto;
  max-width: 65%;
  object-fit: contain;
  object-position: bottom right;
  transition: opacity 0.18s ease;
}
.fe-preview-art-gradient {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, #061832 0%, #061832 28%, rgba(6,18,50,0.72) 52%, transparent 76%),
    linear-gradient(to bottom, rgba(6,18,50,0.55) 0%, transparent 22%);
  pointer-events: none;
}
.fe-preview-info {
  position: absolute;
  left: 30%;   /* ← 文字距左邊距，增大往右（往中間）移 */
  bottom: 44px;
  max-width: 42%;
}
.fe-preview-label {
  font-size: 10px;
  letter-spacing: 0.32em;
  color: #4a7fa8;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.fe-preview-name {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-shadow: 0 0 40px rgba(80,140,220,0.45);
  margin-bottom: 12px;
}
.fe-preview-role {
  font-size: 13px;
  color: #7aaac8;
  line-height: 1.65;
  max-width: 260px;
}

/* ======================================================
   旗艦指定演出（Fleet Build 全螢幕）
   ====================================================== */

.flagship-reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #030b18;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.flagship-reveal-overlay:not(.hidden) {
  pointer-events: auto;
}
.flagship-reveal-overlay.reveal-active {
  opacity: 1;
}
.flagship-reveal-content {
  position: relative;
  width: 100%;
  height: 100%;
}
/* 人設圖：從右側滑入 */
.flagship-reveal-art {
  position: absolute;
  right: -5%;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: 70%;
  object-fit: contain;
  object-position: bottom right;
  transform: translateX(80px);
  opacity: 0;
  transition: transform 0.75s cubic-bezier(0.15, 0, 0.1, 1) 0.1s,
              opacity   0.55s ease 0.1s;
}
.flagship-reveal-overlay.reveal-active .flagship-reveal-art {
  transform: translateX(0);
  opacity: 1;
}
/* 漸層遮罩：讓左半邊保持可讀 */
.flagship-reveal-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, #030b18 0%, #030b18 28%, rgba(3,11,24,0.7) 50%, transparent 75%),
    linear-gradient(to top,   #030b18 0%, transparent 18%);
  pointer-events: none;
}
/* 文字資訊：從左側淡入 */
.flagship-reveal-info {
  position: absolute;
  left: 8%;
  top: 50%;
  transform: translateY(calc(-50% + 24px));
  opacity: 0;
  transition: opacity 0.55s ease 0.35s, transform 0.55s ease 0.35s;
}
.flagship-reveal-overlay.reveal-active .flagship-reveal-info {
  opacity: 1;
  transform: translateY(-50%);
}
.flagship-reveal-eyebrow {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: #4a7fa8;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.flagship-reveal-shipname {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  line-height: 1.05;
  text-shadow: 0 0 40px rgba(80,140,220,0.45);
  margin-bottom: 16px;
}
.flagship-reveal-role {
  font-size: 15px;
  color: #7aaac8;
  max-width: 280px;
  line-height: 1.7;
}
/* 確定按鈕：左下角淡入 */
.flagship-reveal-btn {
  position: absolute;
  bottom: 48px;
  left: 8%;
  background: transparent;
  border: 1px solid rgba(74,127,168,0.7);
  color: #aed4f0;
  padding: 11px 30px;
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  border-radius: 2px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.45s ease 0.6s, transform 0.45s ease 0.6s,
              background 0.2s, color 0.2s, border-color 0.2s;
}
.flagship-reveal-overlay.reveal-active .flagship-reveal-btn {
  opacity: 1;
  transform: translateY(0);
}
.flagship-reveal-btn:hover {
  background: rgba(26,58,90,0.85);
  color: #fff;
  border-color: #6a9dbf;
}

/* ======================================================
   遊戲結束全螢幕
   ====================================================== */

.gameover-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: #020810;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
.gameover-overlay:not(.hidden) {
  pointer-events: auto;
}
.gameover-overlay.gameover-active {
  opacity: 1;
}
/* 勝者人設圖：大，右側 */
.gameover-winner-art {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 100%;
  width: auto;
  max-width: 65%;
  object-fit: contain;
  object-position: bottom right;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.75s ease 0.3s, transform 0.75s cubic-bezier(0.15,0,0.1,1) 0.3s;
}
.gameover-overlay.gameover-active .gameover-winner-art {
  opacity: 1;
  transform: translateX(0);
}
/* 漸層遮罩 */
.gameover-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, #020810 0%, #020810 25%, rgba(2,8,16,0.6) 55%, transparent 80%),
    linear-gradient(to top,   #020810 0%, transparent 20%);
  pointer-events: none;
  z-index: 1;
}
/* 敗者圖：右下角，半透明下沉 */
.gameover-loser-art {
  position: absolute;
  right: 0;
  bottom: -12%;
  height: 55%;
  width: auto;
  object-fit: contain;
  opacity: 0;
  filter: grayscale(0.7) saturate(0.4);
  transform: rotate(12deg) translateY(30px);
  transition: opacity 0.8s ease 0.6s, transform 0.8s ease 0.6s;
  z-index: 0;
}
.gameover-overlay.gameover-active .gameover-loser-art {
  opacity: 0.18;
  transform: rotate(12deg) translateY(0);
}
/* 左側文字區域 */
.gameover-content {
  position: absolute;
  left: 8%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  max-width: 360px;
  opacity: 0;
  transition: opacity 0.6s ease 0.4s, transform 0.6s ease 0.4s;
  transform: translateY(calc(-50% + 20px));
}
.gameover-overlay.gameover-active .gameover-content {
  opacity: 1;
  transform: translateY(-50%);
}
.gameover-eyebrow {
  font-size: 11px;
  letter-spacing: 0.4em;
  color: #4a7fa8;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.gameover-overlay.gameover-defeat .gameover-eyebrow { color: #7a4a4a; }
.gameover-title {
  font-size: clamp(36px, 5.5vw, 58px);
  font-weight: 800;
  color: #fff;
  margin: 0 0 10px;
  text-shadow: 0 0 40px rgba(80,140,220,0.5);
  letter-spacing: 0.03em;
}
.gameover-overlay.gameover-defeat .gameover-title {
  text-shadow: 0 0 40px rgba(200,80,80,0.4);
}
.gameover-sub {
  font-size: 14px;
  color: #7aaac8;
  margin-bottom: 28px;
}
.gameover-overlay.gameover-defeat .gameover-sub { color: #a07a7a; }
.gameover-divider {
  width: 50px;
  height: 2px;
  background: linear-gradient(to right, #4a7fa8, transparent);
  margin-bottom: 32px;
}
.gameover-overlay.gameover-defeat .gameover-divider {
  background: linear-gradient(to right, #7a4a4a, transparent);
}
.gameover-restart-btn {
  background: transparent;
  border: 1px solid rgba(74,127,168,0.7);
  color: #aed4f0;
  padding: 13px 34px;
  font-size: 14px;
  letter-spacing: 0.12em;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.gameover-restart-btn:hover {
  background: rgba(26,58,90,0.9);
  color: #fff;
  border-color: #6a9dbf;
}
.gameover-overlay.gameover-defeat .gameover-restart-btn {
  border-color: rgba(168,74,74,0.7);
  color: #f0aeae;
}
.gameover-overlay.gameover-defeat .gameover-restart-btn:hover {
  background: rgba(90,26,26,0.9);
  border-color: #bf6a6a;
}
