/* ============================================================
   Empire Ascendant — complete UI stylesheet (owner: ui-panels)
   Medieval dark-wood / parchment aesthetic with gold accents.
   Layering: canvas (0) < frame (15) < bars (20) < toasts (40)
             < tooltip (80) < overlay (90) < start-menu (100) < loading (200)
   ============================================================ */

:root {
  --wood-darkest: #140d05;
  --wood-dark: #241708;
  --wood: #362410;
  --wood-light: #4d3418;
  --gold: #d4a531;
  --gold-bright: #f0cd6e;
  --gold-dim: #8a6d1f;
  --parchment: #e9d8ac;
  --parchment-dim: #cdb684;
  --ink: #2b1f10;
  --text: #f0e4c0;
  --text-dim: #b3a074;
  --danger: #d64541;
  --ok: #58b845;
  --warn: #e0762e;
  --grain: repeating-linear-gradient(93deg,
      #3b2812 0px, #452f18 10px, #382510 13px, #4a3119 24px, #33220d 27px);
  --panel-edge: inset 0 1px 0 rgba(240, 205, 110, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: #0d0803;
  font-family: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  color: var(--text);
}

button { font-family: inherit; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------------- main canvas ---------------- */

#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: default;
  background: #0d0803;
}
#game.cursor-attack { cursor: crosshair; }

/* ---------------- play-area vignette ---------------- */

#viewport-frame {
  position: absolute;
  top: 46px; bottom: 185px; left: 0; right: 0;
  pointer-events: none;
  z-index: 15;
  box-shadow:
    inset 0 28px 48px rgba(0, 0, 0, 0.28),
    inset 0 -28px 48px rgba(0, 0, 0, 0.32),
    inset 0 0 120px rgba(0, 0, 0, 0.18);
  border-left: 1px solid rgba(212, 165, 49, 0.06);
  border-right: 1px solid rgba(212, 165, 49, 0.06);
}

/* ---------------- top HUD bar ---------------- */

#ui-top {
  position: absolute; top: 0; left: 0; right: 0;
  height: 46px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.32)), var(--grain);
  border-bottom: 2px solid var(--gold-dim);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), var(--panel-edge);
  z-index: 20;
  user-select: none;
}

