:root {
  /* Tactile Sunlit Atlantean Limestone, Aged Parchment, Burnished Bronze, Moss & Verdigris */
  --bg: #cfc3ab;
  --bg-deep: #b8aa8f;
  --panel: #e6dcc6;
  --panel-2: #d8ccb1;
  --border: rgba(114, 84, 44, 0.42);
  --border-bright: rgba(120, 80, 28, 0.85);
  --patina: #2a7f73;
  --moss: #4d6e3a;
  --bronze: #825920;
  --bronze-dim: #755e3c;
  --crystal: #0d8f86;
  --ink: #2a2117;
  --muted: #655745;
  --crimson: #b83d2e;
  --violet: #7c38b8;
}

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

html,
body {
  height: 100%;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 248, 232, 0.55), transparent 46%),
    radial-gradient(circle at 86% 88%, rgba(77, 110, 58, 0.16), transparent 44%),
    linear-gradient(160deg, #d7ccb4 0%, #c1b398 55%, #b1a185 100%);
  color: var(--ink);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 276px 1fr 308px;
  height: 100vh;
  gap: 10px;
  padding: 10px;
}

.panel {
  background: linear-gradient(180deg, #ece3ce, #ded2b7);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 238, 0.8),
    inset 0 0 24px rgba(130, 96, 48, 0.08),
    0 6px 20px rgba(48, 36, 20, 0.18);
}

.panel-scroll {
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.panel-scroll::-webkit-scrollbar {
  width: 6px;
}
.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(114, 84, 44, 0.35);
  border-radius: 3px;
}

.brand-header {
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  background: linear-gradient(90deg, rgba(164, 122, 56, 0.16), rgba(42, 127, 115, 0.12));
}

.brand-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15.5px;
  letter-spacing: 0.1em;
  color: #5a3c16;
  text-transform: uppercase;
  font-weight: 700;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--bronze-dim);
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

