/* True True Battles: pixel-medieval interface */
:root {
  --ink: #f3e9d2;
  --ink-dim: #b9a686;
  --ink-faint: #7d6d55;
  --gold: #f2c94c;
  --gold-dark: #a87a1c;
  --panel: #231813;
  --panel-2: #30211a;
  --panel-3: #3d2a1f;
  --edge: #0b0705;
  --trim: #8a6438;
  --trim-light: #c99a58;
  --red: #ec6a52;
  --green: #8ee07a;
  --notch: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  --notch-s: polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 0 calc(100% - 2px), 0 2px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0a14; }
body {
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  font-size: 15px;
  color: var(--ink);
  -webkit-font-smoothing: none;
  user-select: none;
}
input, select, button, textarea { font: inherit; }
.hidden { display: none !important; }
.dim { color: var(--ink-dim); }
.pos { color: var(--green); }
.neg, .bad { color: var(--red); }
.center { text-align: center; }
b { font-weight: 600; }
h2, h3 { font-weight: 700; color: var(--gold); text-shadow: 2px 2px 0 #000; margin: 0 0 8px; letter-spacing: 0.5px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; margin-top: 12px; }
p { margin: 6px 0; line-height: 1.35; }

.screen { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; cursor: grab; display: block; }
#view:active { cursor: grabbing; }

/* ---------- Panels ---------- */
.panel {
  background-color: var(--panel);
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 5px);
  border: 3px solid var(--edge);
  box-shadow: inset 0 0 0 2px var(--trim), inset 0 0 0 4px var(--panel-2), 0 6px 0 rgba(0, 0, 0, 0.35);
  clip-path: var(--notch);
}
.card {
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.25);
  padding: 10px 12px;
  margin: 10px 0;
  clip-path: var(--notch-s);
}

/* ---------- Icons ---------- */
.ico { display: inline-block; width: 18px; height: 18px; background-size: contain; background-repeat: no-repeat; background-position: center; image-rendering: pixelated; vertical-align: -4px; flex: none; }
.ico.sm { width: 14px; height: 14px; vertical-align: -2px; }
.ico.u { width: 22px; height: 26px; vertical-align: -7px; }
.ico.u.sm { width: 16px; height: 18px; vertical-align: -4px; }
.ico.b { width: 30px; height: 30px; background-position: center bottom; vertical-align: -9px; }
.emblem { width: 22px; height: 24px; image-rendering: pixelated; vertical-align: -6px; flex: none; }
.emblem.big { width: 33px; height: 36px; }
.emblem.sm { width: 16px; height: 18px; vertical-align: -4px; }
.emblem.huge { width: 66px; height: 72px; display: block; margin: 0 auto 8px; }

/* ---------- Buttons ---------- */
.btn {
  color: var(--ink);
  background: linear-gradient(#6c4b2d, #48301c);
  border: 2px solid var(--edge);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.16), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  cursor: pointer;
  clip-path: var(--notch-s);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
  line-height: 1.2;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35); }
