/* ============================================================================
   styles.css — Interfaccia Imperium Galactica (tema sci-fi, 100% offline)
   ============================================================================ */
:root {
  --bg0: #04060f;
  --bg1: #0a1024;
  --panel: #0c1430;
  --panel2: #111a3a;
  --border: #20305c;
  --border-bright: #2f4a8e;
  --text: #e8eefc;
  --muted: #8593b5;
  --gold: #ffd86b;
  --cyan: #5fd6ff;
  --accent: #3a78ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", system-ui, sans-serif; color: var(--text);
  background:
    radial-gradient(1300px 760px at 82% -12%, rgba(64,120,255,.30), transparent 60%),
    radial-gradient(1000px 680px at 8% 112%, rgba(150,70,255,.26), transparent 60%),
    radial-gradient(900px 600px at 50% 48%, rgba(20,210,210,.10), transparent 70%),
    radial-gradient(700px 520px at 95% 75%, rgba(255,90,160,.10), transparent 65%),
    var(--bg0);
}
/* campo stellare di sfondo (due strati di profondità) */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .8;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff, transparent),
    radial-gradient(2px 2px at 70% 60%, #cfe0ff, transparent),
    radial-gradient(1.3px 1.3px at 40% 80%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 90% 20%, #bcd2ff, transparent),
    radial-gradient(2px 2px at 55% 15%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 15% 65%, #dde9ff, transparent),
    radial-gradient(1px 1px at 33% 47%, #fff, transparent),
    radial-gradient(1px 1px at 78% 88%, #cfe0ff, transparent);
  background-size: 480px 480px, 520px 520px, 360px 360px, 420px 420px, 600px 600px, 300px 300px, 250px 250px, 330px 330px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: .9; } }
/* vignettatura per profondità */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(120% 120% at 50% 40%, transparent 55%, rgba(0,0,0,.55) 100%); }
.screen { height: 100vh; position: relative; z-index: 1; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

button { cursor: pointer; border: 1px solid var(--border-bright); background: linear-gradient(180deg, #1a2750, #131e3e);
  color: var(--text); padding: 7px 13px; border-radius: 7px; font-size: 13px; transition: all .12s; }
button:hover { background: linear-gradient(180deg, #243465, #18244a); border-color: #3c5aa0; transform: translateY(-1px); }
button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
button.primary { background: linear-gradient(180deg, #3f86ff, #2f63e6); border-color: #4f90ff; font-weight: 600;
  box-shadow: 0 0 14px rgba(58,120,255,.45); color: #fff; }
button.primary:hover { background: linear-gradient(180deg, #56a0ff, #3b74ff); }
button.small { padding: 4px 9px; font-size: 12px; }

/* ---------- Setup ---------- */
#setup { display: flex; align-items: center; justify-content: center; }
.setup-box { background: linear-gradient(180deg, rgba(16,24,52,.95), rgba(8,12,28,.95));
  border: 1px solid var(--border-bright); border-radius: 16px; padding: 34px 38px; width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.05); backdrop-filter: blur(6px); }
.setup-box h1 { margin: 0; letter-spacing: 6px; font-size: 32px; text-align: center; font-weight: 800;
  background: linear-gradient(90deg, #ffe08a, #ffb04f); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(255,176,79,.25); }
.subtitle { text-align: center; color: var(--muted); margin: 6px 0 24px; letter-spacing: 1px; font-size: 13px; }
.setup-box label { display: block; margin: 16px 0 5px; font-size: 13px; color: #b9c5e6; letter-spacing: .3px; }
.setup-box select, .setup-box input[type=number], .setup-box input[type=text] {
  width: 100%; padding: 9px; background: #070d20; border: 1px solid var(--border); color: var(--text); border-radius: 7px; }
.setup-box select:focus, .setup-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(58,120,255,.25); }
.player-row { display: flex; gap: 9px; align-items: center; margin: 9px 0; }
.player-row .swatch { width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; box-shadow: 0 0 10px currentColor; }
.player-row input[type=text] { flex: 1; }
#startBtn { width: 100%; margin-top: 26px; padding: 12px; font-size: 16px; letter-spacing: 1px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.5; }

/* ---------- Topbar ---------- */
#game { display: flex; flex-direction: column; }
#topbar { display: flex; align-items: center; gap: 22px; padding: 10px 18px;
  background: linear-gradient(180deg, rgba(14,22,48,.96), rgba(9,14,32,.96)); border-bottom: 1px solid var(--border-bright);
  box-shadow: 0 2px 18px rgba(0,0,0,.4); }
#turnInfo { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.turn-num { color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.active-faction { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 15px; }
.active-faction .fdot { width: 13px; height: 13px; border-radius: 50%; background: var(--fc); box-shadow: 0 0 12px var(--fc); }
.ai-pill { font-size: 10px; background: #28365e; color: #aab9e0; padding: 1px 6px; border-radius: 10px; letter-spacing: 1px; }

/* Stepper fasi */
.stepper { display: flex; align-items: center; gap: 4px; }
.step { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 4px 11px; border-radius: 20px; border: 1px solid transparent; letter-spacing: .3px; white-space: nowrap; }
.step .step-n { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px;
  border-radius: 50%; background: #1b2747; font-size: 10px; font-weight: 700; }
.step.done { color: #7fe0a0; }
.step.done .step-n { background: #1d4030; color: #7fe0a0; }
.step.active { color: var(--gold); background: rgba(255,216,107,.1); border-color: rgba(255,216,107,.4);
  box-shadow: 0 0 14px rgba(255,216,107,.18); }
.step.active .step-n { background: var(--gold); color: #1a1300; }
.step-sep { width: 16px; height: 1px; background: var(--border); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Main ---------- */
#main { display: flex; flex: 1; min-height: 0; }
#boardWrap { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 10px; min-width: 0; background:
    radial-gradient(circle at 50% 35%, rgba(40,60,120,.16), transparent 70%), #060912; }
#board { width: 100%; height: 100%; display: block; }

/* ---------- Sidebar ---------- */
#sidebar { width: 350px; flex: 0 0 350px; border-left: 1px solid var(--border-bright);
  background: linear-gradient(180deg, rgba(11,18,42,.96), rgba(7,11,26,.98)); display: flex; flex-direction: column; overflow: hidden; }
#sidebar section { padding: 13px 15px; border-bottom: 1px solid #16213f; }
#sidebar h3 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px; color: #7c8bb3; }
#playerPanel .pname { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
#playerPanel .pname .dot { width: 14px; height: 14px; box-shadow: 0 0 10px currentColor; }
.res { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 11px; }
.res .pill { display: flex; align-items: center; gap: 7px; background: #0b1430; border: 1px solid #1c294c;
  border-radius: 8px; padding: 6px 9px; font-size: 13px; }
.res .pill .ic { font-size: 14px; }
.res .pill b { color: #fff; }
.res .pill.money { grid-column: 1 / -1; background: linear-gradient(90deg, rgba(255,216,107,.12), rgba(255,216,107,.04));
  border-color: rgba(255,216,107,.35); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

#logPanel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#logBody { overflow-y: auto; font-size: 12px; line-height: 1.55; color: #aebbd6; flex: 1; padding-right: 4px; }
#logBody div { padding: 2px 0; border-bottom: 1px solid #101a32; }

#selectionPanel { max-height: 44%; overflow-y: auto; }
.action-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }
.info-line { font-size: 13px; margin: 4px 0; color: #c2cde6; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: #24345e; margin-left: 4px; color: #b9c7ea; }
.fleet-card { border: 1px solid #1c294c; border-radius: 9px; padding: 8px 10px; margin: 7px 0; background: #0a1230; }
.fleet-card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,216,107,.3), 0 0 16px rgba(255,216,107,.12); }
.fc-head { display: flex; align-items: center; gap: 7px; font-size: 14px; margin-bottom: 8px; }
.fc-arrow { color: var(--gold); }
.fc-units { display: flex; gap: 8px; }
.fc-unit { display: flex; align-items: center; gap: 4px; background: #0b1430; border: 1px solid #1c294c; border-radius: 8px; padding: 4px 8px; flex: 1; justify-content: center; }
.fc-unit svg { display: block; }
.fc-unit .fc-n { font-size: 15px; font-weight: 800; color: #fff; }
.fc-unit.zero { opacity: .38; }
/* Inventario sugli angoli */
.inv-money { font-size: 8px; font-weight: 700; text-anchor: middle; fill: #ffe08a; }
.inv-count { font-size: 10px; font-weight: 800; text-anchor: start; fill: #fff; paint-order: stroke; stroke: #05080f; stroke-width: 2px; }

/* ---------- Board cells (SVG) ---------- */
.hex-wall { stroke: #03050c; stroke-width: 0.4; pointer-events: none; }
.hex-rim { fill: none; stroke: rgba(150,190,255,0.32); stroke-width: 1.6; pointer-events: none; stroke-linejoin: round; }
.hex { stroke: #26365e; stroke-width: 1.3; cursor: pointer; transition: filter .1s; }
.hex:hover { filter: brightness(1.35); stroke: #3c5aa0; }
.hex-reachable { stroke: var(--gold); stroke-width: 3; filter: drop-shadow(0 0 6px rgba(255,216,107,.7)); }
.hex-selected { stroke: #ffffff; stroke-width: 3; filter: drop-shadow(0 0 7px rgba(255,255,255,.8)); }
.fog { font-size: 16px; fill: #2c3a5e; text-anchor: middle; pointer-events: none; font-weight: 700; }
.cell-label { font-size: 9px; fill: #8fa0c6; pointer-events: none; text-anchor: middle; letter-spacing: .3px; }
.planet-name { font-size: 10px; fill: #eaf2ff; pointer-events: none; text-anchor: middle; font-weight: 700;
  paint-order: stroke; stroke: #050912; stroke-width: 2.5px; }
.tile-icon { font-size: 22px; text-anchor: middle; pointer-events: none; }
.start-mark { font-size: 13px; fill: var(--gold); text-anchor: middle; pointer-events: none; opacity: .85; }
.badge-mini { font-size: 9px; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: #050912; stroke-width: 2px; fill: #fff; }
.fleet-badge { cursor: pointer; }
.fleet-count { font-size: 11px; font-weight: 800; pointer-events: none; text-anchor: middle; fill: #fff;
  paint-order: stroke; stroke: #060a14; stroke-width: 2.4px; }
.tok-count { font-size: 11px; font-weight: 800; pointer-events: none; text-anchor: middle; fill: #ffffff;
  paint-order: stroke; stroke: #05080f; stroke-width: 2.6px; }
.pawn-count { font-size: 9px; font-weight: 800; pointer-events: none; text-anchor: middle; fill: #ffffff; }
/* Pedine-astronave che fluttuano */
.ship-float { animation: shipbob 2.6s ease-in-out infinite; }
@keyframes shipbob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3.5px); } }
.fleet-badge { cursor: pointer; }
.fleet-badge:hover { filter: brightness(1.2); }

/* Legenda segnalini navi (sidebar) */
.ship-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.ship-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #b9c5e6; }
.ship-legend svg { display: block; }

/* Pulsanti di produzione con costo */
.prod-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 5px 0; padding: 7px 11px; text-align: left; }
.prod-btn .pb-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.prod-btn .pb-name svg { display: inline-block; vertical-align: middle; }
.prod-btn .pb-cost { font-size: 11px; color: #9fb0d6; white-space: nowrap; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(2,5,12,.72); display: flex; align-items: center; justify-content: center;
  z-index: 50; backdrop-filter: blur(4px); }
.modal-box { background: linear-gradient(180deg, rgba(16,24,52,.98), rgba(9,14,32,.98)); border: 1px solid var(--border-bright);
  border-radius: 14px; padding: 24px 28px; width: 470px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.05); }
.modal-box h3 { margin: 0 0 14px; color: var(--gold); letter-spacing: .5px; }
.modal-box p { line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.combat-log { font-size: 12px; font-family: "Consolas", monospace; background: #050b1a; border: 1px solid #1b2747;
  border-radius: 8px; padding: 10px; max-height: 240px; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; color: #b9c7ea; }
.field-row { display: flex; align-items: center; gap: 9px; margin: 9px 0; font-size: 14px; }
.field-row input { width: 95px; padding: 6px; background: #070d20; border: 1px solid var(--border); color: var(--text); border-radius: 6px; }
.win-banner { text-align: center; }
.win-banner .big { font-size: 28px; margin: 12px 0; font-weight: 800;
  background: linear-gradient(90deg, #ffe08a, #ffb04f); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Dadi ---------- */
.die { display: inline-flex; align-items: baseline; gap: 1px; margin: 0 2px; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.die-face { font-size: 22px; }
.die-mult { font-size: 9px; color: #8593b5; transform: translateY(-6px); }
.die-pop { animation: diepop .28s ease; }
@keyframes diepop { 0% { transform: scale(.5) rotate(-18deg); } 60% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }

.battle-dice { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.battle-sec-h { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: #7c8bb3; margin-bottom: 5px; }
.round { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; padding: 5px 7px; border-radius: 7px;
  background: #0a1124; border: 1px solid #161f3c; margin: 4px 0; }
.round-n { font-size: 10px; color: #6f7c9c; width: 22px; font-weight: 700; }
.side-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-right: 4px; }
.side-tag.att { background: rgba(255,107,107,.18); color: #ff9a9a; }
.side-tag.def { background: rgba(95,150,255,.18); color: #9fb4ff; }
.round .vs { color: #54618a; margin: 0 5px; font-weight: 700; }
.round .kills { margin-left: auto; font-size: 13px; font-weight: 700; color: #ffb04f; }

.dice-line.big { display: flex; justify-content: center; gap: 16px; margin: 18px 0; }
.dice-line.big .die-face { font-size: 56px; }
.casino-outcome { text-align: center; font-size: 16px; font-weight: 700; min-height: 24px; margin-top: 6px; }
.casino-outcome.win { color: #6be08a; }
.casino-outcome.lose { color: #ff7a7a; }
.casino-outcome.push { color: #ffd86b; }

/* ---------- Icone sul tabellone ---------- */
.planet-emoji { font-size: 15px; text-anchor: middle; pointer-events: none; }
.tile-icon { font-size: 26px; }

/* Impulso sulla cella appena scoperta */
.pulse-ring { fill: none; stroke: var(--gold); stroke-width: 3; pointer-events: none; transform-box: fill-box; transform-origin: center;
  animation: pulsering .85s ease-out forwards; }
@keyframes pulsering { 0% { opacity: 0; transform: scale(.4); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(1.15); } }

/* ---------- Banner di scoperta / asteroidi (in alto, non bloccante) ---------- */
#bannerHost { position: fixed; top: 64px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.flash-banner { display: flex; align-items: center; gap: 14px; min-width: 300px; max-width: 440px; padding: 12px 18px;
  border-radius: 12px; background: linear-gradient(180deg, rgba(18,28,58,.97), rgba(10,16,36,.97)); border: 1px solid var(--border-bright);
  box-shadow: 0 14px 40px rgba(0,0,0,.55); transform: translateY(-22px); opacity: 0; transition: all .32s cubic-bezier(.2,.9,.3,1.2); }
.flash-banner.show { transform: translateY(0); opacity: 1; }
.flash-banner .fb-icon { font-size: 36px; line-height: 1; filter: drop-shadow(0 0 8px rgba(255,255,255,.25)); }
.fb-eyebrow { font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); }
.fb-title { font-size: 18px; font-weight: 800; }
.fb-sub { font-size: 12px; color: #b9c5e6; margin-top: 2px; }
.flash-banner.discovery { border-color: #3f6db0; }
.flash-banner.bonus { border-color: #3aa06a; box-shadow: 0 0 26px rgba(58,160,106,.3); }
.flash-banner.bonus .fb-title { color: #7fe0a0; }
.flash-banner.malus { border-color: #b0463f; box-shadow: 0 0 26px rgba(176,70,63,.3); }
.flash-banner.malus .fb-title { color: #ff9a8a; }

/* ---------- Card pianeta (colonizzazione) ---------- */
.discover-modal { text-align: center; }
.dm-icon { font-size: 56px; line-height: 1; margin: 4px 0 8px; filter: drop-shadow(0 0 16px var(--pc)); }
.dm-title { font-size: 22px; font-weight: 800; }
.dm-sub { color: var(--muted); margin-bottom: 12px; }
.dm-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; font-size: 13px; }
.dm-stats span { background: #0b1430; border: 1px solid #1c294c; border-radius: 8px; padding: 4px 9px; }

/* ---------- Combattimento visivo ---------- */
.battle-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 6px 0 4px; }
.battle-grid.result { margin-top: 12px; }
.vs-badge { font-size: 18px; font-weight: 800; color: var(--gold); text-align: center; }
.battle-col { background: #0a1230; border: 1px solid #1c294c; border-radius: 10px; padding: 9px 10px; min-height: 70px; }
.battle-col-h { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin-bottom: 7px; flex-wrap: wrap; }
.battle-col-h .role { font-size: 9px; font-weight: 700; letter-spacing: 1px; padding: 1px 6px; border-radius: 8px; text-transform: uppercase; }
.battle-col-h .role.att { background: rgba(255,107,107,.18); color: #ff9a9a; }
.battle-col-h .role.def { background: rgba(95,150,255,.18); color: #9fb4ff; }
.battle-col-h .bc-name { display: inline-flex; align-items: center; gap: 6px; }
.unit-row { display: flex; flex-wrap: wrap; gap: 5px; }
.uchip { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; font-size: 17px;
  border: 2px solid #888; border-radius: 8px; background: #0b1326; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.uchip.dead { opacity: .32; filter: grayscale(.8); position: relative; }
.uchip.dead::after { content: "✕"; position: absolute; font-size: 20px; color: #ff5a5a; font-weight: 900; }

.outcome-banner { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: .5px; padding: 12px; border-radius: 12px; margin-bottom: 6px; }
.outcome-banner.win { color: #7fe0a0; background: linear-gradient(180deg, rgba(58,160,106,.18), rgba(58,160,106,.05)); border: 1px solid rgba(95,200,140,.4); box-shadow: 0 0 26px rgba(58,160,106,.22); }
.outcome-banner.lose { color: #ff8a7a; background: linear-gradient(180deg, rgba(176,70,63,.18), rgba(176,70,63,.05)); border: 1px solid rgba(220,110,100,.4); }
.outcome-banner.push { color: #ffd86b; background: linear-gradient(180deg, rgba(255,216,107,.14), rgba(255,216,107,.04)); border: 1px solid rgba(255,216,107,.35); }

.dice-details { margin-top: 12px; }
.dice-details summary { cursor: pointer; color: var(--muted); font-size: 12px; letter-spacing: .5px; padding: 4px 0; }
.dice-details summary:hover { color: var(--text); }
p.center { text-align: center; }

/* ---------- Modale larga (combattimento) ---------- */
.modal-box.wide { width: 640px; max-width: 94vw; }

/* ---------- Arena di combattimento interattiva ---------- */
.combat-arena { }
.ca-sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 12px; }
.ca-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.ca-vs { font-size: 26px; }
.ca-roundn { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-align: center; white-space: nowrap; }
.ca-roundtitle { text-align: center; font-size: 16px; margin: 16px 0 10px; }
.ca-dice-rows { display: flex; flex-direction: column; gap: 12px; }
.ca-dice { border-radius: 10px; padding: 10px 12px; border: 1px solid #1c294c; background: #0a1124; }
.ca-dice.yours { border-color: rgba(255,216,107,.5); box-shadow: 0 0 18px rgba(255,216,107,.12); }
.ca-dice-label { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; }
.ca-dice.yours .ca-dice-label { color: var(--gold); }
.ca-dice-list { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-height: 38px; }
.cdie { display: inline-flex; align-items: baseline; gap: 1px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.cdie .die-face { font-size: 34px; }
.cdie .die-mult { font-size: 11px; color: #8593b5; transform: translateY(-10px); }
.cdie.rollable { cursor: pointer; border-radius: 10px; padding: 2px 4px; animation: dieready 1.1s ease-in-out infinite; }
.cdie.rollable:hover { background: rgba(255,216,107,.16); }
.cdie.pending { opacity: .5; }
@keyframes dieready { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.ca-hint { font-size: 13px; color: var(--gold); align-self: center; margin-right: auto; }

/* ---------- Overlay turno IA ---------- */
#aiOverlay { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding-top: 90px;
  pointer-events: none; opacity: 0; transition: opacity .25s; }
#aiOverlay.on { opacity: 1; }
#aiOverlay .ai-card { background: linear-gradient(180deg, rgba(16,24,52,.97), rgba(9,14,32,.97)); border: 2px solid var(--ac);
  border-radius: 16px; padding: 18px 30px; text-align: center; box-shadow: 0 0 40px var(--ac), 0 16px 50px rgba(0,0,0,.6); }
#aiOverlay .ai-spin { font-size: 40px; animation: aispin 2s linear infinite; }
@keyframes aispin { 0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 100% { transform: rotate(-8deg); } }
#aiOverlay .ai-card-t { font-size: 11px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
#aiOverlay .ai-card-n { font-size: 22px; font-weight: 800; }

/* ============================================================================
   RESPONSIVE / MOBILE
   ============================================================================ */
/* Tap reattivi (no ritardo 300ms, no zoom su doppio tap) sui controlli */
button, .hex, .fleet-badge, .step, .pill, .fc-unit { touch-action: manipulation; }
#board { touch-action: pan-x pan-y pinch-zoom; }

/* --- Schermi stretti (telefoni in verticale, tablet piccoli) --- */
@media (max-width: 860px) {
  #topbar { flex-wrap: wrap; gap: 6px 10px; padding: 7px 10px; }
  #turnInfo { font-size: 13px; order: 1; }
  .top-actions { order: 2; margin-left: auto; }
  #phaseInfo { order: 3; width: 100%; overflow-x: auto; }
  .stepper { gap: 3px; }
  .step { padding: 3px 8px; }
  .step:not(.active) .step-label { display: none; } /* solo il numero per le fasi non attive */
  .step.active { padding: 3px 10px; }

  #main { flex-direction: column; }
  #boardWrap { flex: 1 1 auto; min-height: 46vh; padding: 6px; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 46vh; border-left: none; border-top: 1px solid var(--border-bright); }
  #sidebar section { padding: 10px 12px; }
  #selectionPanel { max-height: none; }
  .res { grid-template-columns: 1fr 1fr 1fr; }
  .res .pill.money { grid-column: 1 / -1; }

  /* Modali a tutta larghezza */
  .modal { align-items: flex-end; }
  .modal-box, .modal-box.wide { width: 100vw; max-width: 100vw; max-height: 88vh; border-radius: 16px 16px 0 0; }
  .modal-actions button { flex: 1; min-height: 44px; }
  .cdie .die-face { font-size: 30px; }
  .ca-sides { gap: 6px; }

  /* Controlli più "toccabili" */
  button { min-height: 38px; }
  button.small { min-height: 34px; }
  .prod-btn { min-height: 44px; }
}

/* --- Telefoni molto stretti --- */
@media (max-width: 480px) {
  .setup-box { width: 94vw; padding: 22px 20px; }
  .setup-box h1 { font-size: 24px; letter-spacing: 3px; }
  #sidebar h3 { font-size: 10px; }
  .res .pill { font-size: 12px; padding: 5px 7px; }
  .fc-units { flex-wrap: wrap; }
  #logBody { font-size: 11px; }
}

/* --- Telefoni in orizzontale (bassi e larghi): plancia a sinistra, pannelli stretti a destra --- */
@media (max-height: 520px) and (orientation: landscape) {
  #main { flex-direction: row; }
  #sidebar { width: 250px; flex: 0 0 250px; max-height: none; border-top: none; border-left: 1px solid var(--border-bright); }
  #boardWrap { min-height: 0; }
  #topbar { padding: 4px 8px; }
  .step-label { display: none; } /* solo numeri per compattezza */
}
