/* ============================================================================
   CNW: THE GAME — Interfaccia
   Palette estratta dal logo Courier NetWork.
   ============================================================================ */

:root {
  --deep:   #254E9C;
  --vivid:  #005CB9;
  --cyan:   #00A4E8;
  --ink:    #0A1728;
  --panel:  #10233D;
  --panel2: #16304F;
  --line:   #23456E;
  --text:   #E8F0FA;
  --muted:  #8FA9C8;
  --gold:   #F5C24B;
  --danger: #E8564A;
  --ok:     #35C48C;
  --font:   'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:   'SF Mono', 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ink); color: var(--text);
  font-family: var(--font); font-size: 14px;
  overflow: hidden;
}

button {
  font-family: inherit; font-size: inherit; cursor: pointer;
  border: none; background: none; color: inherit;
}

/* ================================================================== LAYOUT == */

#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px; background: #fff;
  border-bottom: 3px solid var(--cyan);
  flex: 0 0 auto;
}
.topbar .logo { height: 42px; width: auto; }
.topbar .title {
  font-weight: 800; font-size: 19px; letter-spacing: 0.14em;
  color: var(--deep); text-transform: uppercase;
}
.topbar .title small {
  display: block; font-size: 10px; letter-spacing: 0.22em;
  color: var(--vivid); font-weight: 600; margin-top: 2px;
}
.topbar .spacer { flex: 1; }

.turn-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 16px; border-radius: 999px;
  background: var(--deep); color: #fff; font-weight: 700;
}
.turn-chip .dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.turn-chip .meta { font-size: 11px; font-weight: 500; opacity: .85; letter-spacing: .06em; }