.hud-badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px;
  padding: 0 12px 0 10px;
  background: linear-gradient(#2a1a0a, #1a1006);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.12), 0 1px 3px rgba(0, 0, 0, 0.5);
  margin-right: 2px;
}
.hud-badge .badge-icon { font-size: 15px; line-height: 1; }
.hud-badge .badge-text {
  font-size: 12px; font-weight: bold;
  color: var(--gold-bright);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.hud-divider {
  width: 1px; height: 26px;
  background: linear-gradient(transparent, rgba(212, 165, 49, 0.35), transparent);
  margin: 0 2px;
  flex-shrink: 0;
}

.hud-spacer { flex: 1; }

.hud-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 10px;
  background: linear-gradient(#1c1207, #241708);
  border: 1px solid #6b4e22;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.hud-chip .chip-icon { font-size: 15px; line-height: 1; }
.hud-chip .chip-value {
  font-size: 13px; font-weight: bold; color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
}
.res-chip .chip-value { min-width: 40px; }
.res-chip[data-res="food"]  { border-color: #6b8a32; }
.res-chip[data-res="wood"]  { border-color: #7a5a2e; }
.res-chip[data-res="gold"]  { border-color: #9a7a18; }
.res-chip[data-res="stone"] { border-color: #6a6a72; }
.res-chip[data-res="food"]  .chip-value { color: #c8e07a; }
.res-chip[data-res="wood"]  .chip-value { color: #e0b878; }
.res-chip[data-res="gold"]  .chip-value { color: #f5d86a; }
.res-chip[data-res="stone"] .chip-value { color: #d0d0d8; }

.pop-chip.blocked { border-color: var(--danger); }
.pop-chip.blocked .chip-value { color: #ff7a6e; animation: pop-pulse 0.9s ease-in-out infinite alternate; }
@keyframes pop-pulse { from { opacity: 1; } to { opacity: 0.55; } }

.age-chip { border-color: var(--gold-dim); }
.age-chip .chip-value { color: var(--gold-bright); letter-spacing: 1px; min-width: 0; }
.clock-chip .chip-value { min-width: 42px; text-align: right; }

.hud-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
  background: linear-gradient(#4a3218, #2c1c0c);
  border: 1px solid #7a5a26;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.15), 0 1px 3px rgba(0, 0, 0, 0.5);
}
.hud-btn:hover { border-color: var(--gold-bright); box-shadow: 0 0 8px rgba(212, 165, 49, 0.4); }
.hud-btn:active { background: linear-gradient(#2c1c0c, #4a3218); }
.hud-btn.on { border-color: var(--gold); background: linear-gradient(#5b3f1f, #3a2510); }

/* ---------------- toasts ---------------- */

#notifications {
  position: absolute; top: 56px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: max-content; max-width: 64vw;
  z-index: 40;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  background: rgba(22, 13, 5, 0.93);
  color: var(--parchment);
  font-size: 13px;
  letter-spacing: 0.3px;
  border: 1px solid rgba(212, 165, 49, 0.35);
  border-left-width: 4px;
  border-radius: 3px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-info    { border-left-color: var(--gold); }
.toast-success { border-left-color: var(--ok); }
.toast-warn    { border-left-color: var(--warn); }
.toast-error   { border-left-color: var(--danger); }
.toast-out { opacity: 0; transform: translateY(-12px); }

/* ---------------- bottom command bar ---------------- */

#ui-bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 185px;
  display: grid;
  grid-template-columns: minmax(240px, 30%) minmax(0, 1fr) 252px;
  background: linear-gradient(rgba(0, 0, 0, 0.30), rgba(0, 0, 0, 0.30)), var(--grain);
  border-top: 3px solid var(--gold-dim);
  box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.65), var(--panel-edge);
  z-index: 20;
  user-select: none;
  overflow: visible; /* minimap housing protrudes above the bar */
}

#panel-info {
  padding: 10px 14px;
  overflow-y: auto;
  border-right: 1px solid rgba(212, 165, 49, 0.22);
}

#panel-actions {
  position: relative;
  padding: 10px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  grid-auto-rows: 74px;
  gap: 8px;
  align-content: start;
  border-right: 1px solid rgba(212, 165, 49, 0.22);
}

#panel-info::-webkit-scrollbar, #panel-actions::-webkit-scrollbar { width: 8px; }
#panel-info::-webkit-scrollbar-track, #panel-actions::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.35); }
#panel-info::-webkit-scrollbar-thumb, #panel-actions::-webkit-scrollbar-thumb {
  background: #5a3f1d; border-radius: 4px; border: 1px solid #2a1b0b;
}

.panel-hint {
  padding: 16px 8px;
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
  text-align: center;
}

.shortcuts-panel {
  padding: 10px 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.shortcuts-title {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-align: center;
}
.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
}
.shortcut-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-dim);
}
.shortcut-row kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 5px;
  font-family: inherit;
  font-size: 10px;
  font-style: normal;
  text-align: center;
  color: var(--gold-bright);
  background: linear-gradient(#3c2913, #221507);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.panel-title {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 10px 0 5px;
}

/* ----- info card ----- */

.info-head { display: flex; align-items: center; gap: 10px; }
.info-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; line-height: 1;
  background: radial-gradient(circle at 50% 35%, #3a2712, #1a1006);
  border: 1px solid var(--gold-dim);
  border-radius: 5px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.7);
}
.info-titles { min-width: 0; }
.info-name {
  font-size: 15px; font-weight: bold;
  color: var(--gold-bright);
  letter-spacing: 0.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.info-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.hpbar, .buildbar {
  position: relative;
  height: 15px;
  margin: 8px 0 6px;
  background: #17100a;
  border: 1px solid #6b4e22;
  border-radius: 2px;
  overflow: hidden;
}
.hpbar-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 100%;
  background: linear-gradient(#7ed95e, #4a9e36);
  transition: width 0.15s linear;
}
.hpbar.mid .hpbar-fill { background: linear-gradient(#e8c04a, #c08a24); }
.hpbar.low .hpbar-fill { background: linear-gradient(#e86a52, #b03424); }
.buildbar-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0%;
  background: linear-gradient(#f0d264, #c39a2b);
  transition: width 0.15s linear;
}
.hpbar-text, .buildbar-text {
  position: absolute; inset: 0;
  text-align: center;
  font-size: 10px; line-height: 14px; font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 1px #000, 0 0 3px #000;
}

.info-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 14px;
  font-size: 12px;
  margin-top: 4px;
}
.stat-row { display: flex; justify-content: space-between; gap: 6px; min-width: 0; }
.stat-k { color: var(--text-dim); white-space: nowrap; }
.stat-v { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ----- production queue chips ----- */

.queue-row { display: flex; flex-wrap: wrap; gap: 6px; }
.queue-empty { color: var(--text-dim); font-style: italic; font-size: 12px; padding: 3px 0; }

.queue-chip {
  position: relative;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#3c2913, #221507);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  color: var(--text);
}
.qc-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(240, 205, 110, 0.32);
}
.qc-icon { position: relative; font-size: 20px; line-height: 1; }
.qc-x {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  font-size: 17px; font-weight: bold;
  color: #ff9a8a;
  background: rgba(90, 15, 8, 0.62);
}
.queue-chip:hover { border-color: #e05a4a; }
.queue-chip:hover .qc-x { display: flex; }

/* ----- multi-select grid ----- */

.multi-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.multi-chip {
  width: 36px; height: 40px;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 3px 2px 4px;
  background: linear-gradient(#3c2913, #221507);
  border: 1px solid #6b4e22;
  border-radius: 4px;
  cursor: pointer;
}
.multi-chip:hover { border-color: var(--gold-bright); box-shadow: 0 0 6px rgba(212, 165, 49, 0.4); }
.mc-icon { font-size: 17px; line-height: 1.2; }
.mc-hp {
  width: 100%; height: 4px;
  margin-top: auto;
  background: #17100a;
  border-radius: 2px;
  overflow: hidden;
}
.mc-hp-fill { height: 100%; width: 100%; background: var(--ok); }

/* ----- command buttons ----- */
/* NOTE: never put transform/filter on .cmd-btn itself — the fixed-position
   .tip tooltip inside would re-anchor to the button and clip. */

.cmd-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 4px 3px;
  background: linear-gradient(#4a3218, #2c1c0c);
  border: 1px solid #7a5a26;
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.15), 0 2px 3px rgba(0, 0, 0, 0.5);
  color: var(--text);
  cursor: pointer;
}
.cmd-btn:hover {
  border-color: var(--gold-bright);
  background: linear-gradient(#5b3f1f, #382410);
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.25), 0 0 8px rgba(212, 165, 49, 0.35);
}
.cmd-btn:active { background: linear-gradient(#2c1c0c, #4a3218); }
.cmd-btn.active {
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(240, 205, 110, 0.65), inset 0 0 6px rgba(240, 205, 110, 0.35);
}
.cmd-btn.disabled { cursor: not-allowed; }
.cmd-btn.disabled:hover {
  border-color: #6a4f22;
  background: linear-gradient(#4a3218, #2c1c0c);
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.1);
}
.cmd-btn.disabled .cmd-icon,
.cmd-btn.disabled .cmd-label { opacity: 0.38; filter: grayscale(0.8); }

.cmd-icon { font-size: 22px; line-height: 1; }
.cmd-label {
  font-size: 9.5px; line-height: 1.15;
  text-align: center;
  max-height: 22px;
  overflow: hidden;
  padding: 0 1px;
}
.cmd-lock {
  position: absolute; top: 2px; right: 3px;
  font-size: 11px; line-height: 1;
  display: none;
}
.cmd-btn.locked .cmd-lock { display: block; }

.cmd-btn.age-btn { border-color: var(--gold); }
.cmd-btn.age-btn .cmd-label { color: var(--gold-bright); }

/* ----- CSS tooltip: fixed help box anchored above the command bar ----- */

.cmd-btn .tip { display: none; }
.cmd-btn:hover .tip {
  display: block;
  position: fixed;
  left: 50%; bottom: 198px;
  transform: translateX(-50%);
  width: max-content; max-width: 360px;
  padding: 9px 13px;
  text-align: left;
  background: linear-gradient(#f2e4bd, #ddc793);
  color: var(--ink);
  border: 2px solid var(--gold-dim);
  outline: 1px solid #3a2a12;
  border-radius: 3px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
  z-index: 80;
  pointer-events: none;
  cursor: default;
}
.tip-name { font-size: 13.5px; font-weight: bold; color: #4a3208; letter-spacing: 0.4px; }
.tip-cost { margin-top: 3px; font-size: 12px; color: #6b4a10; font-weight: bold; }
.tip-desc { margin-top: 3px; font-size: 11.5px; color: #4c3d22; font-style: italic; }
.tip-reason { margin-top: 5px; font-size: 11.5px; font-weight: bold; color: #a3241c; }
.tip-cost:empty, .tip-desc:empty, .tip-reason:empty { display: none; }

/* ---------------- minimap housing ---------------- */

#panel-minimap { position: relative; }
#mm-label {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold-dim);
  z-index: 1;
  pointer-events: none;
}
#panel-minimap::before {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 244px; height: 250px;
  background: linear-gradient(rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.28)), var(--grain);
  border: 2px solid var(--gold-dim);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.6), var(--panel-edge);
}
#minimap {
  position: absolute;
  bottom: 13px; left: 50%;
  transform: translateX(-50%);
  border: 2px solid #6b4e22;
  border-radius: 2px;
  background: #000;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

/* ---------------- victory / defeat overlay ---------------- */

#overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12, 7, 2, 0.82), rgba(0, 0, 0, 0.93));
  z-index: 90;
}
#overlay.hidden { display: none; }

.over-panel {
  width: min(640px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 30px 36px 28px;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(#f2e4bd, #d9c28c);
  border: 4px double var(--gold-dim);
  outline: 2px solid #241708;
  border-radius: 5px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.85), inset 0 0 60px rgba(138, 109, 31, 0.18);
  animation: over-in 0.5s cubic-bezier(0.18, 0.9, 0.32, 1.2);
}
@keyframes over-in {
  from { opacity: 0; transform: scale(0.9) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.over-title {
  font-size: 52px;
  font-weight: bold;
  letter-spacing: 10px;
  text-transform: uppercase;
}
.over-title.victory {
  color: #8a6a12;
  text-shadow: 0 2px 0 #fff3c4, 0 0 26px rgba(212, 165, 49, 0.65);
}
.over-title.defeat {
  color: #7e1d14;
  text-shadow: 0 2px 0 #f3cfc4, 0 0 26px rgba(190, 50, 40, 0.55);
}
.over-sub { margin: 8px 0 18px; font-size: 14px; font-style: italic; color: #5a4a2a; }

.over-stats table { width: 100%; border-collapse: collapse; }
.over-stats th, .over-stats td {
  padding: 5px 10px;
  border-bottom: 1px solid rgba(90, 70, 40, 0.3);
  font-size: 13px;
}
.over-stats th { font-size: 14px; border-bottom: 2px solid rgba(90, 70, 40, 0.55); }
.over-stats td:first-child { text-align: left; color: #574119; }
.over-stats td:not(:first-child), .over-stats th:not(:first-child) {
  text-align: center;
  font-variant-numeric: tabular-nums;
  min-width: 110px;
}
.over-stats tbody tr:nth-child(even) td { background: rgba(90, 70, 40, 0.07); }

.over-time { margin-top: 12px; font-size: 13px; color: #574119; }

.over-btn {
  margin-top: 20px;
  padding: 11px 40px;
  font-size: 17px;
  letter-spacing: 1.5px;
  color: var(--gold-bright);
  background: linear-gradient(#4a3218, #241708);
  border: 2px solid var(--gold-dim);
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(240, 205, 110, 0.2);
}
.over-btn:hover {
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(212, 165, 49, 0.55);
  transform: translateY(-1px);
}
.over-btn:active { transform: translateY(1px); }

/* ---------------- loading splash ---------------- */

#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(212, 165, 49, 0.08), transparent 70%),
    radial-gradient(ellipse at center, #1c1206 0%, #0d0803 72%);
  z-index: 200;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}
#loading.loading-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-emblem {
  font-size: 52px;
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(212, 165, 49, 0.55);
  animation: emblem-pulse 2.4s ease-in-out infinite;
}
@keyframes emblem-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

.loading-title {
  font-size: 44px;
  font-weight: bold;
  letter-spacing: 12px;
  color: var(--gold-bright);
  text-shadow: 0 0 26px rgba(212, 165, 49, 0.55), 0 2px 0 #000;
}
.loading-sub {
  font-size: 14px;
  font-style: italic;
  color: var(--text-dim);
  animation: loading-pulse 1.6s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.loading-bar {
  width: min(280px, 70vw);
  height: 6px;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 165, 49, 0.25);
  border-radius: 3px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright));
  border-radius: 2px;
  animation: loading-progress 1.8s ease-out forwards;
}
@keyframes loading-progress {
  0% { width: 0%; }
  70% { width: 88%; }
  100% { width: 100%; }
}

/* ---------------- start menu ---------------- */

#start-menu {
  position: absolute; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  animation: sm-fade-in 0.6s ease-out;
}
@keyframes sm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sm-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 35%, rgba(212, 165, 49, 0.12), transparent 65%),
    radial-gradient(ellipse at center, #2a2015 0%, #14100a 70%, #0a0805 100%);
}
.sm-bg::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 47px, rgba(212, 165, 49, 0.03) 48px),
    repeating-linear-gradient(90deg, transparent, transparent 47px, rgba(212, 165, 49, 0.03) 48px);
  pointer-events: none;
}

.sm-vignette {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.sm-panel {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 48px 64px 40px;
  min-width: 380px;
  background: linear-gradient(180deg, rgba(46, 35, 20, 0.96), rgba(22, 16, 9, 0.98));
  border: 2px solid var(--gold-dim);
  border-radius: 10px;
  box-shadow:
    0 0 80px rgba(0, 0, 0, 0.85),
    inset 0 0 40px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(212, 165, 49, 0.08);
  animation: sm-panel-in 0.7s cubic-bezier(0.18, 0.9, 0.32, 1.15);
}
@keyframes sm-panel-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sm-panel::before, .sm-panel::after {
  content: '◆';
  position: absolute;
  font-size: 10px;
  color: var(--gold-dim);
  opacity: 0.7;
}
.sm-panel::before { top: 10px; left: 14px; }
.sm-panel::after  { bottom: 10px; right: 14px; }

.sm-ornament {
  font-size: 36px;
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 20px rgba(212, 165, 49, 0.5);
  margin-bottom: -4px;
}

.sm-title-wrap {
  display: flex; align-items: center; gap: 14px;
  width: 100%; justify-content: center;
}
.sm-rule {
  flex: 1; max-width: 60px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.sm-title {
  font-size: 38px;
  font-weight: bold;
  letter-spacing: 7px;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 #4a3410, 0 0 24px rgba(232, 201, 106, 0.35);
  white-space: nowrap;
}
.sm-title-sm { font-size: 28px; letter-spacing: 5px; }

.sm-sub {
  color: var(--parchment-dim);
  font-style: italic;
  margin-bottom: 10px;
  font-size: 14px;
  text-align: center;
  max-width: 300px;
  line-height: 1.45;
}

.sm-btn {
  width: 280px;
  padding: 14px 0;
  font-size: 17px;
  cursor: pointer;
  letter-spacing: 1.2px;
  color: var(--text);
  background: linear-gradient(180deg, #5b4520, #3a2a12);
  border: 1px solid #8f7439;
  border-radius: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.15), 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s, box-shadow 0.15s, border-color 0.15s, filter 0.15s;
}
.sm-btn:hover {
  border-color: var(--gold-bright);
  filter: brightness(1.15);
  box-shadow: inset 0 1px 0 rgba(240, 205, 110, 0.25), 0 0 18px rgba(212, 165, 49, 0.35);
}
.sm-btn:active { transform: scale(0.97); }
.sm-btn-primary {
  border-color: var(--gold);
  background: linear-gradient(180deg, #6b5327, #4a3712);
  font-weight: bold;
}

.sm-dev {
  background: linear-gradient(180deg, #3d4a5c, #26303d);
  border-color: #5a6f88;
}
.sm-dev:hover { box-shadow: inset 0 1px 0 rgba(180, 200, 230, 0.2), 0 0 18px rgba(90, 111, 136, 0.45); }

.sm-foot {
  margin-top: 12px;
  font-size: 11px;
  color: #6f5f42;
  letter-spacing: 1px;
  text-align: center;
}

.sm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 320px;
  color: var(--parchment);
  font-size: 14px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(212, 165, 49, 0.12);
  border-radius: 6px;
}
.sm-row input[type=range] { flex: 1; accent-color: var(--gold-bright); cursor: pointer; }
.sm-row input[type=checkbox] { accent-color: var(--gold-bright); width: 16px; height: 16px; cursor: pointer; }
.sm-val { min-width: 42px; text-align: right; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.sm-disabled { opacity: 0.42; pointer-events: none; }
.sm-row select {
  background: #26303d;
  color: var(--parchment);
  border: 1px solid #5a6f88;
  border-radius: 4px;
  padding: 3px 6px;
}

/* ---------------- small screens ---------------- */

@media (max-width: 1024px) {
  #ui-bottom { grid-template-columns: minmax(200px, 28%) minmax(0, 1fr) 252px; }
  .res-chip .chip-value { min-width: 32px; }
  .age-chip .chip-value { display: none; }
  .hud-badge .badge-text { display: none; }
  .sm-panel { padding: 36px 28px 32px; min-width: 0; width: min(380px, 92vw); }
  .sm-title { font-size: 28px; letter-spacing: 4px; }
  .sm-btn { width: 100%; max-width: 280px; }
}
