:root {
  --bg: rgba(19, 22, 26, 0.86);
  --bg-solid: #171a1e;
  --bg2: #20252a;
  --bg3: #2a3036;
  --line: rgba(222, 204, 160, 0.16);
  --line2: rgba(222, 204, 160, 0.32);
  --text: #ebe5d6;
  --dim: #a39d8f;
  --gold: #d6b86e;
  --gold2: #b8964a;
  --good: #92c97c;
  --bad: #e58a72;
  --warn: #e3c26a;
  --blue: #7fb3d9;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2e3c; color: var(--text); font: 13px/1.45 var(--sans); user-select: none; -webkit-user-select: none; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
b { font-weight: 650; }
kbd { display: inline-block; font: 600 10px var(--sans); color: var(--dim); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; margin-left: 6px; line-height: 15px; vertical-align: 1px; background: rgba(255, 255, 255, 0.03); }
.ic { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; margin-right: 5px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.attn { color: var(--warn); }
.good { color: var(--good); } .bad { color: var(--bad); }

/* ---------- buttons */
button { font: inherit; color: var(--text); background: linear-gradient(#323940, #2a3036); border: 1px solid var(--line); border-radius: 7px; padding: 6px 11px; cursor: pointer; transition: background .12s, border-color .12s, transform .06s; }
button:hover:not(:disabled) { background: linear-gradient(#3b434b, #323940); border-color: var(--line2); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.42; cursor: default; }
button.primary { background: linear-gradient(#8a7036, #6c5629); border-color: #b99a52; color: #fff7de; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
button.primary:hover:not(:disabled) { background: linear-gradient(#9b7e3d, #7a612e); }
button.danger:hover:not(:disabled) { border-color: rgba(229, 138, 114, 0.6); color: #ffd0c4; }
button.big { font: 600 16px var(--serif); padding: 10px 22px; }
button.on, button.toggle.on { border-color: var(--gold2); background: linear-gradient(#4a4029, #3a3322); color: #fff1c9; }
.iconbtn { width: 34px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn .count { font: 700 10px var(--sans); margin-left: 2px; color: var(--warn); }
#b-units { width: auto; padding: 0 9px; gap: 4px; }

/* ---------- top bar */
#top { position: fixed; top: 0; left: 0; right: 0; height: 48px; display: flex; align-items: center; gap: 2px; padding: 0 10px; background: linear-gradient(rgba(16, 19, 22, 0.94), rgba(20, 23, 27, 0.88)); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); z-index: 5; white-space: nowrap; overflow-x: auto; scrollbar-width: none; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3); }
body:not(.ingame) #top .stat, body:not(.ingame) #top .iconbtn, body:not(.ingame) #corner, body:not(.ingame) #log { visibility: hidden; }
#top .brand { font: 600 17px var(--serif); color: var(--gold); margin-right: 8px; letter-spacing: .3px; display: flex; align-items: center; gap: 7px; }
.crest-s { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #e9cf8a, #9a7a36); color: #2a210d; font-size: 13px; box-shadow: 0 0 0 2px rgba(214, 184, 110, 0.25); }
#top .stat { display: flex; align-items: center; gap: 5px; padding: 4px 11px; border-left: 1px solid var(--line); height: 30px; }
#top .stat .sub { color: var(--dim); font-size: 12px; }
#top .stat.turn { border-left: none; background: rgba(255, 255, 255, 0.04); border-radius: 16px; padding: 4px 12px 4px 8px; margin-right: 4px; }
#top .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 0 8px currentColor; }
#top .clickable { cursor: pointer; border-radius: 6px; }
#top .clickable:hover { background: rgba(255, 255, 255, 0.06); }
#top .spacer { flex: 1; min-width: 8px; }
#top .iconbtn { margin-left: 4px; }
.mini-bar { display: inline-block; width: 54px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.mini-bar span { display: block; height: 100%; background: linear-gradient(90deg, #5d93bd, #9ccbea); }
.share { position: relative; display: inline-block; width: 74px; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.share span { display: block; height: 100%; background: linear-gradient(90deg, #b99a52, #e8cf86); }
.share i { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #fff3cc; box-shadow: 0 0 4px #fff3cc; }

/* ---------- side panel */
#panel { position: fixed; top: 58px; right: 10px; width: 318px; max-height: calc(100% - 250px); overflow-y: auto; background: var(--bg); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; z-index: 4; box-shadow: var(--shadow); scrollbar-width: thin; animation: slidein .16s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
#panel h2 { margin: 0; font: 600 19px var(--serif); }
#panel .meta { color: var(--dim); font-size: 12px; }
#panel .ph { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
#panel .ph canvas { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4)); }
#panel .row { display: flex; justify-content: space-between; padding: 2px 0; }
#panel .row.small { font-size: 11.5px; color: var(--dim); }
.bar { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; overflow: hidden; margin: 3px 0 8px; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 3px; }
.bar.hp-ok > div { background: linear-gradient(90deg, #6fa85e, #9bd486); } .bar.hp-mid > div { background: linear-gradient(90deg, #b8952e, #e8c55e); } .bar.hp-low > div { background: linear-gradient(90deg, #b2533f, #e8826a); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 2px 9px; font-size: 12px; }
#panel .sec { font: 650 11px var(--sans); color: var(--dim); text-transform: uppercase; letter-spacing: .8px; margin: 14px 0 6px; }
#panel .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#panel .acts button { display: inline-flex; align-items: center; }
#panel .note { color: var(--dim); font-size: 12px; margin-top: 8px; }
.hint { margin-top: 8px; padding: 7px 10px; border-radius: 7px; background: rgba(127, 179, 217, 0.09); border: 1px solid rgba(127, 179, 217, 0.22); color: #cfe2ef; font-size: 12.5px; }
.callout { margin-top: 8px; padding: 8px 10px; border-radius: 7px; background: rgba(227, 194, 106, 0.1); border: 1px solid rgba(227, 194, 106, 0.28); color: #f1dfaa; font-size: 12.5px; }
#panel .close { position: absolute; top: 8px; right: 8px; padding: 0 8px; border: none; background: none; color: var(--dim); font-size: 20px; line-height: 26px; }
#panel .close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.cityhead { margin: -14px -14px 10px; padding: 14px 16px 12px; border-radius: var(--r) var(--r) 0 0; background: linear-gradient(135deg, color-mix(in srgb, var(--side) 45%, #1b1f23), #1b1f23 75%); border-bottom: 1px solid var(--line); }
.bigpop { font: 600 26px var(--serif); margin-top: 4px; } .bigpop small { font: 12px var(--sans); color: var(--dim); }
.yields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.yields > div { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 2px; }
.yields b { font-size: 16px; } .yields small { grid-column: 1 / 3; color: var(--dim); font-size: 11px; }
.prodcard { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.opts { display: flex; flex-direction: column; gap: 4px; }
.opt { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; text-align: left; padding: 6px 8px; }
.opt.on { border-color: var(--gold2); background: linear-gradient(#463c26, #392f1e); }
.opt .oi { display: grid; place-items: center; }
.opt .oi .ic { width: 22px; height: 22px; margin: 0; }
.opt .on2 small { display: block; color: var(--dim); font-size: 11.5px; line-height: 1.3; }
.opt .oc { color: var(--dim); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: rgba(214, 184, 110, 0.12); border: 1px solid rgba(214, 184, 110, 0.3); color: #ecd9a4; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ---------- unit roster */
#roster { position: fixed; top: 58px; left: 10px; width: 300px; max-height: calc(100% - 290px); display: flex; flex-direction: column; background: var(--bg); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); z-index: 4; box-shadow: var(--shadow); animation: slidein .16s ease-out; }
#roster .rh { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; }
#roster .rh h3 { margin: 0; font: 600 16px var(--serif); }
#roster .rtabs { display: flex; gap: 4px; padding: 0 10px 8px; flex-wrap: wrap; }
#roster .rtabs button { padding: 3px 9px; font-size: 12px; border-radius: 12px; }
#roster .rlist { overflow-y: auto; padding: 0 6px 6px; scrollbar-width: thin; }
#roster .rgroup { font: 650 10.5px var(--sans); color: var(--dim); text-transform: uppercase; letter-spacing: .8px; padding: 8px 6px 4px; }
#roster .ru { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
#roster .ru:hover { background: rgba(255, 255, 255, 0.05); }
#roster .ru.on { background: rgba(214, 184, 110, 0.12); border-color: rgba(214, 184, 110, 0.35); }
#roster .ru canvas { width: 34px; height: 34px; }
#roster .ru .rn { font-weight: 600; } #roster .ru .rs { color: var(--dim); font-size: 11.5px; display: block; }
#roster .ru .rhp { display: block; width: 60px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); margin-top: 3px; overflow: hidden; }
#roster .ru .rhp i { display: block; height: 100%; background: #8ccf72; }
#roster .ru .ra { display: flex; gap: 3px; }
#roster .ru .ra button { padding: 2px 7px; font-size: 11.5px; }
#roster .rfoot { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
#roster .rfoot button { font-size: 12px; padding: 4px 9px; }
#roster .empty { color: var(--dim); padding: 10px; font-size: 12.5px; }

/* ---------- log */
#log { position: fixed; left: 10px; bottom: 10px; width: 360px; max-height: 196px; overflow: hidden; display: flex; flex-direction: column-reverse; gap: 3px; z-index: 3; pointer-events: none; }
#log .ev { background: rgba(19, 22, 26, 0.8); backdrop-filter: blur(4px); padding: 4px 10px; border-radius: 6px; border-left: 3px solid #5d5a52; pointer-events: auto; cursor: pointer; font-size: 12.5px; animation: fadein .25s; }
#log .ev:nth-child(n+4) { opacity: 0.7; }
#log .ev.good { border-left-color: var(--good); } #log .ev.bad { border-left-color: var(--bad); } #log .ev.warn { border-left-color: var(--warn); }
#log .ev .t { color: var(--dim); margin-right: 7px; font-size: 11px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

/* ---------- corner: minimap + end turn */
#corner { position: fixed; right: 10px; bottom: 10px; display: flex; flex-direction: column; align-items: stretch; gap: 8px; z-index: 4; width: 262px; }
#mini { width: 262px; height: 142px; border: 1px solid var(--line2); border-radius: 9px; background: #22394a; cursor: pointer; display: block; box-shadow: var(--shadow); }
#turnbox { background: var(--bg); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); padding: 9px; display: flex; flex-direction: column; gap: 7px; box-shadow: var(--shadow); }
#waiting { color: var(--dim); font-size: 12px; text-align: center; cursor: pointer; }
#waiting b { color: var(--warn); }
#b-end { font: 600 17px var(--serif); padding: 11px; background: linear-gradient(#8a7036, #634f25); border-color: #b99a52; color: #fff7de; letter-spacing: .3px; }
#b-end:hover:not(:disabled) { background: linear-gradient(#9b7e3d, #725b2b); }
#b-end.ready { animation: pulse 1.8s ease-in-out infinite; }
#b-end:disabled { background: linear-gradient(#353b41, #2c3136); border-color: var(--line); color: var(--dim); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 184, 110, 0.0); } 50% { box-shadow: 0 0 0 5px rgba(214, 184, 110, 0.22); } }

/* ---------- tooltip, toasts, status */
#tip { position: fixed; z-index: 6; pointer-events: none; background: rgba(23, 26, 30, 0.96); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; max-width: 290px; font-size: 12.5px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
#tip .tt-h { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; } #tip .tt-h span { color: var(--dim); }
#tip .tt-y { display: flex; align-items: center; gap: 2px; margin-bottom: 2px; } #tip .tt-y .ic { width: 13px; height: 13px; margin: 0 2px 0 4px; } #tip .tt-y .ic:first-child { margin-left: 0; }
#tip .d { color: var(--dim); }
#tip .odds { margin-top: 6px; padding: 5px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); font-weight: 600; }
#tip .odds span { display: block; font-weight: 400; color: var(--dim); font-size: 11.5px; }
#tip .odds.good { background: rgba(146, 201, 124, 0.14); color: #c4ebb4; } #tip .odds.bad { background: rgba(229, 138, 114, 0.14); color: #f6c3b5; } #tip .odds.warn { background: rgba(227, 194, 106, 0.12); color: #f1dfaa; }
#toast { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 7; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: rgba(23, 26, 30, 0.95); border: 1px solid var(--line2); border-radius: 20px; padding: 7px 16px; font: 600 14px var(--serif); animation: fade 3.2s forwards; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#netstatus { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 6; background: rgba(23, 26, 30, 0.95); border: 1px solid var(--line2); border-radius: 18px; padding: 6px 16px; font-size: 13px; }
#busy { position: fixed; inset: 0; z-index: 8; display: flex; align-items: flex-start; justify-content: center; padding-top: 72px; pointer-events: all; }
#busy div { display: flex; align-items: center; gap: 9px; background: rgba(23, 26, 30, 0.95); border: 1px solid var(--line2); padding: 9px 18px; border-radius: 20px; font: 600 14px var(--serif); box-shadow: var(--shadow); }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(214, 184, 110, 0.25); border-top-color: var(--gold); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tutorial coach */
#coach { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(520px, calc(100% - 600px)); min-width: 320px; z-index: 7; background: linear-gradient(#262b30, #1d2125); border: 1px solid #b99a52; border-radius: 12px; padding: 12px 16px 12px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(214, 184, 110, 0.12); animation: slideup .25s ease-out; }
@keyframes slideup { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.coach-step { font-size: 11.5px; color: var(--dim); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.coach-step > span:first-child { color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }
.coach-dots { display: inline-flex; gap: 3px; margin-left: auto; } .coach-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); } .coach-dots i.d { background: var(--gold2); } .coach-dots i.c { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.coach-text { font-size: 14.5px; line-height: 1.5; }
.coach-btns { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.coach-btns button:last-child { margin-left: auto; font-size: 12px; padding: 4px 10px; }
.coach-wait { color: var(--gold); font-size: 12.5px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
.tut-glow { position: relative; outline: 2px solid #ffd66e !important; outline-offset: 2px; border-radius: 8px; animation: glow 1.2s ease-in-out infinite; z-index: 6; }
@keyframes glow { 50% { outline-color: rgba(255, 214, 110, 0.3); box-shadow: 0 0 18px rgba(255, 214, 110, 0.45); } }

/* ---------- modals */
#modal { position: fixed; inset: 0; background: radial-gradient(ellipse at center, rgba(8, 10, 12, 0.35), rgba(8, 10, 12, 0.75)); z-index: 9; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein .2s; }
#modal .card { background: linear-gradient(#1f2327, #191c20); border: 1px solid var(--line2); border-radius: 14px; padding: 24px 26px; width: min(720px, 100%); max-height: calc(100% - 32px); overflow-y: auto; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05) inset; scrollbar-width: thin; }
#modal h1 { margin: 0 0 6px; font: 600 30px var(--serif); color: var(--gold); letter-spacing: .3px; }
#modal h3 { font: 600 15px var(--serif); margin: 16px 0 8px; color: #e9dcb9; }
#modal p { margin: 6px 0; color: #d6d0c2; }
#modal .lead { color: var(--dim); margin-bottom: 12px; }
#modal .lead.small, .small { font-size: 12px; }
#modal .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
#modal .pick { text-align: left; padding: 7px 10px; }
#modal .pick.on { border-color: var(--gold2); background: linear-gradient(#463c26, #392f1e); }
#modal .pick small { display: block; color: var(--dim); font-size: 11px; }
#modal .btns { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
#modal .btns.center { justify-content: center; }
#modal .btns.foot { border-top: 1px solid var(--line); padding-top: 14px; }
#modal .btns button { display: inline-flex; align-items: center; }
#modal table { width: 100%; border-collapse: collapse; margin-top: 8px; }
#modal td, #modal th { padding: 6px 7px; border-bottom: 1px solid var(--line); text-align: left; }
#modal th { color: var(--dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; }
.chart { width: 100%; height: auto; margin-top: 6px; background: rgba(255, 255, 255, 0.02); border-radius: 8px; }
.hero { text-align: center; padding: 4px 0 8px; }
.hero h1 { font-size: 40px !important; }
.crest { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; margin-bottom: 6px; background: radial-gradient(circle at 35% 30%, #f0d898, #9a7a36); color: #2a210d; font-size: 26px; box-shadow: 0 0 0 4px rgba(214, 184, 110, 0.18), 0 8px 22px rgba(0, 0, 0, 0.5); }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 14px; }
.mode { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 6px; border-radius: 10px; }
.mode .ic { width: 24px; height: 24px; margin: 0 0 2px; }
.mode b { font: 600 14px var(--serif); } .mode small { color: var(--dim); font-size: 11px; }
.mode.on { border-color: var(--gold2); background: linear-gradient(#463c26, #2f2819); box-shadow: 0 0 0 3px rgba(214, 184, 110, 0.12); }
.modebody { min-height: 150px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.setrow input[type=range] { width: 160px; accent-color: var(--gold); }
.stepper { display: inline-flex; align-items: center; gap: 10px; } .stepper button { width: 30px; padding: 3px 0; } .stepper b { min-width: 14px; text-align: center; font-size: 15px; }
.menu { display: flex; flex-direction: column; gap: 0; } .menubtns { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.advgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 7px; }
.adv { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 9px 11px; min-height: 92px; }
.adv small { color: var(--dim); font-size: 11.5px; line-height: 1.35; }
.adv .advc { margin-top: auto; font-size: 11.5px; color: var(--blue); }
.adv.done { opacity: 0.55; } .adv.done .advc { color: var(--good); }
.adv.on { border-color: var(--gold2); background: linear-gradient(#463c26, #392f1e); }
.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hcard { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.03); }
.hcard > .ic { width: 26px; height: 26px; margin-top: 2px; }
.hcard b { font: 600 14px var(--serif); color: #eedfb6; } .hcard p { margin: 3px 0 0 !important; font-size: 12.5px; }
.keys { line-height: 2; }
.handoff { text-align: center; padding: 10px 0; }
.hand-badge { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font: 700 22px var(--serif); color: #fff; box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.08), 0 10px 24px rgba(0, 0, 0, 0.5); margin-bottom: 10px; }
.endbanner { text-align: center; padding: 8px 0 4px; }
.endbanner.win h1 { font-size: 42px !important; text-shadow: 0 0 24px rgba(214, 184, 110, 0.5); }
.endbanner.lose h1 { font-size: 42px !important; color: #d79a87 !important; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seat { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px dashed var(--line2); border-radius: 9px; color: var(--dim); }
.seat.on { border-style: solid; color: var(--text); background: rgba(255, 255, 255, 0.04); }
.seat-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 700 11px var(--sans); }
.linkrow { display: flex; gap: 6px; } .linkrow input { flex: 1; min-width: 0; background: #121518; border: 1px solid var(--line2); border-radius: 7px; color: var(--text); padding: 6px 9px; font: 12px var(--sans); user-select: text; }

@media (max-width: 900px) {
  #top .brand { display: none; }
  #coach { width: calc(100% - 20px); min-width: 0; bottom: 200px; }
}
@media (max-width: 760px) {
  #top { height: 44px; }
  #top .stat .sub, .mini-bar, .share { display: none; }
  #panel { top: auto; bottom: 186px; left: 8px; right: 8px; width: auto; max-height: 46%; }
  #roster { top: 52px; left: 8px; right: 8px; width: auto; max-height: 45%; }
  #log { width: calc(100% - 190px); max-height: 110px; }
  #corner { width: 164px; }
  #mini { width: 164px; height: 90px; }
  #b-end { font-size: 14px; padding: 8px; }
  .modes { grid-template-columns: 1fr 1fr; }
  .hgrid, .seats { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px !important; }
}

/* ---------- start screen: the main button always stays in view */
#modal .btns.go { position: sticky; bottom: -24px; z-index: 2; margin: 14px -26px -24px; padding: 12px 26px 16px; background: linear-gradient(rgba(25, 28, 32, 0), #191c20 28%); }
.birth { flex-wrap: wrap; }
.birthpick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.birthpick select { background: #121518; color: var(--text); border: 1px solid var(--line2); border-radius: 7px; padding: 6px 8px; font: 13px var(--sans); max-width: 220px; }
@media (max-width: 760px), (max-height: 700px) {
  #modal { padding: 8px; }
  #modal .card { padding: 14px 14px; max-height: calc(100% - 16px); }
  #modal .btns.go { margin: 10px -14px -14px; padding: 10px 14px 12px; bottom: -14px; }
  .hero .lead { display: none; }
  .hero h1 { font-size: 26px !important; margin: 0 !important; }
  .crest { width: 34px; height: 34px; font-size: 17px; margin-bottom: 2px; }
  .modes { grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 8px 0 8px; }
  .mode { padding: 7px 2px; } .mode small { display: none; } .mode b { font-size: 12px; } .mode .ic { width: 20px; height: 20px; }
  .modebody { min-height: 0; } .modebody > p { font-size: 12.5px; margin: 4px 0 !important; }
  .setrow { padding: 5px 0; }
  #modal .btns.foot { margin-top: 8px; padding-top: 8px; }
  #modal .btns.foot button { padding: 4px 9px; font-size: 12px; }
  button.big { font-size: 15px; padding: 9px 18px; }
}
.birthnote { margin: 10px 0 4px; padding: 9px 12px; border-radius: 9px; background: rgba(214, 184, 110, 0.08); border: 1px solid rgba(214, 184, 110, 0.25); color: #eadbb2; font-size: 13px; }

/* ================= navy & gold restyle ================= */
:root {
  --bg: rgba(15, 24, 37, 0.93);
  --bg2: #16233a;
  --bg3: #1d2c44;
  --line: rgba(201, 170, 104, 0.28);
  --line2: rgba(201, 170, 104, 0.55);
  --text: #ece6d6;
  --dim: #9ba6b6;
  --gold: #d8b968;
  --gold2: #a88a45;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 236, 190, 0.04);
}
html, body { background: #0f1c2b; }
.caps, #modal h1, #modal h3, #panel h2, .sec, #roster h3, .coach-step > span:first-child { font-variant: small-caps; letter-spacing: .06em; }
button { background: linear-gradient(#22324b, #1a283d); border-color: rgba(201, 170, 104, 0.3); }
button:hover:not(:disabled) { background: linear-gradient(#2a3c58, #203048); border-color: var(--line2); }
button.primary, #b-end { background: linear-gradient(#b48e43, #7c5f26); border-color: #e1c27a; color: #fff8e2; }
button.primary:hover:not(:disabled), #b-end:hover:not(:disabled) { background: linear-gradient(#c49d4e, #8a6a2c); }
button.on, button.toggle.on, .mode.on, #modal .pick.on, .opt.on, .adv.on { background: linear-gradient(#3a3520, #2a2717); border-color: var(--gold); }
#top { background: linear-gradient(rgba(12, 20, 32, 0.97), rgba(15, 25, 40, 0.92)); border-bottom: 1px solid var(--line2); box-shadow: 0 1px 0 rgba(255, 230, 170, 0.06), 0 6px 22px rgba(0, 0, 0, 0.45); }
#top .brand { font-variant: small-caps; letter-spacing: .12em; background: linear-gradient(#f6e3a8, #c39a45 60%, #8f6c2a); -webkit-background-clip: text; background-clip: text; color: transparent; }
#top .stat { border-left-color: rgba(201, 170, 104, 0.18); }
#panel, #roster, #turnbox, #coach, #log .ev, #tip, #toast div, #busy div, #netstatus { background: var(--bg); border-color: var(--line); }
#panel, #roster, #turnbox { border-top: 2px solid var(--gold2); }
#modal .card { background: linear-gradient(#152338, #0f1a2a); border-color: var(--line2); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 236, 190, 0.05); }
#modal h1, .hero h1 { background: linear-gradient(#fbeab4, #d4ad5a 55%, #9a7433); -webkit-background-clip: text; background-clip: text; color: transparent !important; text-shadow: none; }
.hero h1 { font-size: 46px !important; letter-spacing: .14em; font-variant: small-caps; }
.hero .lead { font-style: italic; font-family: var(--serif); font-size: 15px; color: #c9c2b0 !important; }
.hero::after { content: '◆'; display: block; color: var(--gold2); font-size: 10px; margin-top: 2px; letter-spacing: 1em; }
.crest { background: radial-gradient(circle at 35% 30%, #f3dc9a, #a17c36); box-shadow: 0 0 0 3px #1a2a44, 0 0 0 5px var(--gold2), 0 8px 22px rgba(0, 0, 0, 0.6); }
.endbanner.win h1 { font-size: 52px !important; letter-spacing: .12em; }

/* city card */
.cityhead { background: linear-gradient(135deg, color-mix(in srgb, var(--side) 30%, #14213a), #111c2e 80%); border-bottom: 1px solid var(--line2); }
.cityhead h2 { font-size: 22px !important; letter-spacing: .08em; }
.cityhead .pill { position: absolute; right: 40px; top: 16px; font: 700 10.5px var(--sans); letter-spacing: .08em; text-transform: uppercase; padding: 3px 9px; border-radius: 12px; background: #2b5a92; color: #e6f0fb; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.bigstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 10px 0 4px; }
.bigstats div { display: flex; flex-direction: column; }
.bigstats b { font: 600 21px var(--serif); color: #f3ead2; }
.bigstats small { font: 600 10px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.citizens { display: flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 2px; }
.citizens i { width: 9px; height: 15px; display: inline-block; background: radial-gradient(circle at 50% 22%, #9aa3ad 0 2.6px, transparent 3px), linear-gradient(#9aa3ad, #9aa3ad) 50% 100% / 7px 8px no-repeat; border-radius: 2px; opacity: .45; }
.citizens i.on { background: radial-gradient(circle at 50% 22%, #ffe08a 0 2.6px, transparent 3px), linear-gradient(#f0c95e, #f0c95e) 50% 100% / 7px 8px no-repeat; opacity: 1; filter: drop-shadow(0 0 3px rgba(255, 210, 110, 0.7)); }
.district { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); margin-bottom: 4px; }
.district .dico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: radial-gradient(circle at 35% 30%, #d6a15e, #7a4c1f); box-shadow: inset 0 0 0 1.5px rgba(255, 235, 190, 0.5); }
.district.off { opacity: .45; }
.district small { display: block; color: var(--dim); font-size: 11px; }

/* lenses */
#lenses { position: fixed; left: 10px; top: 58px; z-index: 3; display: flex; flex-direction: column; gap: 4px; }
#lenses button { font-size: 12px; padding: 4px 10px; text-align: left; }
#legend { position: fixed; right: 10px; top: 58px; z-index: 3; width: 230px; background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow); }
#legend h4 { margin: 0 0 6px; font: 600 16px var(--serif); font-variant: small-caps; letter-spacing: .08em; color: var(--gold); }
#legend .ramp { height: 10px; border-radius: 5px; margin: 4px 0; }
#legend .lr { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; }
#legend .src { color: var(--dim); font-size: 10.5px; margin-top: 4px; }
body.has-panel #legend { display: none; }
#roster:not(.hidden) ~ #lenses { display: none; }
#roster, #panel { background: rgba(14, 23, 36, 0.975); }
/* generated art */
.hero { margin: -24px -26px 6px; padding: 26px 26px 16px; border-radius: 14px 14px 0 0; background: linear-gradient(rgba(13, 22, 36, 0.25), rgba(15, 26, 42, 0.78) 55%, #152338 98%), url(assets/title.jpg) center 40% / cover; }
.portrait-img { width: 64px; height: 64px; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--c), 0 0 0 4px rgba(10, 16, 26, 0.9), 0 6px 14px rgba(0, 0, 0, 0.5); }
.portrait-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.handoff, .endbanner { margin: -24px -26px 8px; padding: 24px 26px 14px; border-radius: 14px 14px 0 0; background: linear-gradient(rgba(13, 22, 36, 0.35), #152338 96%), url(assets/title.jpg) center 45% / cover; }
@media (max-width: 760px), (max-height: 700px) { .hero { margin: -14px -14px 6px; padding: 16px 14px 10px; } }
/* eras, advantages, birth stage */
#top .stat .era { font: italic 12px var(--serif); color: var(--gold); margin-left: 4px; }
.traits { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 2px; }
.trait { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 4px; border-radius: 14px; background: rgba(214, 184, 110, 0.1); border: 1px solid rgba(214, 184, 110, 0.35); font-size: 12px; font-weight: 600; color: #f0deaa; }
.trait i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #d9b46a, #7b5a24); color: #1d1608; font-size: 11px; }
.trait small { display: none; }
.traits.big { flex-direction: column; }
.traits.big .trait { border-radius: 10px; padding: 7px 10px 7px 6px; }
.traits.big .trait i { width: 28px; height: 28px; font-size: 15px; }
.traits.big .trait small { display: inline; font-weight: 400; color: var(--dim); margin-left: 6px; }
.birth { text-align: center; }
.birth-kicker { font: 600 11px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold2); margin-bottom: 4px; }
.birth h1 { font-size: 38px !important; letter-spacing: .1em; font-variant: small-caps; }
.roll { font: 600 40px var(--serif); font-variant: small-caps; letter-spacing: .08em; color: #f3e6c0; margin: 18px 0 6px; min-height: 52px; transition: transform .1s; }
.roll.flick { transform: translateY(-2px); opacity: .75; }
.roll.landed { color: #ffe59a; text-shadow: 0 0 24px rgba(255, 210, 120, 0.6); animation: land .5s ease-out; }
@keyframes land { from { transform: scale(1.25); } to { transform: none; } }
.roll-sub { color: var(--dim); font-style: italic; font-family: var(--serif); min-height: 20px; }
.sec2 { font: 650 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin: 14px 0 6px; text-align: left; }
.birth .traits { text-align: left; }
.gifts { text-align: left; margin: 0; padding-left: 20px; } .gifts li { margin: 3px 0; color: #e2d8bd; }
.rivals { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; }
.rv { font-size: 13px; }
/* cleaner online */
.online-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 10px; }
.ocard { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border-radius: 12px; text-align: left; background: linear-gradient(#23344f, #1a283d); }
.ocard .ic { width: 26px; height: 26px; margin-bottom: 4px; }
.ocard b { font: 600 16px var(--serif); color: #f1e3b8; } .ocard small { color: var(--dim); }
.ocard:hover:not(:disabled) { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 184, 110, 0.12); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 5px 14px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: linear-gradient(#b48e43, #7c5f26); color: #fff8e2; }
.lobby { text-align: center; } .lobby .seats { margin: 14px 0; text-align: left; } .lobby .seat small { color: var(--dim); margin-left: 4px; }
.lobby .linkrow input { font-size: 13px; padding: 9px 10px; }
.lobby-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.modes { grid-template-columns: repeat(3, 1fr) !important; }