button {
  background: linear-gradient(180deg, #f3ebd8, #dfd2b6);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(48, 36, 20, 0.12);
  transition: border-color 0.14s, background 0.14s, transform 0.08s;
}

button:hover {
  border-color: var(--border-bright);
  background: linear-gradient(180deg, #faf3e4, #e7dac0);
}

button:active {
  transform: translateY(1px);
}

button.active {
  border-color: var(--patina);
  background: linear-gradient(180deg, #d2ebe6, #b7dcd6);
  color: #124741;
  font-weight: 600;
}

button.primary {
  background: linear-gradient(180deg, #c99746, #9c6e26);
  border-color: #6b4914;
  color: #fffaf0;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 1px rgba(40, 24, 8, 0.45);
}

button.primary:hover {
  background: linear-gradient(180deg, #d8a654, #ad7c2e);
}

button.danger {
  border-color: rgba(184, 61, 46, 0.55);
  color: #8f261a;
}

.theorem-card {
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theorem-card .t-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 12px;
}

.theorem-card .t-sub {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
}

.badge {
  font-family: Consolas, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: #614114;
  background: rgba(168, 126, 58, 0.14);
}

.badge.warn {
  border-color: rgba(184, 61, 46, 0.65);
  color: #8f2216;
  background: rgba(184, 61, 46, 0.14);
}

.badge.cyan {
  border-color: rgba(24, 134, 126, 0.55);
  color: #0e5c56;
  background: rgba(42, 148, 138, 0.14);
}

.badge.violet {
  border-color: rgba(124, 56, 184, 0.55);
  color: #5c2291;
  background: rgba(124, 56, 184, 0.14);
}

/* Center Stage */
.center-stage {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.hud-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #eee5d0, #dfd3b8);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  box-shadow: 0 4px 12px rgba(48, 36, 20, 0.14);
}

.caster-hud {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.caster-hud.enemy {
  align-items: flex-end;
  text-align: right;
}

.caster-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #0e635d;
  display: flex;
  gap: 6px;
  align-items: center;
}

.caster-hud.enemy .caster-name {
  color: #9e3124;
}

.hp-track {
  width: 100%;
  max-width: 225px;
  height: 8px;
  background: rgba(68, 52, 34, 0.22);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #1b8c84, #34bdb3);
  transition: width 0.2s ease;
}

.caster-hud.enemy .hp-fill {
  background: linear-gradient(90deg, #a63427, #dc6352);
}

.turn-pill {
  text-align: center;
  padding: 4px 14px;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  background: #f3ebd9;
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #5c3e14;
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Warm temple floor stone backdrop behind the 2.5D pedestal table */
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 250, 236, 0.42), transparent 55%),
    radial-gradient(circle at center, #cfc2a7 0%, #b5a587 72%, #9e8f72 100%);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 2px 18px rgba(54, 40, 22, 0.22);
}

#astrolabeCanvas {
  cursor: grab;
  display: block;
}

.canvas-hint {
  position: absolute;
  bottom: 7px;
  left: 10px;
  right: 10px;
  text-align: center;
  font-size: 10.5px;
  color: #4a3b28;
  pointer-events: none;
  font-family: Consolas, monospace;
  font-weight: 600;
}

.shapes-bar {
  position: absolute;
  top: 8px;
  left: 10px;
  display: flex;
  gap: 5px;
  pointer-events: auto;
  z-index: 12;
}

.shapes-bar .badge {
  cursor: help;
}

.audio-controls {
  position: absolute;
  top: 8px;
  right: 10px;
  display: flex;
  gap: 5px;
  align-items: center;
}

/* Floating Carved Parchment Tooltip */
.astro-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 268px;
  padding: 8px 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f4ecda, #e3d6ba);
  border: 1.5px solid var(--border-bright);
  box-shadow: 0 8px 24px rgba(42, 30, 16, 0.34);
  display: none;
  flex-direction: column;
  gap: 3px;
}

.astro-tooltip.visible {
  display: flex;
}

.tt-title {
  font-family: Georgia, serif;
  font-size: 12.5px;
  font-weight: 700;
  color: #543712;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.tt-meta {
  font-family: Consolas, monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: #0e6b64;
}

.tt-body {
  font-size: 11px;
  color: var(--ink);
  line-height: 1.38;
}

.tt-hint {
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
  margin-top: 2px;
}

/* Timeline Footer */
.timeline-bar {
  padding: 9px 12px;
  background: linear-gradient(180deg, #eee5d0, #dfd3b8);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.timeline-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scrubber-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.scrubber-ticks {
  height: 7px;
  position: relative;
  width: 100%;
}

.tick-dot {
  position: absolute;
  top: 0;
  width: 4px;
  height: 7px;
  border-radius: 2px;
  transform: translateX(-50%);
}

.foresight-beats {
  display: flex;
  gap: 5px;
  flex: 1;
  align-items: center;
}

.foresight-beats button {
  flex: 1;
  padding: 5px 6px;
  font-family: Consolas, monospace;
  font-size: 11px;
}

input[type='range'] {
  width: 100%;
  accent-color: #8f6224;
  cursor: pointer;
}

.time-readout {
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #5c3e14;
  min-width: 78px;
  text-align: right;
}

.el-chip {
  padding: 4px 7px;
  font-size: 11px;
  font-family: Consolas, monospace;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.el-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(40, 28, 16, 0.45);
  display: inline-block;
}

.inspector-box {
  background: rgba(255, 249, 236, 0.55);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
}

.warp-box {
  background: rgba(124, 56, 184, 0.08);
  border: 1px solid rgba(124, 56, 184, 0.35);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sigil-wrap {
  background: #231e18; /* Dark bronze-slate plaque so glowing Red/Blue sigil lines read clearly */
  border: 1.5px solid #8a642c;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

#sigilCanvas {
  width: 248px;
  height: 224px;
  cursor: pointer;
}

.sigil-info {
  font-size: 11px;
  color: #dfd3bc;
  text-align: center;
  min-height: 32px;
  line-height: 1.35;
}

.compendium-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.log-box {
  background: rgba(255, 249, 236, 0.65);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  font-family: Consolas, monospace;
  font-size: 10.5px;
  max-height: 155px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-entry {
  line-height: 1.35;
  border-left: 2px solid var(--border);
  padding-left: 6px;
}

.log-entry.selfhit {
  border-left-color: #b83d2e;
  color: #962216;
  font-weight: 600;
}

.log-entry.scar {
  border-left-color: #9e6d1c;
  color: #6b470c;
  font-weight: 600;
}

.log-entry.reaction {
  border-left-color: #168c84;
  color: #0d5752;
}

/* Structured Per-Turn, Per-Node Chronicle Tree */
.chronicle-turn {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(255, 250, 238, 0.78);
  padding: 4px 6px;
  margin-bottom: 4px;
}

.chronicle-turn-head {
  cursor: pointer;
  font-weight: 700;
  color: #543712;
  font-size: 10px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chronicle-head-text {
  flex: 1;
  min-width: 0;
}

.chronicle-view-btn {
  padding: 1px 5px;
  font-size: 9px;
  font-family: Consolas, monospace;
  border-radius: 3px;
  background: rgba(143, 98, 36, 0.14);
  border: 1px solid rgba(143, 98, 36, 0.45);
  color: #543712;
  cursor: pointer;
  flex-shrink: 0;
}

.chronicle-view-btn:hover {
  background: rgba(24, 148, 140, 0.22);
  border-color: #0e8f86;
  color: #0b5752;
}

.chronicle-turn-head::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.12s;
}

.chronicle-turn[open] > .chronicle-turn-head::before {
  transform: rotate(90deg);
}

.chronicle-tree {
  margin-top: 5px;
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chronicle-node-group {
  border-left: 2px solid rgba(114, 84, 44, 0.35);
  padding: 2px 4px 2px 7px;
  border-radius: 0 4px 4px 0;
  transition: background 0.12s, border-color 0.12s;
}

.chronicle-node-group:hover {
  background: rgba(24, 158, 150, 0.11);
  border-left-color: #0e8f86;
}

.chronicle-node-group.enemy {
  border-left-color: rgba(184, 61, 46, 0.45);
}

.chronicle-node-group.daemon {
  border-left-color: rgba(192, 38, 211, 0.55);
}

.chronicle-node-title {
  font-weight: 700;
  font-size: 10px;
  color: #0e5c56;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.chronicle-node-t {
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  color: #6b4d22;
  opacity: 0.85;
}

.chronicle-node-group.enemy .chronicle-node-title {
  color: #962b1e;
}

.chronicle-node-group.daemon .chronicle-node-title {
  color: #7e1c96;
}

.chronicle-events {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chronicle-item {
  font-size: 10px;
  line-height: 1.42;
  color: var(--ink);
  position: relative;
  padding-left: 10px;
}

.chronicle-item::before {
  content: '├─';
  position: absolute;
  left: -2px;
  color: rgba(114, 84, 44, 0.45);
  font-size: 9px;
}

.chronicle-item:last-child::before {
  content: '└─';
}

.chronicle-seq {
  display: inline-block;
  font-family: Consolas, monospace;
  font-size: 8.5px;
  font-weight: 700;
  color: #5c4018;
  background: rgba(143, 98, 36, 0.15);
  border-radius: 3px;
  padding: 0 3px;
  margin-right: 3px;
}

.chronicle-t {
  display: inline-block;
  font-family: Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  color: #4b381d;
  background: rgba(255, 248, 232, 0.85);
  border: 1px solid rgba(114, 84, 44, 0.28);
  border-radius: 3px;
  padding: 0 3px;
  margin-right: 4px;
}

.chronicle-timeline {
  list-style: none;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chronicle-tl-row {
  font-size: 10px;
  line-height: 1.4;
  color: var(--ink);
  padding: 2px 4px;
  border-radius: 3px;
  border-left: 2px solid rgba(114, 84, 44, 0.3);
}

.chronicle-tl-row:hover {
  background: rgba(24, 158, 150, 0.12);
  border-left-color: #0e8f86;
}

.chronicle-tl-row.enemy {
  border-left-color: rgba(184, 61, 46, 0.45);
}

.chronicle-tl-row.daemon {
  border-left-color: rgba(192, 38, 211, 0.55);
}

.chronicle-src {
  font-weight: 700;
  color: #0e5c56;
}

.chronicle-src.enemy {
  color: #962b1e;
}

.chronicle-src.daemon {
  color: #7e1c96;
}

.verb-tag {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(24, 148, 140, 0.16);
  border: 1px solid rgba(24, 148, 140, 0.42);
  color: #0b5752;
  font-weight: 700;
  cursor: help;
}

.verb-tag:hover {
  background: rgba(24, 148, 140, 0.30);
  border-color: #0d8f86;
}

.chronicle-item.selfhit .verb-tag {
  background: rgba(184, 61, 46, 0.16);
  border-color: rgba(184, 61, 46, 0.5);
  color: #962216;
}

.chronicle-item.scar .verb-tag {
  background: rgba(202, 148, 42, 0.22);
  border-color: rgba(164, 114, 24, 0.55);
  color: #6b470c;
}

.key-legend {
  font-family: Consolas, monospace;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.5;
  background: rgba(255, 249, 236, 0.55);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
}

.key-legend strong {
  color: #5c3e14;
}
