@font-face { font-family: 'Yatra'; src: url('fonts/yatra.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'AlegreyaSans'; src: url('fonts/alegreya.woff2') format('woff2'); font-weight: 400; font-display: block; }
@font-face { font-family: 'AlegreyaSans'; src: url('fonts/alegreya-bold.woff2') format('woff2'); font-weight: 700; font-display: block; }

:root {
  --maroon: #3d1018; --maroon2: #5a1a24; --ink: #1d0c10; --gold: #e8c547; --gold2: #b8901a; --saffron: #f08a24;
  --parch: #f4e8cc; --parch2: #e6d4a8; --text: #fbf3df; --muted: #d8c6a0; --green: #6fbf4a; --red: #e0503a; --blue: #4a8ad0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140e08; color: var(--text); font-family: 'AlegreyaSans', sans-serif; font-size: 15px; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
img.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; margin-right: 1px; }
img.ic.sm { width: 0.95em; height: 0.95em; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; left: 0; right: 0; top: 0; height: 46px; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 max(8px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(61,16,24,0.97), rgba(40,10,16,0.92)); border-bottom: 2px solid var(--gold2); box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
#tb-civ { display: flex; align-items: center; gap: 6px; cursor: pointer; min-width: 0; }
#tb-portrait { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--gold); }
#tb-gold { font-size: 15px; white-space: nowrap; }
#tb-gold .pos { color: #a8e07a; } #tb-gold .neg { color: #ff8a6a; }
#tb-research { flex: 1; min-width: 120px; max-width: 320px; background: rgba(0,0,0,0.35); border: 1px solid rgba(232,197,71,0.5); border-radius: 8px; padding: 3px 8px; cursor: pointer; position: relative; overflow: hidden; }
#tb-research .rrow { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; position: relative; z-index: 1; white-space: nowrap; }
#tb-res-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
#tb-res-turns { color: var(--muted); }
#tb-res-track { height: 5px; background: rgba(255,255,255,0.12); border-radius: 3px; margin-top: 2px; position: relative; z-index: 1; }
#tb-res-bar { height: 100%; background: linear-gradient(90deg, #3a7ad0, #7ab8ff); border-radius: 3px; width: 0; transition: width .4s; }
#tb-era { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tbcol { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
#tb-gp { font-size: 13px; white-space: nowrap; cursor: pointer; }
.tbicons { display: flex; gap: 3px; }
.tbicons button, #tb-menu { width: 36px; height: 36px; border-radius: 8px; border: 1px solid rgba(232,197,71,0.45); background: rgba(0,0,0,0.3); font-size: 17px; cursor: pointer; padding: 0; }
.tbicons button:active, #tb-menu:active { background: rgba(232,197,71,0.3); }
#tb-year { text-align: right; font-family: 'Yatra', serif; font-size: 16px; line-height: 1; white-space: nowrap; color: var(--gold); }
#tb-year small { display: block; font-family: 'AlegreyaSans'; font-size: 11px; color: var(--muted); }

#unitpanel { position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: 8px; width: min(380px, 52vw); background: linear-gradient(180deg, rgba(61,16,24,0.95), rgba(30,8,12,0.95));
  border: 2px solid var(--gold2); border-radius: 12px; padding: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.6); }
.up-top { display: flex; gap: 8px; align-items: center; }
.up-img { width: 54px; height: 54px; background: radial-gradient(circle, rgba(255,240,200,0.25), rgba(0,0,0,0)); border-radius: 8px; }
.up-name { font-family: 'Yatra', serif; font-size: 17px; color: var(--gold); line-height: 1.1; }
.up-name .uu { font-family: 'AlegreyaSans'; font-size: 10px; background: var(--saffron); color: #2a1000; border-radius: 4px; padding: 0 4px; vertical-align: 2px; }
.up-stats { display: flex; gap: 10px; font-size: 14px; margin-top: 2px; }
.up-status { font-size: 12px; color: var(--muted); }
.up-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.act { flex: 1 0 auto; min-width: 54px; height: 44px; border-radius: 8px; border: 1px solid rgba(232,197,71,0.4); background: rgba(0,0,0,0.35); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; padding: 2px 4px; }
.act i { font-style: normal; font-size: 16px; line-height: 1; }
.act.primary { background: linear-gradient(180deg, #f0a030, #c06a10); color: #2a1000; font-weight: 700; border-color: var(--gold); }
.act.disabled { opacity: 0.4; }
.act:active { transform: scale(0.96); }

#endturn { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: 10px; width: 132px; height: 64px; border-radius: 34px; border: 3px solid var(--gold); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,0.6); transition: transform .1s; }
#endturn span { font-family: 'Yatra', serif; font-size: 17px; letter-spacing: 0.5px; }
#endturn small { font-size: 11px; opacity: 0.85; }
#endturn.end { background: radial-gradient(circle at 50% 30%, #f6b54a, #c0560f); color: #2a1000; animation: glow 2s infinite; }
#endturn.next { background: radial-gradient(circle at 50% 30%, #6a8ad8, #2a3f8a); color: #fff; }
#endturn:active { transform: scale(0.95); }
@keyframes glow { 0%,100% { box-shadow: 0 0 6px rgba(255,190,80,0.5), 0 4px 16px rgba(0,0,0,0.6); } 50% { box-shadow: 0 0 22px rgba(255,190,80,0.95), 0 4px 16px rgba(0,0,0,0.6); } }

#toasts { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); width: min(460px, 56vw); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.toast { background: rgba(29,12,16,0.9); border: 1px solid rgba(232,197,71,0.55); border-radius: 8px; padding: 3px 10px; font-size: 13px; line-height: 1.25; text-align: center; animation: tin .25s; transition: opacity .5s; pointer-events: auto; }
.toast.tap { cursor: pointer; }
.toast.bad { border-color: var(--red); background: rgba(70,14,14,0.94); }
.toast.gold { border-color: var(--gold); color: #ffe9a8; }
.toast.hint { border-color: #7ab8ff; background: rgba(16,30,60,0.94); }
.toast.fade { opacity: 0; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

#thinking, #loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; }
#thinking { background: rgba(0,0,0,0.25); }
#thinking div, #loading div { background: rgba(29,12,16,0.95); border: 2px solid var(--gold2); border-radius: 12px; padding: 14px 24px; font-family: 'Yatra', serif; font-size: 18px; color: var(--gold); display: flex; gap: 12px; align-items: center; }
#loading { background: #140e08; z-index: 50; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(232,197,71,0.3); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- main menu ---------- */
#menu { position: absolute; inset: 0; z-index: 5; }
#menu-art { position: absolute; inset: 0; width: 100%; height: 100%; }
#menu-title { position: absolute; left: 6vw; top: 7vh; text-shadow: 0 3px 12px rgba(0,0,0,0.6); }
#menu-title h1 { font-family: 'Yatra', serif; font-size: min(17vh, 96px); margin: 0; color: #ffe9a8; line-height: 0.95; letter-spacing: 2px; }
#menu-title h2 { font-family: 'Yatra', serif; margin: 0; font-size: min(6vh, 30px); color: #fff4d6; letter-spacing: 3px; }
#menu-title p { margin: 6px 0 0; font-size: min(3.8vh, 16px); color: #ffe0b0; max-width: 44vw; }
#menu-buttons { position: absolute; right: 6vw; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 7px; width: min(300px, 38vw); }
.mbtn { height: min(10vh, 48px); border-radius: 10px; border: 2px solid var(--gold); background: linear-gradient(180deg, rgba(61,16,24,0.92), rgba(30,8,12,0.92)); font-family: 'Yatra', serif; font-size: min(4.4vh, 19px); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; color: #ffefc8; }
.mbtn small { font-family: 'AlegreyaSans'; font-size: 12px; color: var(--muted); }
.mbtn.primary { background: linear-gradient(180deg, #f6b54a, #c0560f); color: #2a1000; }
.mbtn.primary small { color: #4a2a00; }
.mbtn:active { transform: scale(0.97); }
#menu-buttons .mbtn { flex-direction: row; }

/* ---------- modals ---------- */
#screens { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.modal-wrap { position: absolute; inset: 0; background: rgba(10,4,6,0.55); display: flex; align-items: center; justify-content: center; pointer-events: auto; animation: fin .18s; }
.modal-wrap.nodim { background: transparent; pointer-events: none; }
.modal-wrap.nodim .modal { pointer-events: auto; }
@keyframes fin { from { opacity: 0; } }
.modal { position: relative; background: linear-gradient(180deg, #4a1420, #2a0a10); border: 2px solid var(--gold2); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.7), inset 0 0 0 4px rgba(232,197,71,0.12);
  padding: 14px 16px; max-height: calc(100% - 16px); max-width: calc(100% - 16px); overflow-y: auto; width: 520px; touch-action: pan-y; }
.modal-wrap.small .modal { width: 430px; }
.modal-wrap.medium .modal { width: 580px; }
.modal-wrap.large .modal { width: 800px; }
.modal-wrap.auto .modal { width: auto; }
.modal.full { width: calc(100% - 16px); height: calc(100% - 16px); display: flex; flex-direction: column; }
.modal-wrap.side { justify-content: flex-end; }
.modal.side { width: min(560px, 60vw); height: calc(100% - 12px); margin-right: 6px; border-radius: 12px; padding: 10px 12px; }
.modal h2 { font-family: 'Yatra', serif; color: var(--gold); margin: 0 30px 8px 0; font-size: 22px; font-weight: normal; }
.modal h2 small { font-family: 'AlegreyaSans'; font-size: 13px; color: var(--muted); }
.modal h3 { font-family: 'Yatra', serif; font-weight: normal; color: var(--gold); margin: 10px 0 4px; }
.modal p { margin: 6px 0; line-height: 1.35; }
.mclose { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(232,197,71,0.5); background: rgba(0,0,0,0.35); font-size: 16px; cursor: pointer; z-index: 3; }
.mtext { margin-bottom: 10px; line-height: 1.35; }
.btnrow { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.btn { min-height: 40px; padding: 6px 16px; border-radius: 9px; border: 1px solid var(--gold2); background: rgba(0,0,0,0.3); font-size: 15px; cursor: pointer; color: var(--text); }
.btn.primary { background: linear-gradient(180deg, #f6b54a, #c0560f); color: #2a1000; font-weight: 700; border-color: var(--gold); }
.btn.danger { background: linear-gradient(180deg, #d0503a, #8a1a10); border-color: #ff9a7a; }
.btn.big { font-family: 'Yatra', serif; font-size: 19px; padding: 6px 26px; font-weight: normal; }
.btn.disabled { opacity: 0.45; }
.btn:active { transform: scale(0.97); }
.small { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 10px; }
.chip { display: inline-block; background: rgba(255,255,255,0.08); border: 1px solid rgba(232,197,71,0.35); border-radius: 6px; padding: 1px 6px; margin: 2px; font-size: 12px; }
.chip.gold { background: rgba(232,197,71,0.2); border-color: var(--gold); color: #ffe9a8; }
.chip.off { opacity: 0.45; }
.era { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
img.mini { width: 24px; height: 24px; border-radius: 4px; vertical-align: middle; }
.bar { height: 6px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #e8a33a, #ffd84a); }

/* new game */
.ng { display: flex; gap: 12px; flex: 1; min-height: 0; }
.ng-civs { width: 44%; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; overflow-y: auto; align-content: start; padding-right: 4px; }
.civcard { background: rgba(0,0,0,0.3); border: 2px solid; border-radius: 10px; padding: 5px; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.civcard img { width: 56px; height: 56px; border-radius: 8px; }
.civcard b { font-size: 12px; line-height: 1.1; margin-top: 3px; }
.civcard small { font-size: 10px; color: var(--muted); }
.civcard.on { background: rgba(232,197,71,0.25); box-shadow: 0 0 12px rgba(232,197,71,0.6); }
.ng-detail { flex: 1; overflow-y: auto; background: rgba(0,0,0,0.25); border-radius: 10px; padding: 10px; }
.cd-head { display: flex; gap: 10px; align-items: center; }
.cd-head img { width: 84px; height: 84px; border-radius: 10px; }
.cd-head h3 { margin: 0; font-family: 'Yatra', serif; font-weight: normal; color: var(--gold); font-size: 22px; }
.cd-leader { font-size: 16px; } .cd-era { font-size: 12px; color: var(--muted); }
.cd-sec { margin: 8px 0; font-size: 14px; }
.cd-sec.uu { display: flex; gap: 8px; align-items: center; background: rgba(240,138,36,0.12); border-radius: 8px; padding: 4px; }
.cd-sec.uu img { width: 56px; height: 56px; }
.bonuses { margin: 4px 0; padding-left: 0; list-style: none; }
.bonuses li { margin: 4px 0; font-size: 14px; }
.bera { display: inline-block; font-size: 10px; background: rgba(232,197,71,0.25); color: #ffe9a8; border-radius: 4px; padding: 0 5px; margin-right: 5px; text-transform: uppercase; }
.blurb { font-style: italic; color: #f0dfb8; font-size: 14px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; overflow-y: auto; flex: 1; align-content: start; }
.opt.wide { grid-column: 1 / -1; }
.opt label { display: block; font-family: 'Yatra', serif; color: var(--gold); margin-bottom: 4px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { min-height: 38px; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--gold2); background: rgba(0,0,0,0.3); cursor: pointer; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.seg button small { font-size: 10px; color: var(--muted); }
.seg button.on { background: linear-gradient(180deg, #f6b54a, #c0560f); color: #2a1000; font-weight: 700; }
.seg button.on small { color: #4a2a00; }
.optdesc { font-size: 13px; color: var(--muted); margin-top: 4px; }
.intro { display: flex; gap: 14px; align-items: flex-start; }
.intro img { width: 130px; height: 130px; border-radius: 12px; flex: none; }
.goal { background: rgba(0,0,0,0.25); border-radius: 8px; padding: 6px 8px; font-size: 14px; }

/* city */
.city { display: flex; flex-direction: column; gap: 6px; }
.c-head { display: flex; justify-content: space-between; align-items: center; margin-right: 36px; }
.c-name { font-family: 'Yatra', serif; font-size: 22px; color: var(--gold); cursor: pointer; }
.c-name .cap { font-family: 'AlegreyaSans'; font-size: 12px; color: #ffe9a8; }
.c-size { font-size: 18px; font-weight: 700; }
.c-yields { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px; }
.cy { background: rgba(0,0,0,0.3); border-radius: 8px; padding: 4px 6px; font-size: 15px; }
.cy small { display: block; font-size: 11px; color: var(--muted); line-height: 1.15; }
.c-focus { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.c-focus button, .tabs button { min-height: 32px; padding: 2px 9px; border-radius: 7px; border: 1px solid rgba(232,197,71,0.4); background: rgba(0,0,0,0.3); cursor: pointer; font-size: 13px; }
.c-focus .gov-btn { margin-left: auto; }
.c-focus button.on, .tabs button.on { background: rgba(232,197,71,0.85); color: #2a1000; font-weight: 700; }
.c-build { display: flex; gap: 8px; align-items: center; background: rgba(240,138,36,0.12); border: 1px solid rgba(240,138,36,0.4); border-radius: 10px; padding: 5px; }
.c-build img { width: 46px; height: 46px; border-radius: 6px; }
.cb-info { flex: 1; } .cb-info small { display: block; color: var(--muted); font-size: 12px; }
.btn.buy { min-width: 70px; font-size: 13px; line-height: 1.1; }
.tabs { display: flex; gap: 4px; }
.c-list { display: flex; flex-direction: column; gap: 3px; }
.bitem { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.28); border: 1px solid transparent; border-radius: 8px; padding: 3px 5px; cursor: pointer; min-height: 46px; }
.bitem img { width: 40px; height: 40px; border-radius: 6px; flex: none; }
.bitem.on { border-color: var(--gold); background: rgba(232,197,71,0.18); }
.bitem.victory { background: linear-gradient(90deg, rgba(232,197,71,0.25), rgba(0,0,0,0.2)); }
.bi-t { flex: 1; min-width: 0; } .bi-t b { display: block; font-size: 14px; } .bi-t small { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bi-c { text-align: right; font-weight: 700; font-size: 14px; } .bi-c small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.bitem .info { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(232,197,71,0.4); background: rgba(0,0,0,0.3); cursor: pointer; flex: none; }
.c-extra { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.uchip { display: inline-flex; align-items: center; gap: 3px; background: rgba(0,0,0,0.3); border: 1px solid rgba(232,197,71,0.4); border-radius: 8px; padding: 1px 6px 1px 1px; margin: 2px; cursor: pointer; font-size: 12px; }
.uchip img { width: 28px; height: 28px; }

/* tech */
.tlist { display: flex; flex-direction: column; gap: 4px; }
.titem { display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,0.3); border-left: 5px solid; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.titem small { display: block; font-size: 12px; color: var(--muted); }
.ti-c { font-weight: 700; font-size: 16px; color: #7ab8ff; }
.tree-wrap { flex: 1; overflow: auto; touch-action: pan-x pan-y; background: rgba(0,0,0,0.25); border-radius: 10px; }
.tree { position: relative; }
.tree canvas { position: absolute; left: 0; top: 0; }
.tnode { position: absolute; width: 150px; height: 48px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); border-top: 4px solid; background: rgba(40,30,40,0.95); padding: 3px 7px; cursor: pointer; font-size: 13px; line-height: 1.15; }
.tnode small { display: block; font-size: 11px; color: var(--muted); }
.tnode.known { background: rgba(70,60,20,0.95); border-color: rgba(232,197,71,0.7); }
.tnode.current { background: rgba(30,60,120,0.98); box-shadow: 0 0 10px #4a8ad0; border-color: #7ab8ff; }
.tnode.avail { background: rgba(30,45,70,0.95); border-color: #4a8ad0; }
.tnode.locked { opacity: 0.7; }
.tnode.goal { outline: 2px dashed #ffd84a; opacity: 1; }
.tdetail { margin-top: 6px; background: rgba(0,0,0,0.3); border-radius: 10px; padding: 6px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; min-height: 56px; }
.td-t { flex: 1; } .td-t p { margin: 2px 0; } .td-t small { color: var(--muted); }
.learned { text-align: center; }
.learned .burst img { width: 64px; height: 64px; }
.learned h2 { margin: 4px 0; }
.unl { background: rgba(0,0,0,0.25); border-radius: 8px; padding: 6px; font-size: 14px; }

/* events / leaders */
.ev { display: flex; gap: 12px; align-items: flex-start; }
.evp { width: 84px; height: 84px; border-radius: 10px; flex: none; }
.wonder { text-align: center; }
.wonder img { width: 120px; height: 120px; border-radius: 12px; box-shadow: 0 0 24px rgba(232,197,71,0.6); }
.wcity { color: var(--muted); font-size: 13px; }
.lore { font-style: italic; color: #f0dfb8; }
.leader { display: flex; gap: 14px; align-items: flex-start; }
.leader img { width: 130px; height: 130px; border-radius: 12px; flex: none; box-shadow: 0 4px 14px rgba(0,0,0,0.6); }
.leader h2 { margin-bottom: 0; }
.lciv { font-weight: 700; } .ltitle { font-family: 'Yatra', serif; font-size: 16px; color: #ffe9a8; margin-top: 4px; }
.quote { font-size: 16px; font-style: italic; color: #f8ecd0; }
.battle { display: flex; align-items: center; justify-content: space-around; gap: 6px; }
.bside { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; text-align: center; width: 36%; }
.bside > img { width: 72px; height: 72px; }
.bside span { font-size: 15px; }
.bodds { font-family: 'Yatra', serif; font-size: 34px; text-align: center; } .bodds small { display: block; font-family: 'AlegreyaSans'; font-size: 11px; color: var(--muted); }
.bodds.good { color: #8ae06a; } .bodds.even { color: #ffd84a; } .bodds.bad { color: #ff7a6a; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.srow, .trow { display: flex; gap: 8px; align-items: center; background: rgba(0,0,0,0.28); border-radius: 8px; padding: 3px 6px; cursor: pointer; }
.srow img, .trow img { width: 42px; height: 42px; }
.srow small { display: block; color: var(--muted); font-size: 12px; }
.tinfo .yields { font-size: 16px; }

/* great people */
.gp { text-align: center; }
.gpicon img { width: 60px; height: 60px; }
.gpt { color: var(--muted); }
.gpch { display: flex; gap: 10px; margin-top: 10px; }
.gpo { flex: 1; background: rgba(0,0,0,0.3); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.gpo small { color: var(--muted); }
.gpo select { width: 100%; min-height: 36px; background: #2a0a10; color: var(--text); border: 1px solid var(--gold2); border-radius: 6px; font-size: 14px; }

/* diplomacy / gov / empire */
.diplo { display: flex; flex-direction: column; gap: 6px; }
.drow { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.28); border-radius: 10px; padding: 5px; flex-wrap: wrap; }
.drow.dead { opacity: 0.5; }
.drow img { width: 52px; height: 52px; border-radius: 8px; }
.dinfo { flex: 1; min-width: 200px; } .dinfo small { display: block; color: var(--muted); font-size: 12px; }
.dstat { font-weight: 700; padding: 2px 10px; border-radius: 10px; font-size: 13px; }
.dstat.war { background: #a02a1a; } .dstat.peace { background: #2a7a3a; }
.dbtns { display: flex; gap: 4px; flex-wrap: wrap; }
.dbtns .btn { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.govs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.gov { background: rgba(0,0,0,0.28); border-radius: 10px; padding: 8px; border: 1px solid rgba(232,197,71,0.3); display: flex; flex-direction: column; gap: 3px; }
.gov b { font-family: 'Yatra', serif; font-weight: normal; font-size: 18px; color: var(--gold); } .gov i { font-size: 12px; color: var(--muted); }
.gov p { font-size: 13px; flex: 1; }
.gov.cur { border-color: var(--gold); background: rgba(232,197,71,0.15); }
.gov.locked { opacity: 0.55; }
.gtag { font-size: 12px; color: #ffe9a8; }
.emp-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.emp-head img { width: 60px; height: 60px; border-radius: 10px; }
.emp-head small { display: block; color: var(--muted); font-size: 13px; }
.emp-bonus { margin-bottom: 6px; }
table.emp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.emp th { text-align: left; color: var(--gold); font-weight: 700; padding: 3px 4px; border-bottom: 1px solid rgba(232,197,71,0.4); }
table.emp td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,0.06); }
table.emp tr[data-k] { cursor: pointer; }
table.emp tr.me td { background: rgba(232,197,71,0.15); }
.menulist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.menulist .mbtn { font-size: 16px; height: 44px; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { background: rgba(0,0,0,0.3); border: 1px solid rgba(232,197,71,0.35); border-radius: 10px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.slot small { color: var(--muted); font-size: 11px; }
.settings { display: flex; flex-direction: column; gap: 8px; }
.tog { display: flex; align-items: center; justify-content: space-between; background: rgba(0,0,0,0.25); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.tog input { display: none; }
.tog i { width: 44px; height: 24px; border-radius: 12px; background: #555; position: relative; transition: background .2s; }
.tog i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.tog input:checked + i { background: var(--saffron); }
.tog input:checked + i::after { left: 23px; }
.gpinfo ul { margin: 4px 0; padding-left: 20px; }

/* victory */
.victory { text-align: center; }
.victory table.emp td, .victory table.emp th { text-align: left; }
.victory img { width: 120px; height: 120px; border-radius: 14px; box-shadow: 0 0 30px rgba(232,197,71,0.7); }
.victory h1 { font-family: 'Yatra', serif; font-weight: normal; color: var(--gold); margin: 6px 0; font-size: 30px; }
.victory.lost h1 { color: #ff9a7a; }

/* pedia */
.pedia-wrap .modal.full { padding: 10px; }
.pedia { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ptabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; margin-right: 38px; flex: none; touch-action: pan-x; }
.ptabs button { flex: none; min-height: 34px; padding: 3px 11px; border-radius: 8px; border: 1px solid rgba(232,197,71,0.4); background: rgba(0,0,0,0.3); cursor: pointer; font-size: 13px; white-space: nowrap; }
.ptabs button.on { background: var(--gold); color: #2a1000; font-weight: 700; }
.pbody { flex: 1; display: flex; gap: 8px; min-height: 0; }
.plist { width: 32%; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; touch-action: pan-y; }
.pitem { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; min-height: 36px; }
.pitem img { width: 30px; height: 30px; border-radius: 4px; flex: none; }
.pitem small { display: block; font-size: 11px; color: var(--muted); }
.pitem.on { background: rgba(232,197,71,0.25); }
.pdet { flex: 1; overflow-y: auto; background: linear-gradient(180deg, var(--parch), var(--parch2)); color: #2a1408; border-radius: 10px; padding: 10px 14px; touch-action: pan-y; }
.pdet h2 { color: #6a1a10; } .pdet h3 { color: #6a1a10; }
.pdet .small, .pdet small { color: #6a5030; }
.pdet .plink { color: #a0300a; font-weight: 700; text-decoration: underline; cursor: pointer; }
.pdet .lore, .pdet .blurb { color: #5a3a20; }
.pdet .cd-head h3 { color: #6a1a10; } .pdet .cd-era { color: #6a5030; }
.pdet .bera { background: #6a1a10; color: #ffe9a8; }
.pdet .cd-sec.uu { background: rgba(160,60,10,0.12); }
.pdet .chip { color: #2a1408; }
.phead { display: flex; gap: 12px; align-items: center; }
.phead img.big { width: 100px; height: 100px; background: radial-gradient(circle, rgba(255,255,255,0.6), rgba(255,255,255,0)); border-radius: 10px; }
.phead img.mid { width: 64px; height: 64px; }
.pstats { font-size: 14px; margin: 2px 0; }
.pback { margin-top: 10px; color: #2a1408; border-color: #8a5a20; }

@media (max-height: 380px) {
  #topbar { height: 42px; }
  .tbicons button, #tb-menu { width: 32px; height: 32px; font-size: 15px; }
  #endturn { width: 116px; height: 56px; }
  #unitpanel { padding: 4px; }
  .act { height: 38px; min-width: 48px; }
  .up-img { width: 44px; height: 44px; }
  .modal h2 { font-size: 19px; margin-bottom: 4px; }
}
@media (max-width: 720px) { #tb-era, .tbicons .opt2 { display: none; } }

input.txt { width: 100%; min-height: 42px; font-size: 17px; font-family: inherit; background: #1d0c10; color: var(--text); border: 1px solid var(--gold2); border-radius: 8px; padding: 6px 10px; user-select: text; -webkit-user-select: text; }

#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#camctl { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: 82px; display: flex; gap: 4px; }
#camctl button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--gold2); background: rgba(40,10,16,0.85); color: #ffe9a8; font-size: 18px; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; }
#camctl #cam-n i { font-style: normal; font-family: 'Yatra', serif; font-size: 15px; display: inline-block; transition: transform .1s; }
#camctl button:active { transform: scale(0.92); }
.gfx { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(232,197,71,0.3); padding-top: 8px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: rgba(0,0,0,0.25); border-radius: 8px; padding: 6px 10px; flex-wrap: wrap; }
@media (max-height: 380px) { #camctl { bottom: 70px; } #camctl button { width: 34px; height: 34px; } }
