/* ============================================================
   Mirror Trial — dark fantasy mirror temple
   Scoped under .mt-root so it never leaks into the maze app.
   ============================================================ */

.mt-root {
  --mt-bg: #07070b;
  --mt-bg-2: #0e0e16;
  --mt-bg-3: #16161f;
  --mt-line: #2a2535;
  --mt-line-2: #3a3548;
  --mt-text: #d9d6e0;
  --mt-muted: #7a7588;
  --mt-accent: #c9a55f;
  --mt-accent-glow: rgba(201, 165, 95, 0.45);
  --mt-red: #c0392b;
  --mt-blue: #2980b9;
  --mt-green: #27ae60;
  --mt-yellow: #d4ac0d;
  --mt-grey: #7f8c8d;
  --mt-flame: #e67e22;
  --mt-purple: #9b59b6;

  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #11101a 0%, #050509 90%);
  color: var(--mt-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Cinzel", serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

/* Hide the maze app while Mirror Trial is on screen */
body.mt-active #root > div:not(.mt-root):not(.mt-player-root) { display: none !important; }

/* === Top bar === */
.mt-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #1a1825 0%, #0d0d14 100%);
  border-bottom: 1px solid var(--mt-line);
  flex: 0 0 auto;
}
.mt-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--mt-accent);
  text-shadow: 0 0 8px var(--mt-accent-glow);
}
.mt-title-glyph { font-size: 22px; }
.mt-view-label {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--mt-line-2);
  border-radius: 999px;
  color: var(--mt-muted);
  letter-spacing: 0.15em;
}
.mt-topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.mt-divider {
  width: 1px;
  height: 22px;
  background: var(--mt-line);
  margin: 0 4px;
}

/* Buttons */
.mt-root button {
  background: #1a1825;
  color: var(--mt-text);
  border: 1px solid var(--mt-line);
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.mt-root button:hover:not(:disabled) {
  background: #221f30;
  border-color: var(--mt-line-2);
}
.mt-root button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mt-root button.active {
  background: var(--mt-accent);
  color: #0d0d14;
  border-color: var(--mt-accent);
  font-weight: 600;
}

.mt-segmented {
  display: inline-flex;
  border: 1px solid var(--mt-line);
  border-radius: 4px;
  overflow: hidden;
}
.mt-segmented button {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--mt-line);
  padding: 6px 10px;
}
.mt-segmented button:last-child { border-right: none; }

.mt-pill {
  border-radius: 999px !important;
  font-size: 11px;
  padding: 4px 10px !important;
}
.mt-pill-red    { background: var(--mt-red) !important;    color: #fff !important; border-color: transparent !important; }
.mt-pill-blue   { background: var(--mt-blue) !important;   color: #fff !important; border-color: transparent !important; }
.mt-pill-green  { background: var(--mt-green) !important;  color: #fff !important; border-color: transparent !important; }
.mt-pill-yellow { background: var(--mt-yellow) !important; color: #0d0d14 !important; border-color: transparent !important; }

/* === Main layout === */
.mt-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.mt-left-panel,
.mt-right-panel {
  width: 260px;
  background: var(--mt-bg-2);
  border-right: 1px solid var(--mt-line);
  overflow-y: auto;
  padding: 12px;
  flex: 0 0 auto;
}
.mt-right-panel {
  border-right: none;
  border-left: 1px solid var(--mt-line);
}
.mt-panel-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--mt-line);
}
.mt-panel-section:last-child { border-bottom: none; }
.mt-panel-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--mt-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.mt-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* === Grid wrap === */
.mt-grid-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    radial-gradient(ellipse at center, rgba(201, 165, 95, 0.04), transparent 70%),
    var(--mt-bg);
  overflow: hidden;
  min-width: 0;
}
.mt-grid-scroll {
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  padding: 12px;
}
#mtCanvas {
  display: block;
  background: #050509;
  border: 1px solid var(--mt-line-2);
  box-shadow: 0 0 40px rgba(201, 165, 95, 0.08);
  image-rendering: pixelated;
  cursor: crosshair;
}
.mt-grid-wrap.play #mtCanvas { cursor: pointer; }

.mt-grid-msg {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7, 7, 11, 0.85);
  border: 1px solid var(--mt-line-2);
  padding: 6px 14px;
  font-size: 12px;
  border-radius: 4px;
  color: var(--mt-accent);
  letter-spacing: 0.1em;
  pointer-events: none;
}

