/* Layout: full-screen 3D diorama with paper-and-ink UI panels floating over it. Single committed look. */
:root {
  --ink: #121314;
  --ink-2: #3A3D42;
  --muted: #55585E;
  --paper: #FAFAF7;
  --white: #FFFFFF;
  --marker: #D4F36B;
  --danger: #B42318;
  --rule: rgba(18,19,20,.16);
  --sans: "Geist", "Helvetica Neue", Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
html, body { height: 100%; margin: 0 !important; }
body { margin: 0; background: #DCE6E1; color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.4; overflow: hidden; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
.ui { position: fixed; z-index: 5; pointer-events: none; }
.ui > * { pointer-events: auto; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Top bar */
.topbar { top: calc(12px + env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; background: var(--white); border: 1px solid var(--ink); border-radius: 4px; padding: 6px 12px 6px 6px; box-shadow: 3px 3px 0 var(--ink); }
.badge { font-family: var(--mono); font-size: 12px; font-weight: 500; background: var(--ink); color: var(--marker); padding: 5px 7px; border-radius: 3px; }
.brand b { font-weight: 500; font-size: 16px; letter-spacing: -.02em; }
.brand span.day { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.res { display: flex; align-items: baseline; gap: 8px; background: var(--white); border: 1px solid var(--ink); border-radius: 4px; padding: 7px 11px; font-variant-numeric: tabular-nums; }
.res small { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.res strong { font-weight: 500; font-size: 16px; }
.res.steps { background: var(--marker); }
.res.steps small { color: var(--ink); }
.spacer { flex: 1 1 auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--ink); background: var(--white); cursor: pointer; font-size: 14px; font-weight: 500; }
.btn.primary { background: var(--ink); color: var(--white); }
.btn.primary:hover { background: #000; }
.btn:hover { box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* Side panel */
.panel { top: calc(76px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: 300px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100% - 100px); overflow: auto; }
.card { background: var(--white); border: 1px solid var(--ink); border-radius: 4px; }
.card-h { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--ink); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.card-h span + span { color: var(--muted); }
.card-b { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.hero-row { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 4px; background: var(--ink); color: var(--marker); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-weight: 500; flex: none; }
.hero-row b { font-weight: 500; font-size: 16px; letter-spacing: -.02em; display: block; }
.hero-row small { font-size: 12px; color: var(--muted); }
.power { display: flex; justify-content: space-between; align-items: baseline; font-variant-numeric: tabular-nums; }
.power span { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; }
.power strong { font-size: 22px; font-weight: 500; letter-spacing: -.03em; }
.team { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; }
.team li { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--rule); font-size: 13px; }
.team li:nth-child(odd) { border-right: 1px solid var(--rule); }
.team li:nth-child(-n+2) { border-top: 0; }
.ucode { width: 28px; height: 28px; flex: none; border: 1.5px solid var(--ink); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; background: var(--paper); }
.team small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.xpbar { height: 6px; background: #F0F0EB; border-radius: 3px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--ink); transition: width .4s ease; }
.lbl.site { background: var(--white); color: var(--ink); border: 1px solid var(--ink); }
.lbl.site.own { background: var(--marker); }
.lbl.neutral { background: #5B6B47; color: var(--white); }
.lvl-opts { display: flex; flex-direction: column; gap: 8px; }
.lvl-opts .opt b { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.build { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ink); border-radius: 4px; }
.build li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--rule); }
.build li:first-child { border-top: 0; }
.build .n { flex: 1; min-width: 0; font-size: 14px; }
.build .n small { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.build .done { font-family: var(--mono); font-size: 11px; background: var(--marker); border: 1px solid var(--ink); border-radius: 3px; padding: 3px 6px; }
.quote { margin: 0; font-size: 18px; line-height: 1.5; color: var(--ink); border-left: 3px solid var(--marker); padding-left: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 8px; border-radius: 3px; border: 1px dashed rgba(18,19,20,.45); color: var(--muted); }
.chip.on { border: 1px solid var(--ink); background: var(--marker); color: var(--ink); }
.info-t { font-size: 17px; font-weight: 500; letter-spacing: -.02em; }
.info-d { font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.info-m { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.actions .btn { flex: 1; }

/* Hint */
.hint { left: max(12px, env(safe-area-inset-left, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.88); border: 1px solid var(--ink); border-radius: 4px; padding: 7px 10px; max-width: calc(100% - 24px); }

/* World labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 3px 6px; border-radius: 3px; will-change: transform; }
.lbl.enemy { background: var(--danger); color: var(--white); }
.lbl.region { background: none; color: rgba(18,19,20,.72); font-family: var(--sans); font-size: 15px; font-weight: 500; letter-spacing: .02em; text-transform: uppercase; text-shadow: 0 1px 0 rgba(255,255,255,.7); transform: translate(-50%, -50%); }
.lbl.know { background: var(--marker); color: var(--ink); border: 1px solid var(--ink); }
.lbl.goal { background: var(--ink); color: var(--white); }
.lbl.hq { background: var(--white); color: var(--ink); border: 1px solid var(--ink); }
.float { position: absolute; transform: translate(-50%, -100%); font-weight: 600; font-size: 15px; color: var(--ink); background: var(--marker); border: 1px solid var(--ink); border-radius: 3px; padding: 2px 6px; animation: rise 1.3s ease-out forwards; pointer-events: none; }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }

/* Modals */
.modal-back { position: fixed; inset: 0; z-index: 20; background: rgba(18,19,20,.35); display: flex; align-items: center; justify-content: center; padding: 16px max(16px, env(safe-area-inset-left, 0px)); }
.modal { width: min(520px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--white); border: 1px solid var(--ink); border-radius: 4px; box-shadow: 6px 6px 0 var(--ink); }
.modal .card-h.hl { background: var(--marker); }
.modal-b { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -.03em; line-height: 1.1; text-wrap: balance; }
.modal p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--ink); border-radius: 4px; background: var(--paper); cursor: pointer; font-size: 14px; line-height: 1.45; }
.opt:hover:not(:disabled) { background: var(--white); box-shadow: 3px 3px 0 var(--ink); }
.opt .l { flex: none; width: 22px; height: 22px; border: 1px solid var(--ink); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; }
.opt.right { background: var(--marker); }
.opt.wrong { background: #FFE3DB; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; }
.vs div { border: 1px solid var(--ink); border-radius: 4px; padding: 12px; }
.vs small { display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--muted); }
.vs strong { font-size: 30px; font-weight: 500; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.vs .foe strong { color: var(--danger); }
.vs em { font-family: var(--mono); font-style: normal; font-size: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.toggle input { width: 18px; height: 18px; accent-color: #121314; }
.recruit { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ink); border-radius: 4px; }
.recruit li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--rule); }
.recruit li:first-child { border-top: 0; }
.recruit .n { flex: 1; min-width: 0; font-size: 14px; }
.recruit .n small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.recruit .c { font-family: var(--mono); font-size: 12px; text-align: right; }
.recruit button { width: 44px; height: 40px; }
.link { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.big { font-size: 56px; font-weight: 500; letter-spacing: -.05em; line-height: 1; }

/* Battle mode */
body:not(.battle) .btop, body:not(.battle) .bpanel, body:not(.battle) #blabels { display: none; }
body.battle .topbar, body.battle .panel, body.battle .hint, body.battle #labels { display: none; }
#blabels { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.stk { position: absolute; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.stk.me { background: var(--ink); color: var(--white); }
.stk.foe { background: var(--danger); color: var(--white); }
.stk.active { outline: 2px solid var(--marker); outline-offset: 1px; }
.stk .hpbar { width: 26px; height: 4px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden; }
.stk .hpbar i { display: block; height: 100%; background: var(--marker); }
.stk.foe .hpbar i { background: #FFD2C8; }
.dmg { position: absolute; transform: translate(-50%, -100%); font-weight: 600; font-size: 16px; color: var(--white); background: var(--danger); border-radius: 3px; padding: 1px 6px; animation: rise 1.2s ease-out forwards; pointer-events: none; white-space: nowrap; }
.dmg.me { background: var(--ink); }
.btop { top: calc(12px + env(safe-area-inset-top, 0px)); left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.order { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; background: rgba(255,255,255,.9); border: 1px solid var(--ink); border-radius: 4px; padding: 5px 6px; }
.order small { font-family: var(--mono); font-size: 10px; text-transform: uppercase; color: var(--muted); margin: 0 4px; }
.ochip { min-width: 30px; height: 26px; padding: 0 5px; box-sizing: border-box; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 11px; border: 1.5px solid var(--ink); background: var(--white); }
.ochip.foe { border-color: var(--danger); color: var(--danger); }
.ochip.now { background: var(--marker); color: var(--ink); }
.bpanel { top: calc(76px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: 300px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100% - 100px); overflow: auto; }
.bstats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; }
.bstats dt { font-family: var(--mono); font-size: 10px; text-transform: uppercase; color: var(--muted); }
.bstats dd { margin: 2px 0 0; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.abil { display: flex; flex-direction: column; gap: 6px; }
.abil .btn { justify-content: space-between; text-align: left; font-weight: 500; }
.abil .btn small { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--muted); }
.abil .btn.armed { background: var(--marker); box-shadow: 2px 2px 0 var(--ink); }
.blog ul { list-style: none; margin: 0; padding: 4px 12px 8px; font-size: 12px; line-height: 1.45; color: var(--ink-2); max-height: 150px; overflow: auto; }
.blog li { padding: 4px 0; border-bottom: 1px solid var(--rule); }
.blog li:last-child { border-bottom: 0; }
.army { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; }
.army li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--rule); padding: 4px 0; }
.army b { font-weight: 500; font-family: var(--mono); font-size: 12px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols2 h3 { margin: 0 0 6px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; font-weight: 500; color: var(--muted); }
.cols2 .army { grid-template-columns: 1fr; }

@media (max-width: 760px) {
  .bpanel { top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); width: auto; max-height: 40%; }
  .bpanel .blog, .bpanel .bstats { display: none; }
  .bpanel { max-height: 32%; gap: 6px; }
  .bpanel .card-b { padding: 8px 10px; gap: 6px; }
  .abil { flex-direction: row; flex-wrap: wrap; }
  .abil .btn { flex: 1 1 30%; min-height: 36px; padding: 0 8px; font-size: 12px; justify-content: center; }
  .abil .btn small { display: none; }
  .order small { display: none; }
  .ochip { min-width: 26px; height: 22px; font-size: 10px; }
  .btop .brand b { display: none; }
}
@media (max-width: 760px) {
  .topbar { gap: 6px; }
  .panel { top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); width: auto; max-height: 34%; }
  .panel .card:not(#info) { display: none; }
  .hint { display: none; }
  .brand { box-shadow: none; padding: 4px 8px 4px 4px; }
  .brand b, .brand .day { display: none; }
  .res { padding: 4px 7px; gap: 5px; }
  .res small { font-size: 9px; }
  .res strong { font-size: 13px; }
  .btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
  #info .card-b { padding: 10px; gap: 6px; }
  .info-t { font-size: 15px; }
  .lbl.region { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .float { animation-duration: .01s; } }

.brand a.badge { text-decoration: none; }
