@font-face { font-family: 'Nunito'; src: url('assets/nunito-var.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Almendra'; src: url('assets/almendra-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --paper: #f8efd9; --paper2: #efe2c4; --paper3: #e4d3ad; --ink: #3d2f1f; --ink2: #6b5a45; --ink3: #94826a;
  --line: #c9b68d; --accent: #2f8f83; --accent2: #256f66; --gold: #d99a16; --red: #c8483a; --green: #3f9a4d; --blue: #3d76b8;
  --shadow: 0 0.18rem 0.6rem rgba(40, 28, 12, 0.32);
  --font: 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --display: 'Almendra', Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fd4f0; font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; }
html { font-size: 16px; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; font-size: 0.875rem; line-height: 1.3; }
#ui > * { pointer-events: auto; }
#ui .pass { pointer-events: none; }
.hud { position: absolute; inset: 0; pointer-events: none !important; }
.hud > .topbar, .hud > .side, .sectag { pointer-events: auto; }
.ic { width: 1.25em; height: 1.25em; vertical-align: -0.28em; flex: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar { position: absolute; left: 0; right: 0; top: 0; height: 2.6rem; display: flex; align-items: center; gap: 0.35rem; padding: 0 0.5rem; background: linear-gradient(#fbf4e2, #f1e4c6); border-bottom: 0.14rem solid var(--line); box-shadow: var(--shadow); }
.town { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.75rem 0.2rem 0.35rem; border-radius: 1.4rem; background: var(--accent); color: #fff; border: 0.12rem solid var(--accent2); cursor: pointer; max-width: 17rem; position: relative; overflow: hidden; }
.town:hover { filter: brightness(1.08); }
.town .crest { width: 1.75rem; height: 1.75rem; border-radius: 50%; background: #fff3; display: grid; place-items: center; font-size: 1rem; flex: none; }
.town .nm { font-family: var(--display); font-size: 1.1rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.town .rk { font-size: 0.7rem; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; white-space: nowrap; }
.town .prog { position: absolute; left: 0; bottom: 0; height: 0.2rem; background: #ffd95a; transition: width 0.4s; }
.town.ready { animation: pulse 1.1s infinite; border-color: #ffd95a; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 70, 0.9); } 50% { box-shadow: 0 0 0 0.5rem rgba(255, 210, 70, 0); } }
.stats { display: flex; align-items: center; gap: 0.3rem; margin-left: 0.3rem; }
.stat { display: flex; align-items: center; gap: 0.3rem; padding: 0.22rem 0.55rem; background: #fff8; border: 0.08rem solid var(--line); border-radius: 0.6rem; font-weight: 800; font-size: 0.95rem; white-space: nowrap; cursor: default; }
.stat small { font-weight: 700; color: var(--ink2); font-size: 0.75rem; }
.stat .pos { color: var(--green); }
.stat .neg { color: var(--red); }
.stat.bad { background: #ffd9cf; border-color: var(--red); }
.spacer { flex: 1; }
.season { display: flex; align-items: center; gap: 0.35rem; font-weight: 800; font-size: 0.82rem; color: var(--ink2); white-space: nowrap; padding: 0.2rem 0.5rem; }
.season .yr { color: var(--ink3); font-weight: 700; }
.season .sbar { width: 2.6rem; height: 0.3rem; background: var(--paper3); border-radius: 0.2rem; overflow: hidden; }
.season .sbar i { display: block; height: 100%; background: var(--accent); }
.speed { display: flex; background: var(--paper3); border-radius: 0.6rem; padding: 0.12rem; gap: 0.1rem; }
.speed button, .iconbtn { width: 2rem; height: 2rem; border-radius: 0.5rem; border: none; background: transparent; color: var(--ink2); display: grid; place-items: center; font-size: 1rem; padding: 0; }
.speed button:hover, .iconbtn:hover { background: #fff9; color: var(--ink); }
.speed button.on { background: var(--accent); color: #fff; }
.speed button.on.paused { background: var(--red); }
.iconbtn { border: 0.08rem solid var(--line); background: #fff8; position: relative; }
.iconbtn .dot { position: absolute; right: -0.2rem; top: -0.2rem; min-width: 0.95rem; height: 0.95rem; border-radius: 0.5rem; background: var(--red); color: #fff; font-size: 0.62rem; font-weight: 900; display: grid; place-items: center; padding: 0 0.2rem; }

/* ---------- resource bar ---------- */
.resbar { position: absolute; left: 0; right: 0; top: 2.6rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem; padding: 0.2rem 0.5rem; pointer-events: none !important; }
.chip { pointer-events: auto; display: flex; align-items: center; gap: 0.22rem; padding: 0.12rem 0.45rem 0.12rem 0.3rem; background: rgba(250, 242, 222, 0.94); border: 0.08rem solid var(--line); border-radius: 0.8rem; font-weight: 800; font-size: 0.82rem; cursor: pointer; box-shadow: 0 0.08rem 0.2rem rgba(40, 28, 12, 0.2); min-width: 3.1rem; }
.chip:hover { background: #fff; }
.chip.zero { color: var(--red); border-color: #e0a79d; }
.chip.cap { color: #a36a00; border-color: #e2c273; }
.chip.flash { animation: flash 0.6s; }
@keyframes flash { 0% { background: #ffe9a8; transform: scale(1.12); } 100% { background: rgba(250, 242, 222, 0.94); transform: none; } }
.chipsep { width: 0.3rem; }

/* ---------- left column ---------- */
.left { position: absolute; left: 0.5rem; top: 5.3rem; width: 17.5rem; display: flex; flex-direction: column; gap: 0.4rem; pointer-events: none !important; }
.left > * { pointer-events: auto; }
.quest { background: var(--paper); border: 0.12rem solid var(--line); border-radius: 0.8rem; box-shadow: var(--shadow); padding: 0.55rem 0.7rem 0.6rem; position: relative; overflow: hidden; }
.quest::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0.32rem; background: var(--gold); }
.quest .qh { display: flex; align-items: center; gap: 0.4rem; font-family: var(--display); font-size: 1.12rem; line-height: 1.1; color: #5a3d0a; }
.quest .qh .tag { font-family: var(--font); font-size: 0.6rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; background: var(--gold); color: #fff; padding: 0.08rem 0.4rem; border-radius: 0.5rem; }
.quest .qt { margin: 0.3rem 0 0.45rem; color: var(--ink2); font-size: 0.82rem; font-weight: 600; }
.quest .qf { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.8rem; }
.quest .qf .rew { margin-left: auto; color: #8a5a00; white-space: nowrap; }
.quest.min .qt, .quest.min .qf { display: none; }
.quest .qmin { position: absolute; right: 0.3rem; top: 0.25rem; width: 1.3rem; height: 1.3rem; border: none; background: none; color: var(--ink3); font-weight: 900; }
.quest .qbtn { margin-top: 0.45rem; }
.quest.done { animation: questdone 0.9s; }
@keyframes questdone { 0% { transform: scale(1); background: #fff3bf; } 30% { transform: scale(1.04); background: #ffe58a; } 100% { transform: scale(1); background: var(--paper); } }
.bar { flex: 1; height: 0.55rem; background: var(--paper3); border-radius: 0.3rem; overflow: hidden; min-width: 2rem; }
.bar i { display: block; height: 100%; background: linear-gradient(#58b8a6, var(--accent)); border-radius: 0.3rem; transition: width 0.3s; }
.bar.gold i { background: linear-gradient(#f3cb5a, var(--gold)); }
.bar.red i { background: linear-gradient(#e88272, var(--red)); }
.alerts { display: flex; flex-direction: column; gap: 0.22rem; align-items: flex-start; }
.alert { display: flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem 0.2rem 0.35rem; background: #fff4d6; border: 0.08rem solid #e2c273; border-radius: 0.8rem; font-size: 0.78rem; font-weight: 800; color: #6b4a00; cursor: pointer; box-shadow: 0 0.08rem 0.2rem rgba(40, 28, 12, 0.2); }
.alert.l2 { background: #ffdcd3; border-color: #e0988b; color: #7a1f12; }
.alert.l0 { background: #e9f1f8; border-color: #a9c3da; color: #254a6b; }
.alert:hover { filter: brightness(1.05); }

/* ---------- event card ---------- */
.card { background: var(--paper); border: 0.12rem solid var(--line); border-radius: 0.8rem; box-shadow: var(--shadow); padding: 0.6rem 0.7rem; animation: slidein 0.35s; }
@keyframes slidein { from { transform: translateX(-110%); } to { transform: none; } }
.card h4 { margin: 0 0 0.25rem; font-family: var(--display); font-size: 1.1rem; color: #5a3d0a; display: flex; gap: 0.4rem; align-items: center; }
.card p { margin: 0 0 0.5rem; font-size: 0.82rem; color: var(--ink2); font-weight: 600; }
.card .choices { display: flex; flex-direction: column; gap: 0.3rem; }
.card .timer { height: 0.2rem; background: var(--paper3); border-radius: 0.2rem; margin-top: 0.45rem; overflow: hidden; }
.card .timer i { display: block; height: 100%; background: var(--ink3); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.38rem 0.8rem; border-radius: 0.55rem; border: 0.1rem solid var(--line); background: #fffaf0; font-weight: 800; font-size: 0.85rem; color: var(--ink); text-align: center; }
.btn:hover { background: #fff; border-color: var(--ink3); }
.btn:active { transform: translateY(0.06rem); }
.btn.primary { background: var(--accent); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: #37a093; }
.btn.gold { background: var(--gold); border-color: #b47d0c; color: #fff; }
.btn.gold:hover { background: #e6aa2a; }
.btn.danger { background: #fff0ec; border-color: #e0988b; color: var(--red); }
.btn.danger:hover { background: #ffe1da; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.4); }
.btn.big { font-size: 1.15rem; padding: 0.7rem 1.8rem; border-radius: 0.8rem; }
.btn small { font-weight: 700; opacity: 0.85; }
.btn.sm { padding: 0.2rem 0.5rem; font-size: 0.78rem; }

/* ---------- build bar ---------- */
.buildwrap { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; pointer-events: none !important; }
.buildwrap > * { pointer-events: auto; }
.hint { background: rgba(40, 30, 18, 0.78); color: #fff; padding: 0.25rem 0.8rem; border-radius: 0.9rem; font-size: 0.8rem; font-weight: 700; margin-bottom: 0.35rem; text-align: center; max-width: 90%; }
.hint b { color: #ffd95a; }
.tabs { display: flex; gap: 0.2rem; align-items: flex-end; padding: 0 0.5rem; align-self: flex-start; margin-left: 0.4rem; }
.tab { padding: 0.28rem 0.8rem 0.22rem; border-radius: 0.6rem 0.6rem 0 0; background: var(--paper3); border: 0.12rem solid var(--line); border-bottom: none; font-weight: 800; font-size: 0.82rem; color: var(--ink2); position: relative; display: flex; align-items: center; gap: 0.3rem; }
.tab:hover { background: var(--paper2); }
.tab.on { background: var(--paper); color: var(--ink); padding-top: 0.42rem; }
.tab .nw { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--red); display: inline-block; }
.buildbar { align-self: stretch; display: flex; align-items: stretch; gap: 0.4rem; padding: 0.4rem 0.5rem; background: linear-gradient(var(--paper), #f1e4c6); border-top: 0.14rem solid var(--line); box-shadow: 0 -0.15rem 0.6rem rgba(40, 28, 12, 0.25); min-height: 5.4rem; }
.blist { flex: 1; display: flex; gap: 0.3rem; overflow-x: auto; overflow-y: hidden; padding-bottom: 0.1rem; scrollbar-width: thin; }
.bbtn { position: relative; flex: none; width: 4.7rem; height: 4.7rem; border-radius: 0.6rem; border: 0.12rem solid var(--line); background: #fffaf0 center 28% / 86% no-repeat; padding: 0; overflow: hidden; }
.bbtn:hover { border-color: var(--accent); background-color: #fff; transform: translateY(-0.1rem); }
.bbtn.on { border-color: var(--accent); box-shadow: 0 0 0 0.16rem var(--accent) inset; background-color: #e6f6f2; }
.bbtn .nm { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(61, 47, 31, 0.84); color: #fff; font-size: 0.66rem; font-weight: 800; padding: 0.1rem 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.bbtn .cost { position: absolute; left: 0.15rem; top: 0.1rem; font-size: 0.68rem; font-weight: 900; color: #7a5200; background: #fff6d8e0; border-radius: 0.4rem; padding: 0 0.25rem; }
.bbtn.poor .cost { color: var(--red); }
.bbtn.poor { filter: saturate(0.55); }
.bbtn.locked { filter: grayscale(1) opacity(0.6); cursor: not-allowed; }
.bbtn .lk { position: absolute; inset: 0; display: grid; place-items: center; color: #3d2f1fcc; font-size: 1.5rem; }
.bbtn .new { position: absolute; right: 0.1rem; top: 0.1rem; background: var(--red); color: #fff; font-size: 0.55rem; font-weight: 900; padding: 0.02rem 0.25rem; border-radius: 0.4rem; letter-spacing: 0.04em; }
.bbtn.glow { animation: glow 1s infinite; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 190, 40, 0.95); border-color: var(--gold); } 50% { box-shadow: 0 0 0 0.45rem rgba(255, 190, 40, 0); border-color: var(--gold); } }
.tab.glow { animation: glow 1s infinite; }
.toolcol { display: grid; grid-template-columns: repeat(3, 2.25rem); grid-auto-rows: 2.25rem; gap: 0.2rem; align-content: center; padding-left: 0.4rem; border-left: 0.1rem solid var(--line); }
.tool { border-radius: 0.5rem; border: 0.1rem solid var(--line); background: #fffaf0; color: var(--ink2); display: grid; place-items: center; font-size: 1.05rem; padding: 0; }
.tool:hover { background: #fff; color: var(--ink); border-color: var(--ink3); }
.tool.on { background: var(--accent); color: #fff; border-color: var(--accent2); }
.tool.on.danger { background: var(--red); border-color: #9a2f22; }

/* ---------- side panel (selection) ---------- */
.side { position: absolute; right: 0.5rem; top: 5.3rem; width: 17rem; background: var(--paper); border: 0.12rem solid var(--line); border-radius: 0.8rem; box-shadow: var(--shadow); padding: 0.6rem 0.7rem 0.7rem; max-height: calc(100% - 12.5rem); overflow-y: auto; }
.side h3, .win h2 { margin: 0; font-family: var(--display); font-size: 1.25rem; color: #5a3d0a; line-height: 1.1; }
.side .sub { color: var(--ink3); font-size: 0.76rem; font-weight: 700; margin-top: 0.1rem; }
.side .desc { color: var(--ink2); font-size: 0.8rem; font-weight: 600; margin: 0.4rem 0; }
.side .x, .win .x { position: absolute; right: 0.35rem; top: 0.35rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: none; background: var(--paper3); color: var(--ink2); display: grid; place-items: center; font-size: 0.85rem; padding: 0; }
.side .x:hover, .win .x:hover { background: var(--red); color: #fff; }
.kv { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; font-weight: 700; padding: 0.14rem 0; }
.kv .k { color: var(--ink2); flex: 1; display: flex; align-items: center; gap: 0.3rem; }
.kv .v { font-weight: 900; text-align: right; }
.status { display: flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.5rem; border-radius: 0.5rem; font-weight: 800; font-size: 0.8rem; margin: 0.35rem 0; background: #e3f3e3; color: #256a30; }
.status.warn { background: #fff0c9; color: #7a5200; }
.status.bad { background: #ffdcd3; color: #8a2414; }
.needs { display: flex; flex-direction: column; gap: 0.12rem; margin: 0.3rem 0; }
.need { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 700; padding: 0.12rem 0.3rem; border-radius: 0.4rem; }
.need.ok { color: #256a30; }
.need.no { color: #8a2414; background: #ffeee9; }
.need .how { display: block; font-size: 0.7rem; color: var(--ink2); font-weight: 600; }
.need .mk { margin-left: auto; }
.secth { font-size: 0.66rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink3); margin: 0.5rem 0 0.15rem; }
.row { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.5rem; }
.side .row { position: sticky; bottom: -0.7rem; background: linear-gradient(transparent, var(--paper) 22%); padding: 0.55rem 0 0.7rem; margin-bottom: -0.7rem; }
.row .btn { flex: 1; }
.costline { display: flex; flex-wrap: wrap; gap: 0.15rem 0.5rem; font-weight: 800; font-size: 0.8rem; }
.costline span { display: inline-flex; align-items: center; gap: 0.15rem; white-space: nowrap; }
.costline .lack { color: var(--red); }

/* ---------- windows ---------- */
.shade { position: absolute; inset: 0; background: rgba(30, 22, 10, 0.42); display: grid; place-items: center; z-index: 80; animation: fadein 0.2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.win { position: relative; background: var(--paper); border: 0.14rem solid var(--line); border-radius: 1rem; box-shadow: 0 0.6rem 2rem rgba(30, 20, 5, 0.5); padding: 1rem 1.2rem 1.1rem; width: 34rem; max-width: 94%; max-height: 88%; overflow-y: auto; animation: popin 0.22s; }
.win.wide { width: 46rem; }
.win.narrow { width: 25rem; }
@keyframes popin { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.win h2 { font-size: 1.6rem; margin-bottom: 0.15rem; padding-right: 2rem; }
.win .lead { color: var(--ink2); font-weight: 600; margin: 0.2rem 0 0.7rem; font-size: 0.9rem; }
.win table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.win th { text-align: right; font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink3); padding: 0.2rem 0.4rem; position: sticky; top: -1rem; background: var(--paper); }
.win th:first-child { text-align: left; }
.win td { padding: 0.2rem 0.4rem; border-top: 0.06rem solid var(--paper3); text-align: right; font-weight: 800; white-space: nowrap; }
.win td:first-child { text-align: left; }
.win td.dim { color: var(--ink3); font-weight: 700; }
.win tr.grp td { background: var(--paper2); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink2); padding: 0.15rem 0.4rem; }
.wtabs { display: flex; gap: 0.25rem; margin: 0.5rem 0 0.7rem; border-bottom: 0.1rem solid var(--line); }
.wtab { padding: 0.3rem 0.8rem; border: none; background: none; font-weight: 800; color: var(--ink3); border-bottom: 0.2rem solid transparent; margin-bottom: -0.1rem; }
.wtab.on { color: var(--accent2); border-bottom-color: var(--accent); }
.req { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0; font-weight: 800; }
.req .lbl { width: 11.5rem; }
.req .num { width: 5.5rem; text-align: right; font-size: 0.82rem; color: var(--ink2); }
.req.ok .lbl { color: #256a30; }
.unl { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.unl .u { display: flex; align-items: center; gap: 0.3rem; background: var(--paper2); border: 0.08rem solid var(--line); border-radius: 0.5rem; padding: 0.15rem 0.5rem 0.15rem 0.15rem; font-weight: 800; font-size: 0.78rem; }
.unl .u img { width: 2rem; height: 2rem; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.4rem; }
.ach .a { display: flex; gap: 0.5rem; align-items: center; padding: 0.4rem 0.5rem; border-radius: 0.6rem; background: var(--paper2); border: 0.08rem solid var(--line); opacity: 0.55; }
.ach .a.got { opacity: 1; background: #fff6d8; border-color: #e2c273; }
.ach .a .ico { width: 2rem; height: 2rem; border-radius: 50%; background: var(--paper3); color: var(--ink3); display: grid; place-items: center; font-size: 1rem; flex: none; }
.ach .a.got .ico { background: var(--gold); color: #fff; }
.ach .a b { display: block; font-size: 0.84rem; }
.ach .a span { font-size: 0.72rem; color: var(--ink2); font-weight: 600; }
.setrow { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0; font-weight: 800; }
.setrow label { width: 9rem; display: flex; align-items: center; gap: 0.35rem; }
.setrow input[type=range] { flex: 1; accent-color: var(--accent); }
.seg { display: flex; background: var(--paper3); border-radius: 0.5rem; padding: 0.12rem; gap: 0.1rem; }
.seg button { border: none; background: none; padding: 0.25rem 0.7rem; border-radius: 0.4rem; font-weight: 800; color: var(--ink2); font-size: 0.82rem; }
.seg button.on { background: var(--accent); color: #fff; }
.help h4 { margin: 0.7rem 0 0.2rem; font-size: 0.95rem; color: #5a3d0a; }
.help p, .help li { font-size: 0.84rem; color: var(--ink2); font-weight: 600; margin: 0.15rem 0; }
.help ul { margin: 0.2rem 0; padding-left: 1.2rem; }
.help kbd { background: #fff; border: 0.08rem solid var(--line); border-bottom-width: 0.16rem; border-radius: 0.3rem; padding: 0 0.3rem; font: 800 0.78rem var(--font); color: var(--ink); }
.contract { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem; border: 0.08rem solid var(--line); border-radius: 0.6rem; background: var(--paper2); margin-bottom: 0.35rem; font-weight: 700; }
.contract .who { font-size: 0.72rem; color: var(--ink3); }
.contract .what { flex: 1; }
.trade-btns { display: inline-flex; gap: 0.15rem; }
canvas.spark { width: 100%; height: 9rem; background: #fffaf0; border: 0.08rem solid var(--line); border-radius: 0.6rem; }
.legend { display: flex; gap: 1rem; font-size: 0.78rem; font-weight: 800; margin: 0.3rem 0 0.6rem; }
.legend i { display: inline-block; width: 0.8rem; height: 0.25rem; border-radius: 0.2rem; vertical-align: middle; margin-right: 0.3rem; }

/* ---------- tooltip, toasts, floating text ---------- */
.tip { position: absolute; z-index: 95; max-width: 19rem; background: #2f2518f2; color: #fbf4e2; border-radius: 0.6rem; padding: 0.5rem 0.65rem; font-size: 0.8rem; font-weight: 600; box-shadow: var(--shadow); pointer-events: none !important; line-height: 1.32; }
.tip b { color: #ffd95a; }
.tip h5 { margin: 0 0 0.15rem; font-family: var(--display); font-size: 1.05rem; color: #ffe9a8; font-weight: 700; }
.tip .tl { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.12rem; }
.tip .costline { margin: 0.25rem 0; }
.tip .lack { color: #ff9b8a; }
.tip .dimt { color: #cbbd9f; }
.tip hr { border: none; border-top: 0.06rem solid #fff3; margin: 0.3rem 0; }
.cursorinfo { position: absolute; z-index: 20; background: #2f2518e6; color: #fff; border-radius: 0.5rem; padding: 0.2rem 0.55rem; font-size: 0.78rem; font-weight: 800; pointer-events: none !important; white-space: nowrap; transform: translate(1rem, 1.2rem); }
.cursorinfo { box-shadow: 0 0.1rem 0.3rem rgba(0,0,0,0.3); }
.cursorinfo.bad { background: #a8372ae6; }
.cursorinfo.good { background: #2c7a3ae6; }
.toasts { position: absolute; left: 50%; top: 5.4rem; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.3rem; pointer-events: none !important; z-index: 25; width: 60%; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 0.45rem; background: #2f2518ee; color: #fbf4e2; padding: 0.4rem 0.9rem; border-radius: 1rem; font-weight: 800; font-size: 0.86rem; box-shadow: var(--shadow); animation: toastin 0.3s; cursor: pointer; max-width: 100%; }
.toast > .ic { flex: none; }
.toast .tw { min-width: 0; }
.toast .tw .ic { vertical-align: -0.18em; }
.toast.good { background: #256f66f2; }
.toast.bad { background: #a8372af2; }
.toast.gold { background: #b47d0cf5; }
.toast.out { opacity: 0; transform: translateY(-0.6rem); transition: all 0.4s; }
@keyframes toastin { from { opacity: 0; transform: translateY(0.8rem) scale(0.95); } to { opacity: 1; transform: none; } }
.float { position: absolute; z-index: 15; font-weight: 900; font-size: 1.05rem; color: #fff; text-shadow: 0 0.08rem 0 #3d2f1f, 0 0 0.3rem #3d2f1f; pointer-events: none !important; white-space: nowrap; display: flex; align-items: center; gap: 0.2rem; will-change: transform, opacity; }
.sectag { position: absolute; z-index: 5; transform: translate(-50%, -50%); background: #fffaf0f0; border: 0.12rem solid var(--gold); color: #6b4a00; border-radius: 1rem; padding: 0.15rem 0.6rem 0.15rem 0.35rem; font-weight: 900; font-size: 0.82rem; display: flex; align-items: center; gap: 0.25rem; cursor: pointer; box-shadow: var(--shadow); white-space: nowrap; }
.sectag:hover { background: #fff; transform: translate(-50%, -50%) scale(1.08); }
.sectag.poor { border-color: var(--line); color: var(--ink3); }

/* ---------- banner (rank up) ---------- */
.banner { position: absolute; left: 0; right: 0; top: 24%; display: flex; flex-direction: column; align-items: center; pointer-events: none !important; z-index: 40; animation: bannerin 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
.banner .rib { background: linear-gradient(#e7b02c, #c98c0e); color: #fff; font-family: var(--display); font-size: 2.6rem; padding: 0.3rem 3.4rem; border-radius: 0.5rem; box-shadow: 0 0.4rem 1.2rem rgba(30, 20, 5, 0.5); text-shadow: 0 0.12rem 0 #8a5a00; border: 0.16rem solid #fff3; }
.banner .sub { margin-top: 0.5rem; background: #2f2518e6; color: #fff; padding: 0.3rem 1.2rem; border-radius: 1rem; font-weight: 800; }
.banner.out { opacity: 0; transition: opacity 0.8s; }
@keyframes bannerin { from { transform: scale(0.3); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- title screen ---------- */
.title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(20, 30, 40, 0.22) 0%, rgba(20, 30, 40, 0.08) 45%, rgba(20, 30, 40, 0.42) 100%); z-index: 50; }
.title .logo { font-family: var(--display); font-size: 5.6rem; color: #fff; text-shadow: 0 0.2rem 0 #7a4a12, 0 0.5rem 1.6rem rgba(0, 0, 0, 0.5); line-height: 1; letter-spacing: 0.02em; }
.title .tag { color: #fff; font-weight: 800; font-size: 1.15rem; margin: 0.4rem 0 1.6rem; text-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.7); }
.title .menu { display: flex; flex-direction: column; gap: 0.5rem; align-items: stretch; min-width: 17rem; }
.title .slot { display: flex; align-items: center; gap: 0.6rem; background: var(--paper); border: 0.12rem solid var(--line); border-radius: 0.8rem; padding: 0.45rem 0.6rem 0.45rem 0.8rem; box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.title .slot:hover { background: #fff; border-color: var(--accent); }
.title .slot .nm { font-family: var(--display); font-size: 1.25rem; color: #5a3d0a; line-height: 1.1; }
.title .slot .meta { font-size: 0.76rem; color: var(--ink2); font-weight: 700; }
.title .slot .go { margin-left: auto; }
.title .slot .del { width: 1.7rem; height: 1.7rem; border-radius: 50%; border: none; background: var(--paper3); color: var(--ink3); display: grid; place-items: center; padding: 0; font-size: 0.8rem; }
.title .slot .del:hover { background: var(--red); color: #fff; }
.title .foot { position: absolute; bottom: 0.8rem; left: 0; right: 0; text-align: center; color: #fffc; font-size: 0.78rem; font-weight: 700; text-shadow: 0 0.06rem 0.3rem #000a; }
.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0.6rem 0; }
.mapc { text-align: left; border: 0.14rem solid var(--line); border-radius: 0.7rem; background: var(--paper2); padding: 0.5rem 0.7rem; }
.mapc:hover { background: #fff; }
.mapc.on { border-color: var(--accent); background: #e6f6f2; box-shadow: 0 0 0 0.1rem var(--accent) inset; }
.mapc b { font-family: var(--display); font-size: 1.1rem; color: #5a3d0a; display: block; }
.mapc span { font-size: 0.76rem; color: var(--ink2); font-weight: 600; display: block; }
.mapc em { font-style: normal; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent2); }
.field { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0; font-weight: 800; }
.field input[type=text] { flex: 1; font: 800 1rem var(--font); color: var(--ink); background: #fff; border: 0.1rem solid var(--line); border-radius: 0.5rem; padding: 0.35rem 0.6rem; -webkit-user-select: text; user-select: text; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: #9fd4f0; color: #fff; font: 700 3rem var(--display); z-index: 100; text-shadow: 0 0.15rem 0 #5a8fae; transition: opacity 0.5s; }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; background: #2f2518; color: #fbf4e2; font: 700 1.1rem var(--font); text-align: center; padding: 2rem; z-index: 200; }

/* compact layouts for small frames */
@media (max-aspect-ratio: 4/3) { .left { width: 15rem; } .side { width: 15rem; } }

.idle { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); background: #2f2518f0; color: #fbf4e2; padding: 0.7rem 1.4rem; border-radius: 1.2rem; font-weight: 800; font-size: 1rem; box-shadow: var(--shadow); pointer-events: none !important; z-index: 45; display: flex; align-items: center; gap: 0.5rem; }

.title .menu > .btn.big.gold { animation: pulse 1.8s infinite; }
.title .menu > .btn.big { box-shadow: var(--shadow); }

.edict { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border: 0.08rem solid var(--line); border-radius: 0.6rem; background: var(--paper2); margin-bottom: 0.3rem; }
.edict.on { background: #e6f6f2; border-color: var(--accent); }
.edict .what { flex: 1; display: flex; flex-direction: column; font-size: 0.78rem; color: var(--ink2); font-weight: 600; }
.edict .what b { font-size: 0.9rem; color: var(--ink); }
.edict i { font-style: normal; font-weight: 800; }
.edict i.pos { color: var(--green); }
.edict i.neg { color: var(--red); }

/* ---------- coach marks ---------- */
.coach { position: absolute; z-index: 30; transform: translate(-50%, -100%); margin-top: -0.75rem; background: var(--gold); color: #fff; font-weight: 900; font-size: 0.88rem; padding: 0.3rem 0.8rem; border-radius: 0.8rem; box-shadow: var(--shadow); pointer-events: none !important; white-space: nowrap; animation: coachbob 0.9s ease-in-out infinite; border: 0.1rem solid #fff7; text-shadow: 0 0.06rem 0 #8a5a00; }
.coach::after { content: ''; position: absolute; left: calc(50% + var(--px, 0px)); top: 100%; margin-left: -0.45rem; border: 0.45rem solid transparent; border-top-color: var(--gold); border-bottom-width: 0; }
.coach b { color: #fff6cf; }
.coach.world { z-index: 18; }
.coach.world.off::after { display: none; }
.coach.world.off { pointer-events: auto !important; cursor: pointer; }
.coach .dir { display: inline-block; font-size: 1rem; line-height: 1; }
@keyframes coachbob { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, calc(-100% - 0.4rem)); } }
.sectag.pulse { animation: pulse 0.9s infinite; border-color: #fff; background: var(--gold); color: #fff; }
.linkbtn { background: none; border: none; color: #fff; font-weight: 800; font-size: 0.86rem; text-shadow: 0 0.06rem 0.3rem #000c; text-decoration: underline; text-underline-offset: 0.18em; opacity: 0.92; padding: 0.2rem; align-self: center; }
.linkbtn:hover { opacity: 1; color: #ffe9a8; }
.coach.right { transform: translate(0, -50%); margin: 0 0 0 0.8rem; animation: coachnudge 0.9s ease-in-out infinite; }
.coach.right::after { left: -0.45rem; top: 50%; margin: -0.45rem 0 0 0; border: 0.45rem solid transparent; border-right-color: var(--gold); border-left-width: 0; }
@keyframes coachnudge { 0%, 100% { transform: translate(0, -50%); } 50% { transform: translate(0.4rem, -50%); } }
.gift { display: flex; align-items: center; gap: 0.7rem; background: #fff6d8; border: 0.1rem solid #e2c273; border-radius: 0.8rem; padding: 0.4rem 0.8rem 0.4rem 0.4rem; margin: 0.4rem 0; }
.gift img { width: 5.2rem; height: 5.2rem; flex: none; }
.gift b { display: block; font-family: var(--display); font-size: 1.2rem; color: #5a3d0a; }
.gift span { display: block; font-size: 0.82rem; color: var(--ink2); font-weight: 600; }
.gift .boon { color: #8a5a00; font-weight: 800; margin-top: 0.15rem; }
.win .lead.tomorrow { background: var(--paper2); border-radius: 0.6rem; padding: 0.35rem 0.6rem; margin-top: 0.5rem; font-weight: 700; }
.bbtn.locked.soon { filter: grayscale(0.55) opacity(0.85); }
.bbtn.locked.soon .cost { color: #8a5a00; }
.bbtn.built { filter: saturate(0.5) opacity(0.75); }
.bbtn.built::after { content: '✓'; position: absolute; right: 0.2rem; top: 0.05rem; color: var(--green); font-weight: 900; font-size: 0.95rem; }
.title .slot .news { color: var(--accent2); }
.title .slot .news .due { color: #a36a00; font-weight: 900; }
.stepper { display: inline-flex; align-items: center; gap: 0.15rem; background: var(--paper2); border: 0.06rem solid var(--line); border-radius: 0.5rem; padding: 0.08rem; }
.stepper i { font-style: normal; min-width: 2.3rem; text-align: center; font-weight: 800; color: var(--ink3); font-size: 0.78rem; }
.stepper.on { background: #e6f6f2; border-color: var(--accent); }
.stepper.on i { color: var(--accent2); }
.stp { width: 1.3rem; height: 1.3rem; border-radius: 0.35rem; border: 0.06rem solid var(--line); background: #fffaf0; font-weight: 900; line-height: 1; padding: 0; color: var(--ink2); }
.stp:hover { background: #fff; border-color: var(--ink3); }
.stp[disabled] { opacity: 0.35; cursor: default; }
.win table.trade td { padding: 0.16rem 0.3rem; white-space: nowrap; }
.win .pos { color: var(--green); } .win .neg { color: var(--red); }
.recipes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem; margin-bottom: 0.4rem; }
.recipe { display: flex; align-items: center; gap: 0.5rem; background: var(--paper2); border: 0.08rem solid var(--line); border-radius: 0.6rem; padding: 0.2rem 0.6rem 0.2rem 0.25rem; cursor: pointer; }
.recipe:hover { background: #fff; border-color: var(--accent); }
.recipe.locked { opacity: 0.6; cursor: default; }
.recipe.locked:hover { background: var(--paper2); border-color: var(--line); }
.recipe img { width: 2.6rem; height: 2.6rem; flex: none; }
.recipe .rn { flex: 1; min-width: 0; }
.recipe .rn b { display: block; font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe .rn span { font-size: 0.7rem; color: var(--ink3); font-weight: 700; }
.recipe .rio { font-size: 0.82rem; font-weight: 700; text-align: right; white-space: nowrap; }
.recipe .rio i { font-style: normal; color: var(--ink2); font-size: 0.74rem; white-space: normal; }
.recipe .rio em { font-style: normal; color: var(--ink3); }
.needgo { margin-left: auto; flex: none; width: 1.6rem; height: 1.6rem; border-radius: 0.45rem; border: 0.08rem solid #e0988b; background: #fff; color: var(--accent2); display: grid; place-items: center; padding: 0; }
.needgo:hover { background: var(--accent); color: #fff; border-color: var(--accent2); }
.needgo.ghost { visibility: hidden; }
.req .needgo { margin-left: 0.2rem; border-color: var(--line); }
#ui img:not([src]) { visibility: hidden; }
.title .slot .go.gold { animation: pulse 1.8s infinite; padding: 0.5rem 1.1rem; font-size: 1rem; }
.cursorinfo.plan { background: #2a5f8fe6; }
.cursorinfo.warn { background: #8a5a00e6; }
.shiprow { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0.6rem; border: 0.08rem solid var(--line); border-radius: 0.6rem; background: var(--paper2); margin-bottom: 0.3rem; font-weight: 700; }
.shiprow.home { background: #fff6d8; border-color: #e2c273; }
.shiprow .sn { font-family: var(--display); font-size: 1.05rem; color: #5a3d0a; white-space: nowrap; }
.shiprow .ss { flex: 1; font-size: 0.84rem; color: var(--ink2); }
.shiprow .bar { max-width: 9rem; }
.voyages { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.voyage { display: flex; flex-direction: column; gap: 0.15rem; border: 0.08rem solid var(--line); border-radius: 0.7rem; background: var(--paper2); padding: 0.45rem 0.65rem 0.5rem; }
.voyage.locked { opacity: 0.6; }
.voyage b { font-family: var(--display); font-size: 1.1rem; color: #5a3d0a; }
.voyage em { font-style: normal; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent2); }
.voyage span { font-size: 0.78rem; color: var(--ink2); font-weight: 600; }
.voyage .vc { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; font-size: 0.8rem; font-weight: 800; margin: 0.2rem 0; }
.voyage .vnote { flex: 0 0 100%; font-size: 0.72rem; font-weight: 700; color: var(--ink2); line-height: 1.2; }
.voyage .btn { align-self: flex-start; margin-top: auto; }
.shipstat { cursor: pointer; font-size: 0.82rem; }
.shipstat.ready { background: #fff6d8; border-color: #e2c273; animation: pulse 1.4s infinite; }
.say { position: absolute; z-index: 16; max-width: 15rem; background: #fffaf0; color: var(--ink); border: 0.1rem solid var(--line); border-radius: 0.8rem; padding: 0.3rem 0.65rem; font-weight: 700; font-size: 0.82rem; line-height: 1.25; box-shadow: var(--shadow); pointer-events: none !important; text-align: center; margin-top: -0.5rem; will-change: transform, opacity; }
.say.aside { font-size: 0.76rem; font-weight: 600; background: #fffaf0e6; max-width: 13rem; }
.say::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -0.4rem; border: 0.4rem solid transparent; border-top-color: #fffaf0; border-bottom-width: 0; }