/* === Brushes === */
.mt-brush-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.mt-brush {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-align: left;
  padding: 6px 8px !important;
}
.mt-trap-types { grid-template-columns: 1fr; }
.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex: 0 0 auto;
}
.sw-empty   { background: #1a1825; }
.sw-stone   { background: #4a4a55; }
.sw-chasm   { background: #000; }
.sw-deco    { background: #3a3540; }
.sw-statue  { background: #6b6675; }
.sw-rubble  { background: #5a4a3a; }
.sw-red     { background: var(--mt-red); }
.sw-blue    { background: var(--mt-blue); }
.sw-green   { background: var(--mt-green); }
.sw-yellow  { background: var(--mt-yellow); }
.sw-grey    { background: var(--mt-grey); }
.sw-trap    { background: #5e2129; }
.sw-flame   { background: var(--mt-flame); }
.sw-start   { background: #ecf0f1; }
.sw-end     { background: var(--mt-purple); }
.sw-erase   { background: repeating-linear-gradient(45deg, #1a1825, #1a1825 3px, #2a2535 3px, #2a2535 6px); }

/* === Tokens panel === */
.mt-token-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.mt-token-btn {
  flex: 1;
  height: 36px;
  font-size: 20px;
  border-radius: 4px;
}
.mt-token-btn.active {
  outline: 2px solid var(--mt-accent);
  outline-offset: 1px;
}
.mt-help {
  font-size: 10px;
  color: var(--mt-muted);
  line-height: 1.4;
}

/* === Timer === */
.mt-timer-display {
  font-size: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--mt-accent);
  text-shadow: 0 0 10px var(--mt-accent-glow);
  margin: 6px 0;
}
.mt-timer-display.expired {
  color: var(--mt-red);
  text-shadow: 0 0 14px rgba(192, 57, 43, 0.6);
}
.mt-timer-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.mt-timer-options button { padding: 4px 0 !important; font-size: 10px; }
.mt-timer-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}
.mt-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--mt-muted);
}

/* === Counters === */
.mt-counter {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mt-counter-value {
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  color: var(--mt-accent);
  min-width: 60px;
  text-align: center;
}
.mt-counter-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  flex: 1;
}
.mt-counter-small {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.mt-counter-small span {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: var(--mt-accent);
  min-width: 28px;
  text-align: center;
}
.mt-broken-msg {
  margin-top: 8px;
  padding: 8px;
  background: rgba(192, 57, 43, 0.15);
  border: 1px solid var(--mt-red);
  color: #ffb3a8;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.05em;
}

/* === Items === */
.mt-items-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.mt-item-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.55;
}
.mt-item-toggle.collected {
  opacity: 1;
  border-color: var(--mt-accent) !important;
  background: rgba(201, 165, 95, 0.12) !important;
}
.mt-muted { color: var(--mt-muted); font-weight: 400; }

/* === Prophecy === */
.mt-prophecy {
  background: var(--mt-bg-3);
  border: 1px solid var(--mt-line);
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--mt-text);
  font-style: italic;
  min-height: 50px;
}
.mt-prophecy.empty { color: var(--mt-muted); font-style: normal; }

/* === Flame controls === */
.mt-flame-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 6px;
}
.mt-flame-controls input {
  width: 50px;
  background: var(--mt-bg-3);
  color: var(--mt-text);
  border: 1px solid var(--mt-line);
  padding: 4px;
  font-family: inherit;
}
.mt-flame-controls button { width: 100%; margin-bottom: 6px; }

/* === Reveals panel === */
.mt-reveal-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto auto auto;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 0;
}
.mt-reveal-row .swatch { width: 14px; height: 14px; }
.mt-reveal-row .mt-reveal-label {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mt-reveal-row .mt-reveal-count {
  color: var(--mt-accent);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: right;
  padding-right: 2px;
}
.mt-reveal-row button {
  padding: 2px 6px !important;
  font-size: 10px !important;
  min-width: 40px;
}

/* === Path Library === */
.mt-path-library {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mt-path-lib-btn {
  text-align: left !important;
  font-size: 11px !important;
}
.mt-path-lib-btn.active {
  background: var(--mt-accent) !important;
  color: #0d0d14 !important;
  border-color: var(--mt-accent) !important;
}

/* === Path Builder === */
.mt-path-list {
  max-height: 360px;
  overflow-y: auto;
  background: var(--mt-bg-3);
  border: 1px solid var(--mt-line);
  border-radius: 3px;
  padding: 4px;
}
.mt-path-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  padding: 2px 4px;
  border-bottom: 1px dashed rgba(58, 53, 72, 0.4);
}
.mt-path-row:last-child { border-bottom: none; }
.mt-path-row.mt-path-bad { color: #ff9d8b; background: rgba(192, 57, 43, 0.1); }
.mt-path-num {
  min-width: 22px;
  color: var(--mt-accent);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.mt-path-cell { flex: 1; }
.mt-path-err { font-size: 9px; color: #ff9d8b; }

/* === Validation modal === */
.mt-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 9, 0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.mt-modal {
  background: var(--mt-bg-2);
  border: 1px solid var(--mt-line-2);
  border-radius: 6px;
  max-width: 720px;
  max-height: 80vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px var(--mt-accent-glow);
}
.mt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--mt-line);
  background: #1a1825;
}
.mt-modal-header h3 {
  color: var(--mt-accent);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}
.mt-modal-body {
  overflow-y: auto;
  padding: 12px 16px;
}
.mt-check-row {
  border-bottom: 1px dashed var(--mt-line);
  padding: 8px 0;
}
.mt-check-row:last-child { border-bottom: none; }
.mt-check-title {
  font-size: 12px;
  color: var(--mt-text);
}
.mt-check-row.bad .mt-check-title { color: #ffb3a8; }
.mt-check-row.ok .mt-check-title { color: #a3d9a3; }
.mt-check-issues {
  margin: 6px 0 0 20px;
  padding-left: 12px;
  font-size: 11px;
  color: var(--mt-muted);
  list-style: disc;
}
.mt-check-issues li { padding: 2px 0; }
.mt-cell-link {
  padding: 1px 5px !important;
  font-size: 10px !important;
  margin-right: 2px;
}

/* === Play tools (DM + player) === */
.mt-play-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.mt-play-tool {
  font-size: 11px !important;
  padding: 6px 8px !important;
  text-align: left !important;
}
.mt-play-tool.active {
  background: var(--mt-accent) !important;
  color: #0d0d14 !important;
  border-color: var(--mt-accent) !important;
}
.mt-player-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  justify-content: center;
}
.mt-player-toolbar .mt-play-tool {
  min-width: 64px;
  text-align: center !important;
}

/* === Flame action panel === */
.mt-flame-action {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(58, 53, 72, 0.4);
}
.mt-flame-action:last-child { border-bottom: none; }
.mt-flame-action-label {
  font-size: 11px;
  color: var(--mt-accent);
  margin-bottom: 4px;
}
.mt-flame-action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.mt-flame-action-btns button {
  font-size: 10px !important;
  padding: 4px 6px !important;
}

/* === Trap effects === */
.mt-trap-effects { display: grid; gap: 4px; }
.mt-trap-effects button {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-align: left;
}

/* === Toast === */
.mt-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7, 7, 11, 0.95);
  border: 1px solid var(--mt-accent);
  color: var(--mt-accent);
  padding: 16px 28px;
  font-size: 20px;
  letter-spacing: 0.1em;
  border-radius: 4px;
  box-shadow: 0 0 30px var(--mt-accent-glow);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.mt-toast.show { opacity: 1; }

/* === Page nav (added in Root) === */
.mt-page-nav {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 100;
  display: flex;
  gap: 4px;
  background: rgba(13, 13, 20, 0.85);
  border: 1px solid var(--mt-line, #2a2535);
  border-radius: 4px;
  padding: 4px;
  backdrop-filter: blur(4px);
}
.mt-page-nav button {
  background: transparent;
  color: #d9d6e0;
  border: 1px solid transparent;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.05em;
}
.mt-page-nav button.active {
  background: #c9a55f;
  color: #0d0d14;
  font-weight: 600;
}
.mt-page-nav button:hover:not(.active) {
  background: rgba(201, 165, 95, 0.15);
}

/* === Player view === */
.mt-player-root {
  position: fixed;
  inset: 0;
  background: #050509;
  display: flex;
  flex-direction: column;
  color: var(--mt-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.mt-player-header {
  padding: 8px 16px;
  background: #0d0d14;
  border-bottom: 1px solid #2a2535;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
}
.mt-player-header .mt-player-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.mt-player-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}
.mt-player-disconnect {
  margin-left: auto;
  color: var(--mt-muted);
  font-size: 11px;
}
.mt-player-disconnect.connected { color: var(--mt-green); }
