/* Terra Towns (/towns/): the world page and the play / visit page.
   Brand: teal UI accent, ochre on the map, basalt panels. */

.tt {
    --tt-bg: #151917;
    --tt-panel: #1e2421;
    --tt-panel-2: #262d29;
    --tt-ink: #eceee9;
    --tt-muted: #9aa49e;
    --tt-rule: rgba(236, 238, 233, 0.1);
    --tt-accent: var(--tp-accent, #2fa596);
    --tt-accent-2: #3cb8a8;
    --tt-ochre: #e3b04b;
    --tt-bad: #e5484d;
    color: var(--tt-ink);
    box-sizing: border-box;
}
.tt *, .tt *::before, .tt *::after { box-sizing: border-box; }
.tt h1, .tt h2, .tt h3 { color: var(--tt-ink); font-family: 'Bricolage Grotesque', system-ui, sans-serif; }
.tt a { color: var(--tt-accent-2); }
.tt-muted { color: var(--tt-muted); }
.tt-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- play / visit page ---------- */
.tt-play {
    display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px;
    width: 100%; max-width: 1680px; margin: 0 auto; padding: 10px 14px 24px;
}
.tt-stage {
    position: relative; height: calc(100vh - 84px); min-height: 520px;
    border-radius: 14px; overflow: hidden; background: #0f1311;
}
.tt-view { position: absolute; inset: 0; }
.tt-view canvas { display: block; }
.tt-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tt-label {
    position: absolute; left: 0; top: 0; white-space: nowrap;
    background: rgba(21, 25, 23, 0.82); color: var(--tt-ochre); border: 1px solid rgba(227, 176, 75, 0.4);
    border-radius: 999px; padding: 2px 10px; font-size: 0.78rem; font-weight: 600;
}

.tt-hud {
    position: absolute; left: 12px; top: 12px; right: 12px; pointer-events: none;
    display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start;
}
.tt-hud > * { pointer-events: auto; }
.tt-title { display: flex; gap: 10px; align-items: center; background: rgba(21, 25, 23, 0.86); border-radius: 12px; padding: 8px 14px 8px 8px; backdrop-filter: blur(6px); }
.tt-title h1 { font-size: 1.25rem; margin: 0; line-height: 1.15; }
.tt-sub { margin: 0; font-size: 0.8rem; color: var(--tt-muted); }
.tt-back { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--tt-panel-2); color: var(--tt-ink) !important; font-size: 1.2rem; text-decoration: none; }
.tt-status { color: var(--tt-ochre); }
.tt-stats {
    display: flex; gap: 2px; margin: 0; background: rgba(21, 25, 23, 0.86); border-radius: 12px; padding: 6px; backdrop-filter: blur(6px);
}
.tt-stats > div { padding: 2px 10px; min-width: 70px; }
.tt-stats dt { font-size: 0.68rem; font-weight: 500; color: var(--tt-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tt-stats dd { margin: 0; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-stats dd small { font-size: 0.7rem; font-weight: 500; color: var(--tt-muted); }
#ttMoney.neg { color: var(--tt-bad); }
.tt-demand dd { display: flex; gap: 5px; align-items: flex-end; height: 26px; }
.tt-dem { position: relative; width: 14px; height: 26px; background: rgba(255, 255, 255, 0.06); border-radius: 3px; display: block; }
.tt-dem i { position: absolute; left: 0; right: 0; bottom: 50%; background: #8bc26a; border-radius: 2px; }
.tt-dem.c i { background: #7fb0e0; } .tt-dem.i i { background: var(--tt-ochre); }
.tt-dem i.neg { bottom: auto; top: 50%; background: var(--tt-bad); }
.tt-dem b { position: absolute; left: 0; right: 0; bottom: -14px; font-size: 0.6rem; text-align: center; color: var(--tt-muted); }
.tt-time { width: 100%; margin: 0; font-size: 0.78rem; color: var(--tt-ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

.tt-overlays { position: absolute; right: 12px; top: 128px; display: flex; flex-direction: column; gap: 4px; }
.tt-overlays button, .tt-tool {
    border: 1px solid var(--tt-rule); background: rgba(21, 25, 23, 0.86); color: var(--tt-ink);
    border-radius: 10px; padding: 6px 10px; font-size: 0.78rem; text-align: left; cursor: pointer; backdrop-filter: blur(6px);
}
.tt-overlays button[aria-pressed="true"], .tt-tool[aria-pressed="true"] { border-color: var(--tt-accent); background: rgba(47, 165, 150, 0.28); }
.tt-overlays button:hover, .tt-tool:hover { border-color: var(--tt-accent-2); }

.tt-tools { position: absolute; left: 12px; right: 12px; bottom: 12px; }
.tt-toolbtns { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.tt-tool { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 70px; padding: 6px 6px 5px; text-align: center; }
.tt-tool i { font-size: 1.25rem; }
.tt-tool span { font-size: 0.72rem; white-space: nowrap; }
.tt-tool small { font-size: 0.62rem; color: var(--tt-muted); }
.tt-toolhelp { margin: 6px 0 0; font-size: 0.78rem; color: var(--tt-ink); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); }

.tt-tip { position: absolute; left: 0; top: 0; pointer-events: none; background: rgba(21, 25, 23, 0.92); border: 1px solid var(--tt-rule); padding: 3px 8px; border-radius: 8px; font-size: 0.76rem; white-space: nowrap; }
.tt-toast { position: absolute; left: 50%; top: 96px; transform: translateX(-50%); background: var(--tt-panel); border: 1px solid var(--tt-accent); padding: 8px 14px; border-radius: 10px; font-size: 0.85rem; max-width: 90%; z-index: 5; }
.tt-toast.bad { border-color: var(--tt-bad); }
.tt-saving { position: absolute; right: 12px; bottom: 96px; font-size: 0.75rem; background: rgba(21, 25, 23, 0.86); padding: 4px 10px; border-radius: 8px; }
.tt-spin { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--tt-accent); border-right-color: transparent; border-radius: 50%; animation: tt-spin 0.8s linear infinite; vertical-align: -1px; }
@keyframes tt-spin { to { transform: rotate(360deg); } }
.tt-inspect { position: absolute; right: 12px; bottom: 110px; max-width: 280px; background: rgba(21, 25, 23, 0.92); border: 1px solid var(--tt-rule); border-radius: 12px; padding: 10px 12px; font-size: 0.82rem; cursor: pointer; }
.tt-inspect div + div { margin-top: 3px; }

.tt-found, .tt-welcome, .tt-gone {
    position: absolute; left: 12px; top: 96px; width: min(360px, calc(100% - 24px));
    background: rgba(21, 25, 23, 0.94); border: 1px solid var(--tt-rule); border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(6px);
}
.tt-found h2, .tt-welcome h2, .tt-gone h2 { font-size: 1.1rem; margin: 0 0 6px; }
.tt-found label { font-size: 0.8rem; color: var(--tt-muted); margin-top: 4px; }
.tt-found .form-control { background: var(--tt-panel-2); color: var(--tt-ink); border-color: var(--tt-rule); }
.tt-welcome ol { padding-left: 1.2rem; margin: 6px 0; font-size: 0.86rem; }
.tt-welcome li + li { margin-top: 4px; }
.tt-x { position: absolute; right: 8px; top: 8px; background: none; border: 0; color: var(--tt-muted); font-size: 1.3rem; }
.tt-gone { top: 40%; left: 50%; transform: translate(-50%, -50%); text-align: center; }

.tt-side { display: flex; flex-direction: column; gap: 12px; }
.tt-side section { background: var(--tt-panel); border-radius: 14px; padding: 12px 14px; }
.tt-side h2 { font-size: 0.95rem; margin: 0 0 8px; }
.tt-range { display: grid; grid-template-columns: 70px 1fr 38px; gap: 8px; align-items: center; font-size: 0.82rem; width: 100%; margin-bottom: 4px; }
.tt-range input { accent-color: var(--tt-accent); }
.tt-nb { list-style: none; padding: 0; margin: 0; font-size: 0.86rem; }
.tt-nb li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--tt-rule); }
.tt-nb li:last-child { border-bottom: 0; }
.tt-nb small { color: var(--tt-muted); }
.tt-side .form-control { background: var(--tt-panel-2); color: var(--tt-ink); border-color: var(--tt-rule); }
.tt-mayoronly { display: none; }
body.tt-mine .tt-mayoronly { display: block; }
.tt-side summary { cursor: pointer; font-size: 0.86rem; }

/* ---------- world page ---------- */
.tt-world { width: 100%; max-width: 1280px; margin: 0 auto; padding: 18px 16px 48px; }
.tt-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 18px; }
.tt-kicker { color: var(--tt-ochre); font-weight: 600; font-size: 0.85rem; margin: 0 0 4px; }
.tt-hero h1 { font-size: clamp(2rem, 4vw, 3rem); margin: 0 0 8px; line-height: 1.05; }
.tt-lead { font-size: 1.05rem; color: var(--tt-ink); opacity: 0.9; }
.tt-totals { display: flex; gap: 10px; flex-wrap: wrap; }
.tt-totals div { background: var(--tt-panel); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.tt-totals b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.tt-totals span { font-size: 0.78rem; color: var(--tt-muted); }
.tt-mapwrap { position: relative; height: min(70vh, 640px); min-height: 380px; border-radius: 14px; overflow: hidden; background: #0f1311; }
#ttMap { position: absolute; inset: 0; }
.tt-search { position: absolute; left: 10px; top: 10px; z-index: 2; display: flex; gap: 6px; width: min(380px, calc(100% - 20px)); }
.tt-search input { flex: 1; background: rgba(21, 25, 23, 0.92); color: var(--tt-ink); border: 1px solid var(--tt-rule); border-radius: 10px; padding: 8px 12px; }
.tt-search button { background: var(--tt-accent); color: #fff; border: 0; border-radius: 10px; padding: 0 14px; }
.tt-results { position: absolute; left: 10px; top: 54px; z-index: 3; width: min(380px, calc(100% - 20px)); list-style: none; margin: 0; padding: 4px; background: var(--tt-panel); border-radius: 10px; }
.tt-results button { width: 100%; text-align: left; background: none; border: 0; color: var(--tt-ink); padding: 6px 8px; border-radius: 8px; font-size: 0.86rem; }
.tt-results button:hover { background: var(--tt-panel-2); }
.tt-maphint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; background: rgba(21, 25, 23, 0.9); border-radius: 999px; padding: 6px 14px; font-size: 0.82rem; white-space: nowrap; }
.tt-plotcard {
    position: absolute; right: 10px; top: 10px; z-index: 2; width: min(300px, calc(100% - 20px));
    background: rgba(21, 25, 23, 0.95); border: 1px solid var(--tt-rule); border-radius: 14px; padding: 12px 14px;
}
.tt-plotcard h3 { font-size: 1rem; margin: 0 0 4px; }
.tt-plotcard p { font-size: 0.84rem; margin: 0 0 8px; }
.tt-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.tt-cols section { background: var(--tt-panel); border-radius: 14px; padding: 14px 16px; }
.tt-cols h2 { font-size: 1.05rem; margin: 0 0 8px; }
.tt-cols ol, .tt-cols ul { padding-left: 1.2rem; margin: 0; font-size: 0.9rem; }
.tt-cols li + li { margin-top: 4px; }
.tt-top li { display: flex; justify-content: space-between; gap: 8px; }
.tt-top small { color: var(--tt-muted); }
.maplibregl-popup-content { background: var(--tt-panel, #1e2421); color: #eceee9; }

@media (max-width: 900px) {
    .tt-play { grid-template-columns: 1fr; padding: 0 0 16px; }
    .tt-stage { height: calc(100svh - 60px); border-radius: 0; }
    .tt-side { padding: 0 16px; }
    .tt-hud { left: 8px; right: 8px; top: 8px; gap: 6px; }
    .tt-title { padding: 6px 10px 6px 6px; }
    .tt-title h1 { font-size: 1.05rem; }
    .tt-stats { width: 100%; justify-content: space-between; overflow-x: auto; }
    .tt-stats > div { min-width: 0; padding: 2px 6px; }
    .tt-stats dd { font-size: 0.92rem; }
    .tt-overlays { top: auto; bottom: 150px; right: 8px; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; left: 8px; }
    .tt-overlays button { padding: 5px 8px; font-size: 0.7rem; }
    .tt-tools { left: 8px; right: 8px; bottom: 8px; }
    .tt-tool { min-width: 58px; }
    .tt-found, .tt-welcome { top: auto; bottom: 10px; left: 8px; width: calc(100% - 16px); max-height: 55%; overflow: auto; }
    .tt-hero { grid-template-columns: 1fr; }
    .tt-cols { grid-template-columns: 1fr; }
    .tt-world { padding: 12px 16px 40px; }
}
