:root {
  --bg: #050914; --panel: #0e1630; --panel2: #16224a; --line: #2a3d78; --text: #e8eefc; --muted: #93a4cf;
  --accent: #4fc3f7; --good: #7ddc7a; --bad: #ef7b6c; --warn: #f2c744;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding: var(--site-bar, 0px) 8px 0; }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px; max-width: 1040px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.25rem; letter-spacing: .04em; color: var(--accent); white-space: nowrap; }
.top-right { display: flex; align-items: center; gap: 6px; }
.langs { display: inline-flex; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .85rem; cursor: pointer; }
.langs .chip:first-child { border-radius: 999px 0 0 999px; }
.langs .chip:last-child { border-radius: 0 999px 999px 0; border-left: 0; }
.chip.active { background: var(--accent); color: #04121a; border-color: var(--accent); font-weight: 700; }
.conn { max-width: 1040px; margin: 0 auto 6px; background: #4a3512; border: 1px solid #a2701f; border-radius: 8px; padding: 6px 10px; font-size: .9rem; }
main { max-width: 1040px; margin: 0 auto; padding-bottom: 24px; }
#home, #lobby { max-width: 640px; margin: 0 auto; }

.tagline { color: var(--muted); margin: 4px 2px 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.card h3, .bleft h3 { margin: 12px 0 4px; font-size: .92rem; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: .88rem; margin: 2px 0 8px; }
label { display: block; font-size: .88rem; color: var(--muted); margin: 6px 0 4px; }
input[type=text], input[type=password], input[type=email], select, textarea { width: 100%; background: #070d20; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
textarea { font: 12px/1.3 ui-monospace, Consolas, monospace; resize: vertical; margin-bottom: 8px; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; margin: 6px 0; }
.row > * { flex: 1; }
.row.join input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 700; }
.btn { background: var(--accent); color: #04121a; border: 0; border-radius: 12px; padding: 11px 14px; font-weight: 700; cursor: pointer; min-height: 44px; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.seg button { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 4px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--accent); color: #04121a; border-color: var(--accent); }
.shipbox { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#ship-preview { background: #070d20; border: 1px solid var(--line); border-radius: 10px; max-width: 100%; }
.codebox { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.codebox span { font-size: 2rem; letter-spacing: .25em; font-weight: 800; color: var(--accent); flex: 1; }
.codebox .btn { flex: 0 0 auto; }
.seats { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 8px; }
.seats li { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.seats .dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.seats .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats .tag { color: var(--muted); font-size: .8rem; }
.seats .free { opacity: .5; }
.seats button { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
#lobby-host { margin: 8px 0; }

.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--text); font-size: .92rem; }
.glist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.gcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: grid; gap: 6px; }
.gcard canvas { width: 100%; height: auto; background: #070d20; border: 1px solid var(--line); border-radius: 10px; aspect-ratio: 25 / 17; }
.gcard h3 { margin: 0; font-size: 1rem; color: var(--text); }
.gcard .by { color: var(--muted); font-size: .85rem; }
.gcard .row .btn { min-height: 36px; padding: 6px 8px; font-size: .86rem; }
.gcard .row .btn.on { background: var(--accent); color: #04121a; }
/* costruttore */
.bhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bhead h2 { margin: 6px 0; }
.bgrid { display: grid; grid-template-columns: 220px minmax(0, 1fr) 250px; gap: 12px; align-items: start; }
.tbar { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 8px; }
.tbar .btn { min-height: 34px; padding: 4px 6px; font-size: .82rem; }
.tbar .btn.on { background: var(--accent); color: #04121a; }
.tbar .btn:disabled { opacity: .35; }
.palette { display: grid; gap: 4px; margin-bottom: 8px; }
.tool { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 6px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px 8px 3px 4px; cursor: pointer; }
.tool.on { border-color: var(--accent); background: var(--panel2); box-shadow: 0 0 0 1px var(--accent) inset; }
.tool .tl { font-size: .84rem; line-height: 1.15; }
.tool small { color: var(--warn); font-weight: 700; }
#b-canvas { width: 100%; height: auto; aspect-ratio: 25 / 17; border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; display: block; }
.stats { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.srow { display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; padding: 2px 0; }
.srow span { color: var(--muted); }
.srow.bad b { color: var(--bad); } .srow.warn b { color: var(--warn); }
.notes { list-style: none; margin: 8px 0 0; padding: 0; font-size: .84rem; display: grid; gap: 4px; }
.notes .bad { color: var(--bad); } .notes .warn { color: var(--warn); } .notes .good { color: var(--good); }
.bbottom { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.slot.on { border-color: var(--accent); background: var(--accent); color: #04121a; font-weight: 700; }
@media (max-width: 900px) { .bgrid { grid-template-columns: 1fr; } .palette { grid-template-columns: repeat(2, 1fr); } .bbottom { grid-template-columns: 1fr; } }

/* partita */
#game { position: fixed; inset: 0; z-index: 10; background: #04060f; }
#view { width: 100%; height: 100%; display: block; }
.helpbar { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: .72rem; color: rgba(160,180,230,.55); padding: 2px 6px; pointer-events: none; }
.leave { position: absolute; top: 8px; right: 8px; z-index: 2; opacity: .8; }
.result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2,5,15,.55); z-index: 3; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 2147483001; display: flex; align-items: flex-end; justify-content: center; overflow-y: auto; padding: 12px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 520px; margin: auto; display: grid; gap: 10px; }
.sheet h2 { margin: 0; }
.sheet p { margin: 0; }
.sheet .hint { margin: 0; }
.error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.rules p { margin: 0 0 8px; font-size: .92rem; }
@media (min-width: 700px) { .overlay { align-items: center; } }
