/* EVERWORLD 3D — same palette as ../index.html, mobile first */

:root {
  --bg: #101821; --panel: #15212d; --card: #15212d; --ink: #edf2f3; --mut: #9cafb9; --line: #2b3b49;
  --gold: #d9b978; --war: #e2563f; --ally: #e9c766;
}
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(#0e1720, #121c25); color: var(--ink); font-family: system-ui, sans-serif; min-height: 100vh; }
a { color: inherit; }
.hidden { display: none !important; }
.mono { font: 11px ui-monospace, monospace; color: var(--mut); }
.w { max-width: 1320px; margin: auto; padding: 16px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.top a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.top .to2d { padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.hero { padding: 16px 0 10px; }
h1 { font: 500 34px Georgia, serif; letter-spacing: .03em; margin: 4px 0; color: #f4e4bd; }
.badge3d { font: 600 .4em system-ui, sans-serif; vertical-align: super; padding: .12em .45em; border: 1px solid var(--gold); border-radius: 4px; color: var(--gold); letter-spacing: .1em; }
.sub { color: var(--mut); line-height: 1.6; margin: 0; font-size: 14px; max-width: 780px; }

.layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.layout > * { min-width: 0; }

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 78vh; min-height: 380px;
  overflow: hidden; border: 1px solid #385061; border-radius: 10px; background: #15394c;
  user-select: none; -webkit-user-select: none; box-shadow: inset 0 0 0 2px rgba(225,197,136,.08);
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
.stage.pixel #view { image-rendering: pixelated; image-rendering: crisp-edges; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.ntag { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 4px; padding: 2px 6px 2px 4px; border-radius: 4px;
  background: rgba(9,15,20,.74); border: 1px solid color-mix(in srgb, var(--c, #888) 70%, transparent); font: 600 10px ui-monospace, monospace;
  color: #f0eadb; white-space: nowrap; will-change: transform; transition: opacity .25s; }
.ntag .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--c, #888); }
.ntag .nm { display: none; font-weight: 400; color: var(--mut); }
.ntag.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.ntag.on .nm { display: inline; color: #f0eadb; }
.ntag.far { font-size: 9px; padding: 1px 4px; }
.rtag { --c: #7d776d; color: #c9c2b4; background: rgba(20,20,22,.7); }
.rtag .dot { display: none; }

.bubble { position: absolute; left: 0; top: 0; max-width: min(260px, 72%); padding: 7px 10px 8px; border-radius: 8px; background: rgba(250,244,228,.95); color: #1d1a14;
  font-size: 12px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0,0,0,.35); will-change: transform, opacity; display: grid; gap: 2px; border-left: 4px solid #d9b978; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: rgba(250,244,228,.95); }
.bubble.free::after { display: none; }
.bubble .bh { font: 700 9px ui-monospace, monospace; letter-spacing: .05em; color: #6a5a3a; }
.bubble.t-war, .bubble.t-battle { border-left-color: var(--war); }
.bubble.t-war .bh, .bubble.t-battle .bh { color: #a83a2a; }
.bubble.t-alliance { border-left-color: var(--ally); }
.bubble.t-settlement { border-left-color: #6fb35a; }
.bubble.t-collapse { border-left-color: #8a6fb0; }
.bubble.t-rebirth { border-left-color: #4fb8c2; }

.hud { position: absolute; left: 8px; right: 8px; top: 8px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.hbox { display: grid; gap: 1px; padding: 6px 9px; border-radius: 8px; background: rgba(12,20,28,.74); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(4px); }
.hbox b { font: 600 15px Georgia, serif; color: #f7f0dc; }
.hbox.live { display: flex; align-items: center; gap: 6px; align-self: start; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #7fd07a; box-shadow: 0 0 0 0 rgba(127,208,122,.6); animation: pulse 2s infinite; }
#hLive.stale { color: #e2a07a; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(127,208,122,0); } 100% { box-shadow: 0 0 0 0 rgba(127,208,122,0); } }

.caption { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 9px 12px; border-radius: 8px; background: rgba(12,20,28,.8); font-size: 13px; pointer-events: none; }
.caption:empty { display: none; }
.camhint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 6px 10px; border-radius: 999px; background: rgba(0,0,0,.55); font: 11px ui-monospace, monospace; color: var(--mut); white-space: nowrap; pointer-events: none; transition: opacity .5s; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
.camhint.gone { opacity: 0; }
.toast { position: absolute; left: 50%; top: 62px; transform: translate(-50%, -8px); padding: 7px 12px; border-radius: 8px; background: rgba(217,185,120,.94); color: #101821; font: 700 12px ui-monospace, monospace; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: nowrap; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.nowebgl { position: absolute; inset: 0; display: grid; place-content: center; gap: 8px; text-align: center; padding: 20px; background: #101821; }
.nowebgl a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--gold); }

/* nation / ruin panel: bottom sheet on phones, right card on wide screens */
.panel { position: absolute; left: 6px; right: 6px; bottom: 6px; max-height: 52%; overflow: auto; padding: 12px 12px 10px; border-radius: 10px;
  background: rgba(16,24,33,.94); border: 1px solid var(--line); border-top: 3px solid var(--c, var(--gold)); backdrop-filter: blur(6px); animation: sheetIn .3s ease-out; }
@keyframes sheetIn { from { transform: translateY(16px); opacity: 0; } }
.pclose { position: absolute; right: 4px; top: 2px; width: 44px; height: 44px; border: 0; background: none; color: var(--mut); font-size: 22px; cursor: pointer; }
.ph { display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; align-items: center; padding-right: 40px; }
.ph .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.ph strong { font: 600 17px Georgia, serif; color: #f4e4bd; }
.ph .mono { grid-column: 2; }
.pgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.pcell { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #111b24; min-width: 0; }
.pcell b { display: block; font-size: 13px; margin-top: 2px; }
.pcell .mono { font-size: 9px; }
.pcell.wide { grid-column: span 3; display: grid; gap: 4px; }
.sbar { display: block; height: 5px; border-radius: 3px; background: #26323d; overflow: hidden; }
.sbar > i { display: block; height: 100%; background: linear-gradient(90deg, #c4573f, #d9b978 45%, #7fbf6a); }
.warn { font-size: 11px; color: #e2a07a; } .warn.hot { color: #ff8a5a; } .ok { font-size: 11px; color: #8fcf86; }
.prel { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.rel { font-size: 11px; padding: 4px 7px; border-radius: 5px; border: 1px solid var(--line); background: #111b24; }
.rel.war { border-color: #7c443f; background: #251a1b; } .rel.alliance { border-color: #6d5f33; background: #221f15; }
.plog { margin-top: 9px; display: grid; gap: 4px; }
.pl { font-size: 12px; line-height: 1.4; color: #d4dcdf; }
.note { font-size: 12px; color: var(--mut); line-height: 1.5; margin: 8px 0 0; }

/* ---------------------------------------------------------------- below the stage */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.stats > div { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); min-width: 0; }
.stats b { display: block; font: 17px Georgia, serif; color: #f7f0dc; overflow: hidden; text-overflow: ellipsis; }
.stats .mono { font-size: 10px; }
.controls { display: flex; gap: 6px; margin-top: 10px; }
button { font: inherit; color: inherit; }
.ctl { min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; font-size: 15px; }
.ctl.wide { flex: 1; font-size: 12px; font-family: ui-monospace, monospace; }
.err { color: #e2a07a; font-size: 13px; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font: 10px ui-monospace, monospace; padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--mut); }
.sw { width: 14px; height: 3px; border-radius: 2px; } .sw.war { background: var(--war); } .sw.ally { background: var(--ally); }

.card { border: 1px solid var(--line); background: rgba(21,33,45,.96); border-radius: 9px; padding: 14px; margin-bottom: 14px; }
.nlist, .log { display: grid; gap: 6px; margin-top: 10px; }
.nrow { display: grid; grid-template-columns: auto 1fr; gap: 1px 7px; align-items: center; width: 100%; min-height: 44px; padding: 7px 10px; text-align: left;
  border: 1px solid var(--line); border-left: 4px solid var(--c, #555); border-radius: 6px; background: #111b24; cursor: pointer; }
.nrow .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c, #555); }
.nrow strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nrow .mono { grid-column: 2; font-size: 10px; }
.nrow.ruin { --c: #5d5850; color: #b8b1a4; }
.ev { display: grid; gap: 2px; width: 100%; padding: 8px 2px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 12px; line-height: 1.4; cursor: pointer; }
.ev:disabled { cursor: default; color: inherit; }
.ev .mono { font-size: 10px; }
.ev.t-war .mono, .ev.t-battle .mono { color: #e08a7a; }
.ev.t-alliance .mono { color: var(--ally); }

@media (max-width: 380px) {
  .hide-s { display: none; }
  h1 { font-size: 30px; }
  .sub { font-size: 13px; }
}
@media (min-width: 900px) {
  .w { padding: 24px; }
  h1 { font-size: 46px; }
  .layout { grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
  .stage { aspect-ratio: 16 / 10; max-height: 74vh; }
  .panel { left: auto; right: 10px; top: 64px; bottom: auto; width: 300px; max-height: calc(100% - 74px); }
  .ntag .nm { display: inline; }
  .side .log { max-height: 52vh; overflow: auto; }
}
