:root {
  --panel: rgba(20, 26, 36, .9);
  --text: #e9eef5;
  --muted: #9aa7b8;
  --accent: #4cc38a;
  --bad: #ef5b5b;
  --res: #4caf50;
  --com: #3b8eea;
  --ind: #f2b52f;
  --off: #9c6ade;
  --border: rgba(255, 255, 255, .09);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #a9d4e6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); user-select: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.right { text-align: right; margin-top: 12px; }
.pos { color: var(--accent); } .neg { color: var(--bad); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.tag { font-size: 10px; background: rgba(255,255,255,.12); border-radius: 4px; padding: 1px 5px; color: var(--muted); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

button {
  font: inherit; font-size: 13px; color: inherit; background: rgba(255,255,255,.06);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 9px; cursor: pointer;
}
button:hover { background: rgba(255,255,255,.14); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.on, button.primary { background: var(--accent); color: #0b1a12; border-color: transparent; font-weight: 600; }

/* Barra superior */
#topbar { position: fixed; top: 8px; left: 8px; right: 8px; z-index: 5; display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#topbar .spacer { pointer-events: none; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.stat { display: flex; flex-direction: column; justify-content: center; min-width: 76px; }
.stat label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat b.neg { color: var(--bad); }
.stat small { font-size: 10px; font-variant-numeric: tabular-nums; }
.demand { display: flex; gap: 6px; align-items: center; }
.dcol { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); }
.dbar { width: 12px; height: 30px; background: rgba(255,255,255,.08); border-radius: 3px; position: relative; overflow: hidden; }
.dbar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255,255,255,.25); }
.dbar i { position: absolute; left: 0; right: 0; }
.dbar i.r { background: var(--res); } .dbar i.c { background: var(--com); } .dbar i.i { background: var(--ind); } .dbar i.o { background: var(--off); }
.speed, .menu { display: flex; gap: 4px; align-items: center; }
.menu button { padding: 5px 7px; }
#btnAccount { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1500px) { .stat { min-width: 66px; } #topbar .card { padding-left: 8px; padding-right: 8px; } }

/* Ferramentas */
#toolbar { position: fixed; left: 8px; top: 72px; z-index: 6; display: flex; flex-direction: column; gap: 2px; padding: 4px; max-height: calc(100vh - 160px); overflow-y: auto; scrollbar-width: thin; }
.tool { width: 58px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 3px 2px; }
.tool .ic { font-size: 18px; line-height: 1.15; }
.tool .nm { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.tool.on .nm { color: #0b1a12; }
#flyout { position: fixed; left: 80px; z-index: 7; width: 290px; display: flex; flex-direction: column; gap: 4px; padding: 8px; max-height: calc(100vh - 80px); overflow-y: auto; }
.fly-title { font-weight: 700; padding: 2px 4px 4px; }
#flyout .item { display: flex; align-items: center; gap: 10px; text-align: left; padding: 6px 8px; }
#flyout .item .ic { font-size: 24px; width: 30px; text-align: center; }
#flyout .item small { color: var(--muted); }
#flyout .item .desc { display: block; font-size: 11px; opacity: .85; }
#flyout .item.on small { color: #123; }
#flyout .item.locked { opacity: .5; }

/* Camadas de mapa */
#overlays { position: fixed; left: 8px; bottom: 40px; z-index: 5; display: flex; gap: 3px; align-items: center; flex-wrap: wrap; max-width: calc(100vw - 210px); }
#overlays button { padding: 4px 7px; }
.olabel { font-size: 11px; color: var(--muted); margin-right: 4px; min-width: 120px; }

/* Painéis laterais */
#info, #districtPanel { position: fixed; right: 8px; top: 80px; width: 270px; z-index: 5; font-size: 13px; padding: 10px 12px; max-height: calc(100vh - 200px); overflow-y: auto; }
#districtPanel { width: 300px; }
#info h3, #districtPanel h3 { margin: 0 0 8px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.meter { height: 5px; background: rgba(255,255,255,.1); border-radius: 3px; margin: 1px 0 5px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; }
.x { padding: 1px 7px; }
.alert { background: rgba(239,91,91,.2); border: 1px solid rgba(239,91,91,.5); border-radius: 6px; padding: 5px 8px; margin: 4px 0; }
.district { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin: 6px 0; cursor: pointer; }
.district.on { border-color: var(--accent); background: rgba(76,195,138,.08); }
.dhead { display: flex; align-items: center; gap: 6px; }
.dhead button { padding: 1px 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dtax { margin-top: 6px; }

#minimap { position: fixed; right: 8px; bottom: 40px; width: 160px; height: 160px; padding: 0; z-index: 5; cursor: pointer; }

/* Avisos */
#toasts { position: fixed; top: 66px; right: 8px; width: 300px; z-index: 15; display: flex; flex-direction: column; gap: 6px; align-items: stretch; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 8px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3); transition: opacity .4s, transform .4s; max-width: 90vw; }
.toast.bad { border-left-color: var(--bad); }
.toast.party { border-left-color: var(--ind); }
.toast.good { border-left-color: #4fd18b; }
.toast.click { pointer-events: auto; cursor: pointer; }
.toast.out { opacity: 0; transform: translateY(-8px); }
#tip { position: fixed; z-index: 12; pointer-events: none; display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; white-space: nowrap; }
#tip.bad { color: #ffb0b0; }
.fatal { position: fixed; inset: 40% 10% auto; background: #400; color: #fff; padding: 16px; border-radius: 10px; z-index: 50; }

/* Janelas */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { width: min(500px, calc(100% - 32px)); max-height: 88vh; overflow: auto; padding: 18px 22px; user-select: text; }
.modal-box.wide { width: min(940px, calc(100% - 32px)); }
.modal-box h2 { margin: 0 0 12px; font-size: 20px; }
.modal-box h3 { margin: 16px 0 6px; font-size: 14px; }
.modal-box li { margin: 5px 0; line-height: 1.4; }
.modal-box table { width: 100%; border-collapse: collapse; font-size: 14px; }
.modal-box td { padding: 4px 0; border-bottom: 1px solid var(--border); }
.modal-box td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.modal-box tr.total td { font-weight: 700; border-bottom: none; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.charts canvas { width: 100%; height: auto; border-radius: 8px; }
.newslog { font-size: 13px; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.slider { display: grid; grid-template-columns: 150px 1fr 52px; gap: 10px; align-items: center; margin: 4px 0; font-size: 13px; }
.slider input { accent-color: var(--accent); width: 100%; }
.slider b { text-align: right; font-variant-numeric: tabular-nums; }
#districtPanel .slider { grid-template-columns: 24px 1fr 44px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form label.chk, label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input[type=text], input:not([type]), input[type=password], select {
  font: inherit; color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px;
}
select option { background: #1c2430; }
.policy { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.policy .ic { font-size: 22px; }
.cityrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
#ranking ol { margin: 4px 0; padding-left: 22px; font-size: 14px; }
.filebtn { font-size: 13px; background: rgba(255,255,255,.06); border: 1px solid var(--border); border-radius: 7px; padding: 5px 9px; cursor: pointer; }
.filebtn input { display: none; }

/* Telas pequenas */
@media (max-width: 760px) {
  #topbar { gap: 4px; }
  .stat { min-width: 62px; }
  .stat b { font-size: 13px; }
  #toolbar { top: auto; bottom: 52px; left: 8px; right: 8px; transform: none; flex-direction: row; overflow-x: auto; max-height: none; }
  .tool { flex: 0 0 auto; }
  #flyout { left: 8px; right: 8px; width: auto; top: auto !important; bottom: 120px; max-height: 50vh; }
  #minimap { display: none; }
  #overlays { max-width: calc(100vw - 16px); }
  #info, #districtPanel { top: auto; bottom: 130px; right: 8px; left: 8px; width: auto; max-height: 45vh; }
  .cols, .charts { grid-template-columns: 1fr; }
  .slider { grid-template-columns: 110px 1fr 44px; }
}

/* ---------- 3D ---------- */
#hud { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#game { z-index: 0; }
#loading { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1d3348, #0b121b); }
.loading-box { text-align: center; width: min(360px, 80vw); }
.loading-box h1 { font-size: 46px; margin: 0 0 18px; letter-spacing: -.03em; }
.loading-box h1 span { background: linear-gradient(90deg, #4cc38a, #6fd3ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.loading-track { height: 8px; background: rgba(255,255,255,.12); border-radius: 6px; overflow: hidden; }
.loading-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4cc38a, #6fd3ff); transition: width .2s; }
#loadingText { color: var(--muted); font-size: 14px; }
/* Vitrine: só a cidade 3D (fundo da tela de apresentação) */
body[data-modo="vitrine"] > :not(#game):not(#loading) { display: none !important; }
body[data-modo="vitrine"] #loading .loading-box { display: none; }
body[data-modo="vitrine"] #loading { background: #0d1520; }

/* Painel de som */
#soundPanel { position: fixed; top: 64px; right: 8px; z-index: 12; width: 280px; display: flex; flex-direction: column; gap: 8px; padding: 12px; }
#soundPanel .slider { grid-template-columns: 64px 1fr 44px; }
#soundPanel .sp-title { margin-top: 4px; }
#soundPanel .song { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
#soundPanel .song i { color: var(--muted); }
#soundPanel select { width: 100%; padding: 6px; border-radius: 8px; background: rgba(255,255,255,.08); color: inherit; border: 1px solid rgba(255,255,255,.15); }
#soundPanel select option { color: #111; }

/* Cidades vizinhas e acordos */
.nb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.nb { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 2px; }
.nb.on { border-color: #4fd18b; background: rgba(79,209,139,.12); cursor: pointer; }
.nb.sel { box-shadow: 0 0 0 2px #4fd18b inset; }
.nb small { opacity: .7; text-transform: uppercase; font-size: 10px; letter-spacing: .05em; }
.nb span { font-size: 12px; }
.deal { padding: 10px 0; border-top: 1px solid rgba(255,255,255,.08); }
.deal-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.deal p { margin: 4px 0 8px; }
.deal .btnrow button small { opacity: .75; }

/* Necessidades do lote no painel */
.needs { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; margin: 6px 0; }
.needs b { width: 100%; }
.needs span { background: rgba(255,90,90,.12); border: 1px solid rgba(255,90,90,.3); border-radius: 6px; padding: 1px 6px; }
.needs.ok { color: #4fd18b; }

/* Letreiro de notícias no rodapé */
#ticker { position: fixed; left: 0; right: 0; bottom: 0; height: 30px; z-index: 6; display: flex; align-items: center; gap: 0;
  background: rgba(14, 20, 28, .92); border-top: 1px solid var(--border); font-size: 13px; overflow: hidden; }
#ticker .tk-label { flex: 0 0 auto; padding: 0 12px; height: 100%; display: flex; align-items: center; font-weight: 700; background: #c0392b; color: #fff; letter-spacing: .02em; }
#ticker .tk-view { position: relative; flex: 1; height: 100%; overflow: hidden; }
#tickerTrack { position: absolute; top: 0; height: 100%; display: flex; align-items: center; white-space: nowrap; will-change: transform; }
#tickerTrack span { padding: 0 28px 0 0; }
#tickerTrack span.bad { color: #ff8b7a; } #tickerTrack span.tip { color: #9fd8ff; } #tickerTrack span.good { color: #8be3b0; }
/* Alertas e últimas notícias (abaixo do menu, à direita) */
#feed { position: fixed; top: 64px; right: 8px; z-index: 4; width: 270px; padding: 8px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 290px); overflow-y: auto; }
#feed.min .fd-body { display: none; }
#feed .fd-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; cursor: pointer; }
#feed .fd-head button { padding: 0 6px; font-size: 12px; }
#feed .al { display: flex; gap: 6px; align-items: flex-start; padding: 3px 6px; border-radius: 6px; cursor: pointer; border-left: 3px solid #e67e22; background: rgba(230,126,34,.08); }
#feed .al.bad { border-left-color: #e74c3c; background: rgba(231,76,60,.1); }
#feed .al:hover { filter: brightness(1.3); }
#feed .fd-sub { margin-top: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#feed .nw { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
#feed .nw small { color: var(--muted); }
#feed .okline { color: #4fd18b; }
@media (max-width: 760px) { #feed { display: none; } }


/* Avisos que podem ser fechados (à direita) + sino com a lista */
#toasts .toast { pointer-events: auto; position: relative; padding-right: 26px; text-align: left; }
#toasts .toast .tx { position: absolute; top: 4px; right: 6px; cursor: pointer; opacity: .6; font-size: 12px; }
#toasts .toast .tx:hover { opacity: 1; }
body:has(#info:not(.hidden)) #toasts, body:has(#districtPanel:not(.hidden)) #toasts { right: 290px; }
#btnBell { position: relative; }
#btnBell .badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #e74c3c; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
#btnBell .badge.hidden { display: none; }
#bellPanel { position: fixed; top: 64px; right: 8px; z-index: 13; width: 310px; padding: 10px 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 140px); overflow-y: auto; }
#bellPanel .al { display: flex; gap: 6px; align-items: flex-start; padding: 4px 6px; border-radius: 6px; cursor: pointer; border-left: 3px solid #e67e22; background: rgba(230,126,34,.08); }
#bellPanel .al.bad { border-left-color: #e74c3c; background: rgba(231,76,60,.1); }
#bellPanel .al:hover { filter: brightness(1.3); }
#bellPanel .sub { margin-top: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#bellPanel .nw { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
#bellPanel .nw small, #bellPanel .muted { color: var(--muted); }
#bellPanel .okline { color: #4fd18b; }
