/* ====== AirStrategic ====== */
:root {
  --bg: #1f1f29;
  --bg-deep: #15151d;
  --panel: #2a2a38;
  --panel-edge: #3a3a4c;
  --text: #e8e6df;
  --muted: #9a98a8;
  --tan: #d6bb86;
  --olive: #747748;
  --brown: #6f553e;
  --blue: #5b8fd6;
  --blue-deep: #2f5f9e;
  --red: #d64545;
  --red-deep: #a02020;
  --gold: #e8c548;
  --green: #6fce6f;
  --danger: #ff5d5d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 70% -10%, #2c2c40 0%, var(--bg) 55%, var(--bg-deep) 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; align-items: center; justify-content: center; }

/* ---------- landing ---------- */
.landing-inner { text-align: center; padding: 32px 16px; max-width: 900px; width: 100%; }

.logo {
  font-size: clamp(3rem, 8vw, 5.5rem);
  letter-spacing: .06em;
  margin: 0 0 4px;
  font-weight: 900;
  color: var(--blue);
  text-shadow: 0 2px 0 var(--blue-deep), 0 6px 24px rgba(91,143,214,.35);
  font-style: italic;
}
.logo span { color: var(--red); text-shadow: 0 2px 0 var(--red-deep), 0 6px 24px rgba(214,69,69,.35); }
.tagline { color: var(--muted); margin: 0 0 36px; font-size: 1.05rem; letter-spacing: .04em; }

.tut-link { margin: -24px 0 30px; font-size: .95rem; }
.tut-link a { color: var(--gold); text-decoration: none; border-bottom: 1px dashed rgba(232,197,72,.5); padding-bottom: 2px; }
.tut-link a:hover { border-bottom-style: solid; }

.games-played { color: var(--muted); font-size: .9rem; margin: -18px 0 26px; letter-spacing: .04em; }
.games-played span { color: var(--gold); font-weight: 700; font-family: Consolas, monospace; }

.landing-cards { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }

.card {
  background: linear-gradient(180deg, var(--panel), #24242f);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 24px 28px;
  width: 340px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
  text-align: left;
}
.card h2 { margin: 0 0 6px; font-size: 1.25rem; }
.card p { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }

.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: .9rem; flex-wrap: wrap; }
.opt-row label { min-width: 150px; }
.opt-hint { color: var(--muted); font-size: .75rem; }
select {
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--panel-edge); border-radius: 6px; padding: 6px 8px;
}

.btn {
  cursor: pointer;
  background: var(--panel-edge);
  color: var(--text);
  border: 1px solid #4a4a5e;
  padding: 10px 20px;
  font-size: 1rem;
  border-radius: 8px;
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  border-color: var(--blue-deep);
  font-weight: 600;
  width: 100%;
  margin-top: 8px;
}
.btn.danger { background: linear-gradient(180deg, #8e2f2f, #6e1f1f); border-color: #6e1f1f; }
.btn.small { padding: 6px 14px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }

.code-input {
  width: 100%;
  font-size: 2rem;
  letter-spacing: .55em;
  text-align: center;
  padding: 10px 0 10px .55em;
  background: var(--bg-deep);
  color: var(--gold);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  font-family: Consolas, monospace;
}

.error-msg { color: var(--danger); margin-top: 20px; min-height: 1.2em; }

/* ---------- lobby ---------- */
.lobby-inner { text-align: center; width: 380px; }
.lobby-inner h2 { margin-top: 4px; }
.big-code {
  font-family: Consolas, monospace;
  font-size: 3.2rem;
  letter-spacing: .35em;
  padding-left: .35em;
  color: var(--gold);
  background: var(--bg-deep);
  border-radius: 10px;
  padding-top: 8px; padding-bottom: 8px;
  margin-bottom: 12px;
  user-select: all;
}
.lobby-inner .btn { width: 100%; margin-bottom: 16px; }

.radar {
  width: 110px; height: 110px; margin: 18px auto 6px;
  border-radius: 50%;
  border: 2px solid #3f6f4f;
  background:
    radial-gradient(circle, rgba(60,140,80,.15) 0%, rgba(20,40,25,.6) 70%),
    repeating-radial-gradient(circle, transparent 0 24px, rgba(90,180,110,.25) 25px 26px);
  position: relative; overflow: hidden;
}
.radar-sweep {
  position: absolute; inset: 0;
  background: conic-gradient(from 0deg, rgba(110,220,140,.55), transparent 70deg, transparent 360deg);
  animation: sweep 2.4s linear infinite;
  border-radius: 50%;
}
@keyframes sweep { to { transform: rotate(360deg); } }

/* ---------- game layout ---------- */
#screen-game.active { align-items: stretch; }
.game-layout {
  display: flex; gap: 14px; width: 100%;
  padding: 12px; max-height: 100vh;
}
.board-wrap {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  min-width: 0;
}
#board {
  height: calc(100vh - 24px);
  max-width: 100%;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.5));
}