.phase-strip {
  display: flex; gap: 2px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.phase-strip .ph {
  flex: 1; padding: 8px 6px; text-align: center;
  font-size: 10.5px; letter-spacing: .12em; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  border-bottom: 3px solid transparent; position: relative;
}
.phase-strip .ph small { display: block; font-weight: 500; letter-spacing: .02em; font-size: 9.5px; opacity: .7; text-transform: none; }
.phase-strip .ph.done { color: #5F7EA6; }
.phase-strip .ph.active {
  color: #fff; background: var(--panel2); border-bottom-color: var(--cyan);
}

.main { display: flex; flex: 1; min-height: 0; }

.board-wrap {
  flex: 1; min-width: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #071322; padding: 6px;
}
.board { width: 100%; height: 100%; display: block; }

.side {
  flex: 0 0 340px; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
  min-height: 0;
}

/* =================================================================== BOARD == */

.grid line { stroke: rgba(120,170,220,.07); stroke-width: 1; }
.equator { stroke: rgba(0,164,232,.22); stroke-width: 1.2; stroke-dasharray: 8 6; }

.landmass { fill: #14304F; stroke: #2B5786; stroke-width: 1.1; }

.region-label {
  fill: rgba(150,195,235,.30); font-size: 22px; font-weight: 800;
  letter-spacing: .28em; text-anchor: middle; pointer-events: none;
  text-transform: uppercase;
}
.region-bonus {
  fill: rgba(0,164,232,.42); font-size: 12px; font-weight: 600;
  letter-spacing: .18em; text-anchor: middle; pointer-events: none;
}

.link { stroke: rgba(140,190,235,.28); stroke-width: 2; }
.route {
  stroke: var(--cyan); stroke-width: 2; fill: none;
  stroke-dasharray: 9 7; opacity: .75;
}
.route-label {
  fill: rgba(0,164,232,.75); font-size: 9.5px; font-weight: 700;
  letter-spacing: .16em; text-anchor: middle; pointer-events: none;
}

.bridge {
  fill: none; stroke-width: 1.6; stroke-dasharray: 3 9;
  opacity: .5; pointer-events: none;
}
.chain-line {
  fill: none; stroke: var(--gold); stroke-width: 5;
  opacity: .85; pointer-events: none; stroke-linecap: round;
}

.node { cursor: pointer; }
/* area di click: invisibile ma sensibile al puntatore */
.node-hit { fill: transparent; pointer-events: all; }
.node-ring { fill: none; stroke: rgba(255,255,255,.16); stroke-width: 2; }
.node-disc { stroke: rgba(255,255,255,.55); stroke-width: 1.5; transition: r .12s; }
.hub-mark { fill: var(--cyan); }
.node-code {
  fill: #fff; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  text-anchor: middle; pointer-events: none;
}
.node.is-hub .node-code { font-size: 12px; }
.node-units {
  font-size: 15px; font-weight: 800; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--ink); stroke-width: 4px; stroke-linejoin: round;
}
/* Layer separato dai nodi: le etichette non devono catturare i click. */
.city-labels { pointer-events: none; }
/* text-anchor NON va qui: lo imposta map.js per attributo in base a `lpos`,
   e una regola CSS lo sovrascriverebbe. */
.node-city {
  fill: rgba(200,222,245,.72); font-size: 10px; font-weight: 600;
  pointer-events: none;
  paint-order: stroke; stroke: rgba(7,19,34,.85); stroke-width: 3px; stroke-linejoin: round;
}

.node:hover .node-ring { stroke: #fff; stroke-width: 2.5; }
.node.is-mine .node-ring { stroke: rgba(255,255,255,.45); }
.node.is-selected .node-ring {
  stroke: var(--gold); stroke-width: 4;
}
.node.is-target .node-ring {
  stroke: var(--danger); stroke-width: 3.5; stroke-dasharray: 5 4;
  animation: spin 8s linear infinite;
}
.node.is-chain .node-ring { stroke: var(--gold); stroke-width: 3; }
.node.is-struck .node-disc { stroke: var(--danger); stroke-dasharray: 3 3; stroke-width: 3; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Il bagliore va sull'anello, non su tutto il gruppo: applicato al gruppo
   sfocava anche il codice IATA e il nome della città. */
.node.is-hub .node-ring { filter: url(#hubGlow); }

/* ================================================================== SIDEBAR == */

.side-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.card {
  margin: 10px; padding: 12px 13px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
}
.card h3 {
  margin: 0 0 9px; font-size: 10px; letter-spacing: .18em; font-weight: 800;
  color: var(--cyan); text-transform: uppercase;
}
.card.accent { border-left: 3px solid var(--cyan); }

.kv { display: flex; justify-content: space-between; padding: 2.5px 0; font-size: 12.5px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- giocatori --- */
.player-row {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px;
  border-radius: 7px; font-size: 12.5px;
}
.player-row.active { background: rgba(0,164,232,.13); box-shadow: inset 0 0 0 1px rgba(0,164,232,.35); }
.player-row.dead { opacity: .38; text-decoration: line-through; }
.player-row .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.player-row .pname { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-row .stat { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; }
.player-row .sla { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.slabar { height: 4px; background: rgba(255,255,255,.09); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.slabar i { display: block; height: 100%; background: var(--gold); }

/* --- spedizioni --- */
.ship {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  margin-bottom: 8px; background: rgba(255,255,255,.03);
  border-left: 3px solid var(--muted);
}
.ship.ready { border-left-color: var(--ok); background: rgba(53,196,140,.09); }
.ship.urgent { border-left-color: var(--danger); }
.ship .ship-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 9.5px; letter-spacing: .14em; font-weight: 800; color: var(--cyan);
  margin-bottom: 6px;
}
.ship .ttl { font-variant-numeric: tabular-nums; color: var(--gold); letter-spacing: 0; }
.ship.urgent .ttl { color: var(--danger); }
.ship .route-line {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 7px; margin-bottom: 4px;
}
.ship .route-line em { color: var(--cyan); font-style: normal; }
.ship .cities { font-size: 10.5px; color: var(--muted); margin-bottom: 6px; }
.ship .brief { font-size: 11px; color: #B9CCE3; font-style: italic; line-height: 1.45; margin-bottom: 8px; }
.ship .pay { display: flex; gap: 10px; font-size: 11px; font-weight: 700; }
.ship .pay .sla { color: var(--gold); }
.ship .pay .re { color: var(--ok); }
.ship .deliver-btn {
  width: 100%; margin-top: 8px; padding: 7px; border-radius: 6px;
  background: var(--ok); color: #062b1d; font-weight: 800; font-size: 11.5px;
  letter-spacing: .08em;
}
.ship .why { margin-top: 6px; font-size: 10.5px; color: var(--muted); }

/* --- carte in mano --- */
.hand { display: flex; flex-wrap: wrap; gap: 5px; }
.gwcard {
  padding: 5px 8px; border-radius: 6px; background: #fff; color: var(--deep);
  font-weight: 800; font-size: 11.5px; font-family: var(--mono);
  display: flex; align-items: center; gap: 5px; line-height: 1;
}
.gwcard.owned { box-shadow: 0 0 0 2px var(--cyan); }
/* icona servizio: SVG in currentColor, eredita il blu della carta */
.gwcard .svc { display: inline-flex; width: 13px; height: 13px; flex: 0 0 auto; }
.gwcard .svc svg { width: 100%; height: 100%; display: block; }

/* --- log --- */
.log { flex: 0 0 auto; max-height: 30vh; overflow-y: auto; border-top: 1px solid var(--line); background: #0B1B2E; }
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.log-entry {
  padding: 5px 12px; font-size: 11.5px; line-height: 1.45;
  border-bottom: 1px solid rgba(255,255,255,.04); color: #C4D6EB;
}
.log-entry.turn { background: var(--deep); color: #fff; font-weight: 800; letter-spacing: .1em; font-size: 10.5px; text-align: center; }
.log-entry.battle { color: #FFD9D4; }
.log-entry.deliver { color: #9FEBC9; font-weight: 600; }
.log-entry.fail { color: #FFB4AC; }
.log-entry.inc { color: var(--gold); }
.log-entry.win { background: var(--gold); color: #2A1D00; font-weight: 800; }
.log-entry.elim { color: #FF9A8F; font-weight: 700; }
.log-entry.reinf, .log-entry.ship, .log-entry.card, .log-entry.move, .log-entry.obc { color: #A7C4E2; }

/* ================================================================== ACTIONS == */

.actionbar {
  flex: 0 0 auto; padding: 10px 14px; background: var(--panel2);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
}
.hint { font-size: 12px; color: #BDD3EA; line-height: 1.45; min-height: 34px; }
.hint b { color: var(--cyan); }
.btn-row { display: flex; gap: 7px; }
.btn {
  flex: 1; padding: 10px; border-radius: 7px; font-weight: 800;
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  background: var(--vivid); color: #fff; transition: filter .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); }
.btn.gold { background: var(--gold); color: #2A1D00; }
.btn.warn { background: var(--danger); }

/* ================================================================== MODALS == */

.overlay-screen {
  position: fixed; inset: 0; background: rgba(4,12,22,.86);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(4px); padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 28px; max-width: 560px; width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 {
  margin: 0 0 6px; font-size: 20px; letter-spacing: .06em; color: #fff;
}
.modal .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; line-height: 1.5; }
.modal label { display: block; font-size: 10.5px; letter-spacing: .14em; color: var(--cyan); font-weight: 800; margin: 14px 0 6px; text-transform: uppercase; }
.modal input[type=text], .modal select {
  width: 100%; padding: 9px 11px; border-radius: 7px; font-family: inherit; font-size: 13px;
  background: var(--ink); border: 1px solid var(--line); color: var(--text);
}
.opt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.opt {
  padding: 10px 12px; border-radius: 8px; text-align: left; font-size: 12.5px;
  background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line);
}
.opt:hover { background: var(--vivid); }

.dice-panel { display: flex; flex-direction: column; gap: 10px; }
.dice-row { display: flex; align-items: center; gap: 8px; }
.dice-row .lbl { font-size: 10px; letter-spacing: .14em; font-weight: 800; width: 78px; color: var(--muted); }
.die {
  width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums;
}
.die.att { background: #E8564A; color: #fff; }
.die.def { background: var(--vivid); color: #fff; }
.die.plus { box-shadow: 0 0 0 2.5px var(--cyan); }
.die.lost { opacity: .3; }
.pairs { display: flex; gap: 10px; margin-top: 4px; }
.pair { font-size: 11px; padding: 3px 8px; border-radius: 5px; font-weight: 700; }
.pair.win { background: rgba(53,196,140,.2); color: #7FE3B8; }
.pair.lose { background: rgba(232,86,74,.2); color: #FFAFA7; }

.winner-card { text-align: center; }
.winner-card .crown { font-size: 46px; }
.winner-card .wname { font-size: 27px; font-weight: 800; margin: 8px 0 2px; }
.winner-card .wreason { color: var(--cyan); letter-spacing: .16em; font-size: 11.5px; font-weight: 800; text-transform: uppercase; }
.winner-card .wobj { margin-top: 14px; font-size: 12.5px; color: var(--muted); font-style: italic; }

.legend {
  position: absolute; left: 14px; bottom: 12px;
  background: rgba(8,22,38,.9); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; font-size: 10.5px; color: var(--muted);
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
  line-height: 1.4;
}
.legend b { color: var(--cyan); letter-spacing: .12em; font-size: 9.5px; }
.legend .li { display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 22px; height: 0; border-top: 2px solid; }

.topbar .home-link { display: flex; align-items: center; }
.topbar .top-link {
  margin-left: 4px; padding: 6px 12px; border-radius: 6px; font-size: 12px;
  font-weight: 700; color: var(--vivid); text-decoration: none;
}
.topbar .top-link:hover { background: #EEF3FA; }

/* ============================================================ SCHERMI PICCOLI == */
/* Il gioco richiede spazio reale. Sotto i 1100 px si mostra un avviso invece
   di un'interfaccia inutilizzabile. */

.too-small { display: none; }

@media (max-width: 1099px) {
  #app { display: none; }
  .too-small {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; min-height: 100vh; padding: 32px 24px; gap: 4px;
  }
  .too-small img {
    height: 46px; background: #fff; padding: 8px 12px; border-radius: 8px;
    margin-bottom: 20px;
  }
  .too-small h1 { font-size: 22px; margin: 0 0 10px; }
  .too-small p { color: var(--muted); max-width: 30em; line-height: 1.6; margin: 0 0 14px; }
  .too-small b { color: var(--cyan); }
  .too-small .ts-links { margin-top: 10px; font-size: 13px; }
  .too-small a { color: var(--cyan); }
  html, body { overflow: auto; }
}

@media (min-width: 1100px) and (max-width: 1360px) {
  .side { flex-basis: 300px; }
  .region-label { font-size: 18px; }
}