.btn.primary { background: linear-gradient(#e2b445, #a2700f); color: #2a1806; text-shadow: 0 1px 0 rgba(255, 240, 200, 0.45); font-weight: 600; }
.btn.danger { background: linear-gradient(#bd4a33, #7c2516); }
.btn.sm { padding: 2px 8px; font-size: 14px; }
.btn.huge { display: block; width: 100%; font-size: 20px; padding: 10px; margin: 10px 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.mini {
  background: rgba(0, 0, 0, 0.35); color: var(--ink-dim); border: 1px solid rgba(0, 0, 0, 0.7);
  cursor: pointer; padding: 0 5px; line-height: 18px; font-size: 13px;
}
.mini:hover { color: var(--gold); }
.ibtn {
  position: relative; width: 34px; height: 32px; padding: 0; cursor: pointer;
  background: linear-gradient(#5a3e26, #3a2717); border: 2px solid var(--edge);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14); clip-path: var(--notch-s);
}
.ibtn:hover { filter: brightness(1.25); }
.ibtn .ico { width: 18px; height: 18px; vertical-align: middle; }
.badge {
  position: absolute; top: -2px; right: -2px; background: var(--red); color: #fff; font-style: normal;
  font-size: 11px; line-height: 13px; min-width: 13px; padding: 0 2px; text-align: center; border: 1px solid #000;
}
.key { display: inline-block; padding: 0 4px; border: 1px solid var(--ink-faint); color: var(--ink-dim); font-size: 12px; line-height: 15px; }
.tag { display: inline-block; padding: 1px 6px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(201, 154, 88, 0.4); font-size: 13px; color: var(--ink-dim); }
.tag.peace { color: #bfe8ff; border-color: #4a7aa8; }
.tag.paused { color: #ffe0a0; border-color: #c8902c; background: rgba(120, 70, 10, 0.55); font-size: 14px; padding: 2px 8px; }
.tag.soon { color: #ffd0a0; border-color: #a8602c; }

/* ---------- Bars ---------- */
.bar { display: inline-block; width: 90px; height: 9px; background: #120c08; border: 1px solid #000; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); vertical-align: middle; position: relative; }
.bar > div { height: 100%; background: linear-gradient(#a8e070, #5a9a34); }
.bar.low > div { background: linear-gradient(#ff8a6a, #b8402a); }
.bar.wall > div { background: linear-gradient(#d8d0c0, #8a8378); }
.bar.hp > div { background: linear-gradient(#ff8a6a, #c03a2a); }
.bar.big { width: 100%; height: 16px; }
.bar.big > div { background: linear-gradient(#f2c94c, #a87a1c); transition: width 0.2s; }

/* ---------- Top bar ---------- */
#topbar {
  position: absolute; left: 0; right: 0; top: 0; height: 46px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 10px; background: linear-gradient(#3a2819, #241811); border-bottom: 3px solid var(--edge);
  box-shadow: 0 2px 0 var(--trim), 0 6px 0 rgba(0, 0, 0, 0.3); z-index: 5;
}
.tb-left, .tb-mid, .tb-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.tb-left .realm { font-weight: 700; font-size: 17px; text-shadow: 2px 2px 0 #000; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.res { display: inline-flex; align-items: center; gap: 4px; }
.res b { font-size: 16px; }
.res small { font-size: 12px; }
.clock { display: inline-flex; gap: 6px; align-items: center; font-size: 16px; }
.speed { display: inline-flex; align-items: center; gap: 3px; }
.speed .lbl { margin-right: 4px; color: var(--gold); }
.sp { background: rgba(0, 0, 0, 0.35); color: var(--ink-dim); border: 1px solid #000; padding: 1px 5px; cursor: pointer; font-size: 13px; }
.sp.on { background: var(--gold-dark); color: #fff; }
.lords { display: inline-flex; gap: 4px; }
.lord { position: relative; display: inline-block; }
.lord .dot { position: absolute; right: -2px; bottom: 0; width: 8px; height: 8px; border: 1px solid #000; background: #555; }
.lord.on .dot { background: #6be26b; }
.lord.away .dot { background: #e2c56b; }
.lord.dead { opacity: 0.35; filter: grayscale(1); }
.fps { color: var(--ink-dim); font-size: 12px; }

/* ---------- Side panel ---------- */
#side {
  position: absolute; right: 8px; top: 54px; width: 340px; max-height: calc(100vh - 54px - 200px);
  overflow-y: auto; padding: 12px 14px; z-index: 4; scrollbar-width: thin; scrollbar-color: var(--trim) transparent;
}
#side .close, .modal-head .close { position: absolute; right: 8px; top: 8px; background: none; border: none; color: var(--ink-dim); cursor: pointer; font-size: 16px; }
#side .close:hover, .modal-head .close:hover { color: var(--gold); }
.ph { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; padding-right: 18px; }
.ph .title { font-size: 19px; font-weight: 700; color: var(--gold); text-shadow: 2px 2px 0 #000; }
.ph .sub { font-size: 13px; color: var(--ink-dim); }
.sec { border-top: 2px solid rgba(0, 0, 0, 0.45); box-shadow: 0 -1px 0 rgba(201, 154, 88, 0.15); padding: 8px 0 4px; }
.sec .lbl { color: var(--ink-dim); font-size: 13px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; }
.stats > div { margin: 3px 0; }
.units { width: 100%; border-collapse: collapse; }
.units td { padding: 1px 4px; }
.units td.num { text-align: right; font-weight: 600; }
.seg { display: flex; }
.seg button { flex: 1; background: rgba(0, 0, 0, 0.35); color: var(--ink-dim); border: 1px solid #000; padding: 4px 2px; cursor: pointer; }
.seg button.on { background: linear-gradient(#e2b445, #a2700f); color: #2a1806; font-weight: 600; }
.hint-s { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.row-btn {
  display: block; width: 100%; text-align: left; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(0, 0, 0, 0.6);
  color: var(--ink); padding: 4px 6px; margin: 3px 0; cursor: pointer;
}
.row-btn:hover { background: rgba(242, 201, 76, 0.12); }
.blds { display: flex; flex-wrap: wrap; gap: 6px; }
.bld { display: inline-flex; align-items: center; gap: 4px; background: rgba(0, 0, 0, 0.25); padding: 2px 6px 2px 2px; border: 1px solid rgba(0, 0, 0, 0.5); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.opt {
  display: flex; align-items: center; gap: 6px; text-align: left; background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(0, 0, 0, 0.7);
  color: var(--ink); padding: 3px 5px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.15);
}
.opt span { display: flex; flex-direction: column; line-height: 1.1; }
.opt small { font-size: 12px; color: var(--ink-dim); }
.opt:hover:not(:disabled) { background: rgba(242, 201, 76, 0.14); }
.opt:disabled { opacity: 0.45; cursor: not-allowed; }
.rec { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.rec-i { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.rec-i small { font-size: 12px; color: var(--ink-dim); }
.stepper { display: inline-flex; align-items: center; border: 1px solid #000; background: rgba(0, 0, 0, 0.35); }
.stepper button { background: none; border: none; color: var(--gold); width: 20px; cursor: pointer; font-size: 15px; }
.stepper span { min-width: 22px; text-align: center; }
.queue { margin-top: 6px; }
.qrow { display: flex; align-items: center; gap: 5px; font-size: 13px; margin: 2px 0; }
.qrow .bar { width: 60px; }
.build-prog { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.spells { display: flex; flex-wrap: wrap; gap: 5px; }
.btn.spell { font-size: 13px; padding: 3px 7px; }
.fogged { color: var(--ink-dim); }
.rel { font-weight: 600; }
.rel.war { color: var(--red); }
.rel.truce { color: #bfe8ff; }
.rel.alliance { color: var(--green); }
.pn { font-weight: 600; }

/* ---------- Units: rows, cards, codex, upgrades ---------- */
.uimg { image-rendering: pixelated; vertical-align: middle; flex: none; filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.55)); }
.uslot { display: inline-flex; align-items: flex-end; justify-content: center; width: 48px; flex: none; }
.stars { color: var(--gold); font-size: 11px; letter-spacing: -1px; text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.urows { display: flex; flex-direction: column; gap: 2px; }
.urow { display: flex; align-items: center; gap: 6px; padding: 2px 4px; min-height: 32px; cursor: pointer; background: rgba(0, 0, 0, 0.18); border: 1px solid transparent; }
.urow:hover { background: rgba(242, 201, 76, 0.1); border-color: rgba(242, 201, 76, 0.3); }
.uname { flex: 1; line-height: 1.1; }
.ucount { text-align: right; min-width: 40px; }
.ucount .bar { width: 70px; }
.mini.up { background: rgba(0, 0, 0, 0.35); border: 1px solid #000; padding: 1px 3px; line-height: 0; }
.mini.up:hover { background: rgba(242, 201, 76, 0.25); }
.link { cursor: pointer; text-decoration: underline dotted rgba(242, 201, 76, 0.55); text-underline-offset: 3px; }
.link:hover { color: var(--gold); }
div.link { text-decoration: none; }
div.link:hover { background: rgba(242, 201, 76, 0.08); }
.sub-lbl { margin-top: 8px; color: var(--trim-light); font-size: 13px; display: flex; align-items: center; gap: 4px; }
.orb-box { background: linear-gradient(rgba(255, 200, 80, 0.12), rgba(255, 150, 40, 0.05)); border: 1px solid rgba(255, 210, 110, 0.5); padding: 6px 8px; line-height: 1.4; }
.ibtn.alarm, .mbtn.alarm { animation: alarm 0.8s steps(2) infinite; }
@keyframes alarm { 50% { background: #8a2a1a; } }
.unit-card { display: flex; gap: 16px; align-items: flex-start; }
.uc-art {
  flex: none; width: 170px; min-height: 150px; display: flex; align-items: flex-end; justify-content: center; padding: 10px;
  background: radial-gradient(ellipse at 50% 85%, rgba(120, 160, 70, 0.4), rgba(0, 0, 0, 0.25) 70%); border: 2px solid rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.25); clip-path: var(--notch-s);
}
.uc-art .uimg { filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.5)); }
.uc-main { flex: 1; min-width: 0; }
.uc-tags { color: var(--ink-dim); font-size: 13px; }
.uc-main .card { margin: 6px 0; padding: 6px 10px; }
.uc-main .grid2 { margin: 8px 0; gap: 2px 16px; }
.uc-main h3 { margin-top: 10px; }
.matchups > div { margin: 4px 0; line-height: 1.6; }
.mchip { display: inline-block; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.6); padding: 0 5px; margin: 1px 1px; font-size: 13px; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 3px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.6); padding: 0 5px 0 2px; cursor: pointer; margin: 1px 2px; }
.chip:hover { background: rgba(242, 201, 76, 0.15); }
.abilities > div { margin: 3px 0; line-height: 1.35; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.cx {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-height: 100px; padding: 6px 4px;
  background: rgba(0, 0, 0, 0.25); border: 2px solid rgba(0, 0, 0, 0.6); color: var(--ink); cursor: pointer; clip-path: var(--notch-s);
  font-size: 13px; line-height: 1.1; text-align: center;
}
.cx:hover { background: rgba(242, 201, 76, 0.12); box-shadow: inset 0 0 0 1px var(--gold-dark); }
.cx > span:not(.stars) { min-height: 28px; display: flex; align-items: center; }
.up-opts { display: flex; flex-direction: column; gap: 4px; }
.up-opt { display: flex; gap: 14px; align-items: center; }
.up-art { width: 116px; display: flex; justify-content: center; flex: none; }
.up-main { flex: 1; }
.up-main h3 { margin: 0 0 4px; }
.up-main .btn { margin-top: 6px; }

/* ---------- Chat ---------- */
#chat { position: absolute; left: 8px; bottom: 8px; width: 410px; height: 258px; display: flex; flex-direction: column; z-index: 4; padding: 6px; }
#chat.collapsed { height: 42px; }
#chat.collapsed .chat-body { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 2px 2px 4px; }
.chat-head .tabs { display: flex; gap: 3px; }
.chat-head .tabs button {
  position: relative; background: rgba(0, 0, 0, 0.35); color: var(--ink-dim); border: 1px solid #000; padding: 3px 9px; cursor: pointer;
}
.chat-head .tabs button.on { color: var(--gold); background: rgba(242, 201, 76, 0.12); }
.chat-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.log { flex: 1; overflow-y: auto; background: rgba(0, 0, 0, 0.32); border: 1px solid #000; padding: 4px 6px; font-size: 14px; user-select: text; scrollbar-width: thin; scrollbar-color: var(--trim) transparent; }
.msg { margin: 2px 0; line-height: 1.3; word-wrap: break-word; }
.msg .t { color: var(--ink-faint); font-size: 12px; margin-right: 2px; }
.msg.sys { color: var(--gold); font-style: italic; }
.msg.letter { color: #e8d8ff; }
.msg.chron { cursor: default; }
.msg.chron[data-act] { cursor: pointer; }
.msg.chron[data-act]:hover { background: rgba(242, 201, 76, 0.08); }
.msg.chron.battle, .msg.chron.alert, .msg.chron.siege { color: #ffc0b0; }
.msg.chron.capture { color: #ffe08a; }
.msg.chron.diplo { color: #c8e4ff; }
.msg.chron.dragon { color: #ffb070; }
.pad { padding: 8px; }
.chat-form { display: flex; gap: 4px; margin-top: 4px; }
.chat-form input, .chat-form select, .card input, .card select, .modal-body input[type=number], #rename-input {
  background: #120c08; color: var(--ink); border: 2px solid #000; box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.25); padding: 4px 6px; outline: none;
}
.chat-form input { flex: 1; min-width: 0; user-select: text; }
.chat-form input:focus, .card input:focus { box-shadow: inset 0 0 0 1px var(--gold); }

/* ---------- Minimap ---------- */
#minimap-box { position: absolute; right: 8px; bottom: 8px; padding: 7px; z-index: 4; line-height: 0; }
#minimap { image-rendering: pixelated; cursor: pointer; border: 1px solid #000; }
.zoom { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 2px; line-height: 18px; }
.zoom .mini { background: rgba(10, 6, 4, 0.75); color: var(--ink); width: 20px; }

/* ---------- Hints, toasts, tooltip ---------- */
#hint {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%); z-index: 6; background: rgba(20, 12, 8, 0.92);
  border: 2px solid var(--gold-dark); padding: 6px 14px; color: var(--ink); clip-path: var(--notch-s);
}
#toasts { position: absolute; top: 136px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 560px; background: rgba(28, 18, 12, 0.94); border: 2px solid #000; box-shadow: inset 0 0 0 1px var(--trim);
  padding: 6px 12px; transition: opacity 0.7s, transform 0.7s; clip-path: var(--notch-s); animation: toast-in 0.25s ease-out;
}
.toast.good { box-shadow: inset 0 0 0 1px #5aa84a; }
.toast.bad { box-shadow: inset 0 0 0 1px #c8503a; color: #ffd8cc; }
.toast.link { cursor: pointer; }
.toast.fade { opacity: 0; transform: translateY(-6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
#tooltip, #uitip {
  position: fixed; left: 0; top: 0; z-index: 7; background: rgba(28, 18, 12, 0.96); border: 2px solid #000; box-shadow: inset 0 0 0 1px var(--trim), 0 3px 0 rgba(0, 0, 0, 0.35);
  padding: 5px 9px; font-size: 14px; line-height: 1.35; pointer-events: none; max-width: 260px; clip-path: var(--notch-s); will-change: transform;
}
#uitip { z-index: 40; color: var(--ink); }

/* ---------- Modals ---------- */
#modal { position: fixed; inset: 0; background: rgba(5, 3, 8, 0.6); z-index: 20; display: flex; align-items: center; justify-content: center; }
.modal-box {
  position: relative; width: 560px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column;
  background-color: var(--panel); background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 5px);
  border: 3px solid var(--edge); box-shadow: inset 0 0 0 2px var(--trim), inset 0 0 0 4px var(--panel-2); clip-path: var(--notch);
  animation: pop 0.15s ease-out;
}
.modal-box.wide { width: 820px; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 12px 16px 6px; border-bottom: 2px solid rgba(0, 0, 0, 0.5); }
.modal-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 8px 16px 16px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--trim) transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv { display: flex; justify-content: space-between; margin: 3px 0; }
.list { max-height: 220px; overflow-y: auto; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cards .card { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.cards .card h3 { margin: 0; font-size: 16px; }
.cards .card p { flex: 1; font-size: 14px; }
.card.tech.done { opacity: 0.75; box-shadow: inset 0 0 0 1px #5aa84a; }
.dip { display: flex; gap: 12px; align-items: flex-start; }
.dip-main { flex: 1; }
.dip .title { font-size: 18px; font-weight: 700; }
.tribute { display: inline-flex; gap: 4px; align-items: center; }
.tribute input { width: 80px; }
.seal { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.seal code, #gate-seal { font-family: inherit; font-size: 20px; letter-spacing: 2px; color: var(--gold); background: #120c08; padding: 4px 10px; border: 2px solid #000; user-select: text; }
.seal.big code { font-size: 30px; padding: 8px 16px; }
.blur { filter: blur(6px); }
.slider { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.slider input { flex: 1; accent-color: var(--gold); }
.check { display: block; margin: 6px 0; cursor: pointer; }
.split-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.split-row input { width: 80px; }
#rename-input { width: 100%; font-size: 18px; }
.help h3 { display: flex; align-items: center; gap: 6px; }
.away-log { max-height: 50vh; }
.victory { text-align: center; }
.victory h2 { font-size: 28px; }
.stats-table { margin: 10px auto; border-collapse: collapse; }
.stats-table th, .stats-table td { padding: 4px 10px; border-bottom: 1px solid rgba(201, 154, 88, 0.2); text-align: left; }
.victory .actions { justify-content: center; }

/* ---------- Loading ---------- */
#loading { position: fixed; inset: 0; z-index: 30; background: #0b0a14; display: flex; align-items: center; justify-content: center; }
.loading-box { width: 360px; padding: 20px; }
.loading-title { font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 #000; margin-bottom: 12px; text-align: center; }

/* ---------- Gate (title + council) ---------- */
#gate { overflow-y: auto; }
#gate-art { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; }
.gate-inner { position: relative; z-index: 1; max-width: 680px; margin: 0 auto; padding: 5vh 16px 40px; }
.logo {
  margin: 0; text-align: center; font-weight: 700; letter-spacing: 6px; line-height: 1;
  color: var(--gold); text-shadow: 4px 0 0 #2a1406, -4px 0 0 #2a1406, 0 4px 0 #2a1406, 0 -4px 0 #2a1406, 6px 8px 0 #000;
}
.logo span { display: block; }
.logo span:first-child { font-size: 54px; }
.logo span:last-child { font-size: 84px; color: #ff8a3a; }
.tagline { text-align: center; color: #e8d2b0; margin: 10px 0 22px; text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
#gate-panel { padding: 18px 22px; }
.err { background: rgba(200, 60, 40, 0.25); border: 1px solid #c8503a; padding: 6px 10px; margin-bottom: 8px; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.seat {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0, 0, 0, 0.28); border: 2px solid #000;
  box-shadow: inset 4px 0 0 var(--pc, #555); clip-path: var(--notch-s); min-height: 56px;
}
.seat.mine { box-shadow: inset 4px 0 0 var(--pc), inset 0 0 0 1px var(--gold); }
.seat.empty { justify-content: center; opacity: 0.6; }
.seat.fallen { opacity: 0.45; filter: grayscale(0.8); }
.seat-main { flex: 1; }
.seat-name { font-size: 18px; font-weight: 700; text-shadow: 2px 2px 0 #000; }
.seat-sub { font-size: 13px; color: var(--ink-dim); }
.dot { display: inline-block; width: 8px; height: 8px; background: #555; border: 1px solid #000; }
.dot.on { background: #6be26b; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.row > span:first-child { width: 110px; color: var(--ink-dim); }
.row input { flex: 1; }
.row.buttons { justify-content: flex-end; }
.swatches, .sigils { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border: 2px solid #000; cursor: pointer; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3); }
.swatch.on { outline: 2px solid var(--gold); outline-offset: 1px; }
.swatch:disabled { opacity: 0.2; cursor: not-allowed; }
.sig { background: rgba(0, 0, 0, 0.3); border: 2px solid #000; padding: 3px 5px; cursor: pointer; line-height: 0; }
.sig.on { outline: 2px solid var(--gold); }
.seal-card { text-align: center; }
.seal-card .seal { justify-content: center; }
.code-form { display: flex; gap: 8px; align-items: stretch; }
#code-input {
  flex: 1; min-width: 0; font-size: 26px; letter-spacing: 4px; text-align: center; text-transform: uppercase; color: var(--gold);
  background: #120c08; border: 3px solid #000; box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.35); padding: 8px 10px; outline: none; user-select: text;
}
#code-input::placeholder { color: var(--ink-faint); letter-spacing: 3px; font-size: 20px; }
#code-input:focus { box-shadow: inset 0 0 0 1px var(--gold); }
.code-form .btn { font-size: 20px; padding: 0 22px; }
#join-form .row input, #rename-form input { background: #120c08; color: var(--ink); border: 2px solid #000; box-shadow: inset 0 0 0 1px rgba(201, 154, 88, 0.25); padding: 4px 6px; outline: none; user-select: text; }
#rename-form input { flex: 1; }
.invite-card { text-align: center; }
.invite-card .seal { justify-content: center; }
.link-btn { background: none; border: none; color: var(--ink-dim); text-decoration: underline; cursor: pointer; font-size: 14px; }
.link-btn:hover { color: var(--gold); }
#sched-line { font-size: 14px; }
.gate-chat .log { height: 140px; }
.legends { margin-top: 16px; }
.legend { margin: 4px 0; }
#seal-input { text-transform: uppercase; letter-spacing: 2px; user-select: text; }
#join-name { user-select: text; }

/* ---------- Gate in daylight: parchment panels over a sunny sky ---------- */
#gate {
  --ink: #3b2412; --ink-dim: #6e5034; --ink-faint: #a58c69; --gold: #a0560c; --trim: #b28650; --trim-light: #d9b67c;
  --panel: #f5e7c6; --panel-2: #e8d3a6; --edge: #4a2e16; --green: #2f7d2c; --red: #b3361e;
  background: #8fc6ee;
  color: var(--ink);
}
#gate .logo { text-shadow: 4px 0 0 #3a1c08, -4px 0 0 #3a1c08, 0 4px 0 #3a1c08, 0 -4px 0 #3a1c08, 5px 7px 0 rgba(20, 50, 100, 0.35); }
#gate .tagline { color: #fffaf0; text-shadow: 2px 2px 0 rgba(30, 60, 110, 0.75); }
#gate .panel {
  background-image: repeating-linear-gradient(0deg, rgba(140, 95, 40, 0.05) 0 2px, transparent 2px 6px);
  box-shadow: inset 0 0 0 2px var(--trim), inset 0 0 0 4px var(--panel-2), 0 6px 0 rgba(30, 60, 110, 0.25);
}
#gate h2, #gate h3 { color: #8a3410; text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6); }
#gate .card { background: rgba(255, 251, 238, 0.6); border-color: rgba(110, 70, 30, 0.35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6); }
#gate .btn:not(.primary) { color: #fdf3dc; }
#gate .err { background: rgba(200, 60, 40, 0.12); color: #8a1f0c; }
#gate .seat { background: rgba(255, 251, 238, 0.7); border-color: #6b4a2a; }
#gate .seat.mine { box-shadow: inset 4px 0 0 var(--pc), inset 0 0 0 1px #c88a2c; }
#gate .seat-name { text-shadow: none; }
#gate .tag { background: rgba(110, 70, 30, 0.1); border-color: rgba(110, 70, 30, 0.45); color: var(--ink-dim); }
#gate .dot { background: #b8a78e; border-color: #6b4a2a; }
#gate .dot.on { background: #3fae3c; }
#gate .sig { background: rgba(110, 70, 30, 0.1); border-color: #6b4a2a; }
#gate .swatch { border-color: #3b2412; }
#gate .log { background: rgba(255, 255, 255, 0.6); border-color: rgba(110, 70, 30, 0.45); }
#gate .msg.sys { color: #8a5a0a; }
#gate #code-input { background: #fffaf0; color: #7a2e0e; border-color: var(--edge); box-shadow: inset 0 2px 0 rgba(110, 70, 30, 0.12); }
#gate #code-input::placeholder { color: #b9a07c; }
#gate #code-input:focus { box-shadow: inset 0 2px 0 rgba(110, 70, 30, 0.12), 0 0 0 2px #e2b445; }
#gate #join-form .row input, #gate #rename-form input, #gate .chat-form input, #gate select {
  background: #fffaf0; color: var(--ink); border: 2px solid #6b4a2a; box-shadow: inset 0 1px 0 rgba(110, 70, 30, 0.12); padding: 4px 6px; outline: none;
}
#gate #join-form .row input:focus, #gate #rename-form input:focus, #gate .chat-form input:focus { box-shadow: 0 0 0 2px #e2b445; }

/* ---------- Menu bar (labelled buttons under the top bar) ---------- */
#menubar {
  position: absolute; left: 8px; top: 52px; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 4px;
  background: linear-gradient(#3a2819, #241811); border: 2px solid var(--edge); box-shadow: inset 0 0 0 1px var(--trim), 0 3px 0 rgba(0, 0, 0, 0.3);
  clip-path: var(--notch-s);
}
.mbtn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; color: var(--ink); cursor: pointer;
  background: linear-gradient(#5e4129, #3a2717); border: 1px solid #000; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); font-size: 14px;
}
.mbtn:hover { filter: brightness(1.25); }
.mbtn:active { transform: translateY(1px); }
.mbtn .ico { width: 18px; height: 18px; }
.mbtn.has-badge::after {
  content: '!'; position: absolute; top: -3px; right: -3px; background: var(--red); color: #fff; font-size: 11px; line-height: 13px; min-width: 13px;
  text-align: center; border: 1px solid #000;
}
.msep { width: 10px; }

/* ---------- Guided tour ---------- */
#tour { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.tour-spot {
  position: fixed; border: 2px solid var(--gold); border-radius: 6px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 5, 3, 0.58), 0 0 18px rgba(242, 201, 76, 0.55); transition: left 0.25s, top 0.25s, width 0.25s, height 0.25s;
}
.tour-card { position: fixed; width: 370px; max-width: calc(100vw - 16px); padding: 14px 16px 12px; pointer-events: auto; transition: left 0.25s, top 0.25s; }
.tour-card h3 { margin: 0 0 6px; }
.tour-card p { margin: 0 0 12px; line-height: 1.45; }
.tour-count { position: absolute; right: 14px; top: 11px; font-size: 12px; color: var(--ink-dim); }
.tour-btns { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tour-btns .btn { margin-left: 6px; }
