:root {
  --paper: #f3efe6;
  --paper-2: #e9e3d6;
  --card: #ffffff;
  --ink: #23201b;
  --ink-2: #5d574d;
  --ink-3: #8f887b;
  --line: #ddd5c5;
  --line-2: #c9bfab;
  --accent: #2f5fa8;
  --good: #2a8a5a;
  --bad: #c0392b;
  --warn: #b8860b;
  --sea: #b9d0dc;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px; overflow: hidden; }
button { font-family: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); border-radius: 6px; padding: 6px 10px; }
button:hover { background: var(--paper-2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #3c372e; }
button.danger { color: var(--bad); border-color: #e3b3ad; }
button.sel { background: var(--ink); color: #fff; border-color: var(--ink); }
.hidden { display: none !important; }

#app { display: grid; grid-template-rows: 66px 1fr 34px; height: 100vh; }

/* ---------- barra superiore ---------- */
#top { display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--card); border-bottom: 1px solid var(--line); }
#nationBadge { display: flex; align-items: center; gap: 10px; min-width: 190px; }
#nationBadge .flag { width: 30px; height: 30px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); }
#nationBadge .nname { font-family: var(--serif); font-weight: 700; font-size: 16px; line-height: 1.1; }
#nationBadge .trait { font-size: 11px; color: var(--ink-3); }
#pillars { display: flex; gap: 10px; flex: 1; min-width: 0; }
.pil { flex: 1; min-width: 86px; max-width: 150px; cursor: help; }
.pil .lab { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-bottom: 3px; }
.pil .lab b { color: var(--ink); font-weight: 600; font-size: 12px; }
.pil .bar { position: relative; height: 8px; background: var(--paper-2); border-radius: 4px; overflow: visible; }
.pil .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.pil .tgt { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
.pil.ok .lab b::after { content: ' ✓'; color: var(--good); }
#treasury { text-align: right; min-width: 120px; }
#treasury .v { font-weight: 600; font-size: 16px; }
#treasury .d { font-size: 11px; color: var(--ink-3); }
#clock { text-align: center; min-width: 150px; }
#date { font-family: var(--serif); font-weight: 700; font-size: 19px; }
#era { font-size: 11px; color: var(--ink-3); }
#speed { display: flex; gap: 3px; }
#speed button { padding: 5px 7px; font-size: 11px; min-width: 30px; }
#menuBtns { display: flex; gap: 4px; }

/* ---------- mappa ---------- */
#main { display: grid; grid-template-columns: 1fr 390px; min-height: 0; }
#mapWrap { position: relative; overflow: hidden; background: var(--sea); }
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.dragging { cursor: grabbing; }
#mapHint { position: absolute; left: 12px; top: 12px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; font-size: 13px; pointer-events: none; display: none; max-width: 360px; }
#legend { position: absolute; left: 12px; bottom: 12px; background: rgba(255,255,255,.9); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; font-size: 11px; color: var(--ink-2); }

/* ---------- pannello laterale ---------- */
#side { background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#tabs { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
#tabs button { border: none; border-radius: 0; background: none; padding: 8px 2px; font-size: 12px; color: var(--ink-2); border-bottom: 2px solid transparent; }
#tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); background: var(--paper); }
#tabs button .ic { display: block; font-size: 15px; margin-bottom: 1px; }
#panel { flex: 1; overflow-y: auto; padding: 14px 16px 30px; }
#panel h2 { font-family: var(--serif); font-size: 21px; margin: 0 0 2px; font-weight: 700; }
#panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 0 8px; font-weight: 600; }
#panel .sub { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--ink-2); }
.kv span:nth-child(even) { text-align: right; font-weight: 500; }
.row { display: flex; align-items: center; gap: 8px; }
.row.sp { justify-content: space-between; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; background: var(--card); }
.card.soft { background: var(--paper); border-color: transparent; }
.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--paper-2); color: var(--ink-2); margin-left: 4px; font-weight: 500; }
.tag.war { background: #f8dcd8; color: #8e2a1f; }
.tag.ally { background: #d6ecdf; color: #1d6640; }
.tag.eu { background: #dbe5f5; color: #23477f; }
.tag.good { background: #d6ecdf; color: #1d6640; }
.tag.bad { background: #f8dcd8; color: #8e2a1f; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; border: 1px solid rgba(0,0,0,.15); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.good { color: var(--good); } .bad { color: var(--bad); }
.progress { height: 6px; background: var(--paper-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; background: var(--accent); }
.list-item { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.list-item:hover { background: var(--paper); }
.list-item .grow { flex: 1; min-width: 0; }
.slider { margin: 10px 0; }
.slider .row { font-size: 13px; }
.slider input { width: 100%; accent-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; flex: 1; border-right: 1px solid var(--line-2); padding: 6px 4px; font-size: 12px; }
.seg button:last-child { border-right: none; }
.tech { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.tech.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tech .tn { font-weight: 600; }
.tech .td { font-size: 12px; color: var(--ink-2); margin: 2px 0 4px; }
.tech .te { font-size: 11px; color: var(--ink-3); }
.cat { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 8px; margin-right: 4px; text-transform: uppercase; letter-spacing: .04em; }
.cat.mil { background: #f8dcd8; color: #8e2a1f; } .cat.eco { background: #f6ead0; color: #7a5a0e; }
.cat.soc { background: #d6ecdf; color: #1d6640; } .cat.info { background: #e6e1f5; color: #4b3d8f; }
table.t { width: 100%; border-collapse: collapse; font-size: 12px; }
table.t th { text-align: right; font-weight: 500; color: var(--ink-3); padding: 4px 3px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { text-align: right; padding: 5px 3px; border-bottom: 1px solid var(--line); }
table.t tr.me td { background: #f5f0e2; font-weight: 600; }
.sharebar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--paper-2); margin: 4px 0; }
.sharebar div { height: 100%; }
select { font-family: inherit; font-size: 13px; padding: 5px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: #fff; }

/* ---------- gazzetta in basso ---------- */
#ticker { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #f3efe6; padding: 0 14px; font-size: 13px; overflow: hidden; white-space: nowrap; }
#ticker .tk-label { font-family: var(--serif); font-weight: 700; letter-spacing: .05em; color: #e8c97a; }
#tickerText { overflow: hidden; text-overflow: ellipsis; }

/* ---------- notifiche ---------- */
#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 50; pointer-events: none; width: min(560px, 90vw); }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--ink-3); border-radius: 6px; padding: 8px 12px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.12); animation: tin .25s ease-out; }
.toast.good { border-left-color: var(--good); } .toast.bad { border-left-color: var(--bad); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- finestre ---------- */
#modal { position: fixed; inset: 0; background: rgba(30, 25, 18, .55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.dlg { background: var(--card); border-radius: 12px; max-width: 560px; width: 100%; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto; }
.dlg h2 { font-family: var(--serif); margin: 0 0 8px; }
.dlg .opts { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.dlg .opts button { text-align: left; padding: 10px 14px; font-size: 14px; }

/* giornale dell'Ottocento */
.ev-carta { background: #f4ecd8; color: #2a2318; font-family: Georgia, serif; border: 1px solid #c9b88f; }
.ev-carta .mast { text-align: center; font-family: var(--serif); font-weight: 900; font-size: 30px; letter-spacing: .02em; border-bottom: 3px double #2a2318; padding-bottom: 4px; }
.ev-carta .dateline { display: flex; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; border-bottom: 1px solid #2a2318; padding: 3px 0; margin-bottom: 14px; }
.ev-carta .head { font-family: var(--serif); font-weight: 900; font-size: 27px; line-height: 1.1; text-align: center; margin-bottom: 10px; }
.ev-carta .body { font-size: 15px; line-height: 1.55; text-align: justify; }
.ev-carta .opts button { background: #fbf6e9; border-color: #b8a67e; font-family: Georgia, serif; }
/* bollettino radio */
.ev-radio { background: #2b2620; color: #f1e3c4; font-family: 'Special Elite', 'Courier New', monospace; border: 1px solid #5a4e3c; }
.ev-radio .mast { font-size: 13px; letter-spacing: .3em; color: #e3b552; text-align: center; margin-bottom: 4px; }
.ev-radio .dateline { text-align: center; font-size: 12px; color: #b8a888; margin-bottom: 14px; }
.ev-radio .head { font-size: 24px; text-align: center; line-height: 1.2; margin-bottom: 12px; color: #fff3d6; }
.ev-radio .body { font-size: 15px; line-height: 1.6; }
.ev-radio .opts button { background: #3d362c; color: #f1e3c4; border-color: #6d5f48; font-family: inherit; }
/* telegiornale */
.ev-tv { background: #10233f; color: #fff; border: none; }
.ev-tv .mast { display: inline-block; background: #c8262e; color: #fff; font-weight: 600; font-size: 12px; letter-spacing: .15em; padding: 4px 10px; border-radius: 3px; }
.ev-tv .dateline { font-size: 12px; color: #9fb3d1; margin: 8px 0 12px; }
.ev-tv .head { font-family: var(--sans); font-weight: 600; font-size: 24px; line-height: 1.2; margin-bottom: 10px; }
.ev-tv .body { font-size: 15px; line-height: 1.55; color: #dbe6f5; }
.ev-tv .opts button { background: #1d3a63; color: #fff; border-color: #35598c; }
/* notizie online */
.ev-web .mast { font-weight: 600; color: var(--accent); font-size: 13px; }
.ev-web .dateline { font-size: 12px; color: var(--ink-3); margin: 4px 0 10px; }
.ev-web .head { font-weight: 600; font-size: 23px; line-height: 1.2; margin-bottom: 10px; }
.ev-web .body { font-size: 15px; line-height: 1.55; color: var(--ink-2); }
/* notifica dello smartphone */
.ev-smart { background: #f7f7f9; border-radius: 22px; }
.ev-smart .mast { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6b6b75; font-weight: 600; }
.ev-smart .mast::before { content: ''; width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg,#ff7a59,#c53bd8); }
.ev-smart .dateline { font-size: 12px; color: #9a9aa5; margin: 4px 0 8px; }
.ev-smart .head { font-weight: 600; font-size: 20px; line-height: 1.25; margin-bottom: 8px; }
.ev-smart .body { font-size: 15px; line-height: 1.5; color: #3d3d46; }
.ev-smart .opts button { border-radius: 14px; }

/* ---------- schermata iniziale ---------- */
#start { position: fixed; inset: 0; background: var(--paper); z-index: 200; overflow-y: auto; }
#start.hidden { display: none; }
.st-wrap { max-width: 1080px; margin: 0 auto; padding: 36px 24px 60px; }
.st-title { font-family: var(--serif); font-weight: 900; font-size: 54px; text-align: center; margin: 0; letter-spacing: -.01em; }
.st-sub { text-align: center; color: var(--ink-2); font-size: 16px; margin: 6px 0 28px; font-family: Georgia, serif; font-style: italic; }
.st-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; margin: 26px 0 10px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode, .natc { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 16px 18px; cursor: pointer; text-align: left; }
.mode:hover, .natc:hover { border-color: var(--line-2); background: #fffdf8; }
.mode.on, .natc.on { border: 2px solid var(--ink); padding: 15px 17px; }
.mode h4, .natc h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 19px; }
.mode p, .natc p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.nats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.natc .tr { font-size: 12px; font-weight: 600; margin: 6px 0 2px; }
.natc .tg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; margin-top: 8px; font-size: 10px; text-align: center; color: var(--ink-3); }
.natc .tg b { display: block; font-size: 13px; color: var(--ink); }
.st-go { display: flex; justify-content: center; gap: 12px; margin-top: 28px; }
.st-go button { font-size: 16px; padding: 12px 28px; border-radius: 10px; }

@media (max-width: 1100px) {
  #main { grid-template-columns: 1fr 330px; }
  .nats { grid-template-columns: repeat(2, 1fr); }
  #era { display: none; }
  .pil { min-width: 60px; }
}
#mmWrap { position: absolute; right: 12px; bottom: 12px; padding: 4px; background: #1d2430; border: 1px solid #c9a24a; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
#minimap { display: block; cursor: crosshair; border-radius: 3px; }