.side-panel {
  flex: 0 0 300px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - 24px);
}
.panel-block {
  background: linear-gradient(180deg, var(--panel), #24242f);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  padding: 12px 14px;
}
.panel-block.grow { flex: 1 1 auto; min-height: 80px; display: flex; flex-direction: column; overflow: hidden; }
.panel-block h3 { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }

.you-banner { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
.you-banner .chip, .fleet-chip {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .85rem; font-weight: 700;
}
.chip.blue { background: var(--blue-deep); color: #dfeaff; }
.chip.red { background: var(--red-deep); color: #ffe2e2; }

.turn-banner { font-size: .95rem; color: var(--muted); }
.turn-banner.mine { color: var(--gold); font-weight: 700; animation: pulse-text 1.6s ease-in-out infinite; }
@keyframes pulse-text { 50% { opacity: .55; } }

.prompt { font-size: .92rem; min-height: 2.2em; color: var(--text); }
.action-buttons { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.action-buttons .btn { width: 100%; font-size: .9rem; padding: 8px 10px; }

.fleet-status { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.fleet-row { display: flex; align-items: center; gap: 8px; }
.fleet-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.ok { background: var(--green); }
.dot.done { background: #777; }
.dot.dead { background: #442222; border: 1px solid #663333; }
.fleet-row.dead { color: #6d6d7a; text-decoration: line-through; }

.log {
  overflow-y: auto; flex: 1 1 auto; font-size: .8rem; line-height: 1.5;
  color: var(--muted);
}
.log .entry { padding: 2px 0; border-bottom: 1px dotted #33333f; }
.log .entry.blue { border-left: 3px solid var(--blue); padding-left: 6px; }
.log .entry.red { border-left: 3px solid var(--red); padding-left: 6px; }
.log .entry.sys { border-left: 3px solid var(--gold); padding-left: 6px; color: var(--gold); }

.copyright { color: var(--muted); font-size: .75rem; margin-top: 40px; opacity: .7; }
.copyright a { color: var(--muted); text-decoration: underline; }
.copyright a:hover { color: var(--gold); }

.code-tag { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.code-tag span { color: var(--gold); font-family: Consolas, monospace; letter-spacing: .15em; }

/* ---------- board svg ---------- */
.hex-cell { stroke: var(--bg-deep); stroke-width: 1.2; }
.hex-cell.placeable { cursor: pointer; }
.hex-cell.dim { opacity: .92; }

.move-target { cursor: pointer; }
.move-ring { fill: none; stroke-width: 3; pointer-events: none; }
.move-ring.safe { stroke: var(--green); }
.move-ring.fatal { stroke: var(--danger); }
.move-ring.win { stroke: var(--gold); }
.move-ring.msl { stroke: #ff9d3c; }
.move-fill.safe { fill: rgba(111,206,111,.22); }
.move-fill.fatal { fill: rgba(255,93,93,.25); }
.move-fill.win { fill: rgba(232,197,72,.3); }
.move-fill.msl { fill: rgba(255,157,60,.25); }
.move-target:hover .move-fill.safe { fill: rgba(111,206,111,.45); }
.move-target:hover .move-fill.fatal { fill: rgba(255,93,93,.45); }
.move-target:hover .move-fill.win { fill: rgba(232,197,72,.5); }
.move-target:hover .move-fill.msl { fill: rgba(255,157,60,.45); }
/* next-turn flight preview shown while hovering a launch option */
.next-flight { pointer-events: none; }
.move-ring.msl.next { stroke-dasharray: 5 4; }

.piece { cursor: default; }
.piece.selectable { cursor: pointer; }
.piece.selectable .sprite-img { animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { opacity: .85; } }
.piece.done .sprite-img { filter: saturate(.25) brightness(.75); }
.piece.selected-ring { }

.sel-ring { fill: none; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 8 5; pointer-events: none; animation: spin-ring 6s linear infinite; transform-origin: center; transform-box: fill-box; }
@keyframes spin-ring { to { transform: rotate(360deg); } }

.badge-num { font: 700 12px Consolas, monospace; fill: #fff; pointer-events: none; }
.badge-done { pointer-events: none; }

.badge-launch { cursor: pointer; }
.badge-launch-icon { font-size: 9px; pointer-events: none; }
.badge-launch-ring { animation: launch-pulse 1.8s ease-in-out infinite; }
.badge-launch:hover .badge-launch-ring { stroke: #ffd166; fill: #3a3a4c; animation: none; }
@keyframes launch-pulse { 50% { stroke-opacity: .45; } }

.crosshair { cursor: pointer; }
.crosshair circle { fill: none; stroke: var(--danger); stroke-width: 2.4; }
.crosshair line { stroke: var(--danger); stroke-width: 2.4; }
.crosshair:hover circle { stroke: #fff; }
.crosshair:hover line { stroke: #fff; }

/* ---------- combat effects ---------- */
.fx-fire {
  transform-box: fill-box; transform-origin: center;
  animation: fx-fire .72s ease-out forwards;
  opacity: 0;
}
@keyframes fx-fire {
  0% { opacity: 0; transform: scale(.15); }
  18% { opacity: 1; transform: scale(.8); }
  60% { opacity: .95; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.5); }
}

.fx-ring {
  fill: none; stroke: #ffd166; stroke-width: 4;
  transform-box: fill-box; transform-origin: center;
  animation: fx-ring .65s ease-out forwards;
}
@keyframes fx-ring {
  0% { opacity: .95; transform: scale(.35); stroke-width: 5; }
  100% { opacity: 0; transform: scale(2.7); stroke-width: 1; }
}

.fx-shard {
  animation: fx-shard .6s ease-out forwards;
}
@keyframes fx-shard {
  0% { opacity: 1; transform: translateX(4px); }
  100% { opacity: 0; transform: translateX(34px); }
}

.fx-muzzle {
  animation: fx-muzzle .13s ease-out 3;
}
@keyframes fx-muzzle {
  0% { opacity: 0; }
  40% { opacity: 1; }
  100% { opacity: 0; }
}

.fx-flash {
  transform-box: fill-box; transform-origin: center;
  animation: fx-flash .5s ease-out forwards;
}
@keyframes fx-flash {
  0% { opacity: .95; transform: scale(.3); }
  100% { opacity: 0; transform: scale(1.8); }
}

.setup-glow { animation: glow-cell 1.5s ease-in-out infinite; }
@keyframes glow-cell { 50% { opacity: .55; } }

/* ---------- overlays & toast ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,10,16,.75);
  display: flex; align-items: center; justify-content: center;
}
.overlay[hidden], .toast[hidden] { display: none; }
.overlay-card { text-align: center; width: 360px; }
.overlay-card h2 { font-size: 1.6rem; }
.overlay-actions { display: flex; gap: 10px; margin-top: 16px; }
.overlay-actions .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%);
  z-index: 60;
  background: #101018ee; color: var(--text);
  border: 1px solid var(--panel-edge);
  padding: 10px 22px; border-radius: 30px;
  font-size: .95rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toast-in .25s ease-out;
}
.toast.warn { border-color: var(--danger); color: #ffc9c9; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .game-layout { flex-direction: column; max-height: none; }
  #board { height: auto; width: 100%; max-height: 70vh; }
  .side-panel { flex: 1 1 auto; max-height: none; }
}
