/* ==========================================================================
 * Prison Match 5: Tower of Equations — Cold-Steel Magnetic Equation Rack
 * Unified Apple-Grade Motion · GPU-Composited · Dark Obsidian & Light Porcelain
 * ========================================================================== */

.toe-arena {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(305px, 0.88fr);
  gap: 18px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

/* Top Target & Phase Telemetry Strip */
.toe-banner {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 18px;
  border-radius: var(--dp-radius-md);
  background: var(--dp-surface-card);
  border: 1px solid var(--dp-border);
  box-shadow: var(--dp-shadow-card);
  transition: border-color var(--dp-dur-base) var(--dp-ease-apple);
}

.toe-banner.is-undercut {
  border-color: var(--dp-amber);
}

.toe-banner.is-executing {
  border-color: var(--dp-cyan);
}

.toe-banner.is-success {
  border-color: var(--dp-emerald);
}

.toe-banner.is-fail {
  border-color: var(--dp-crimson);
}

.toe-headline {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--dp-ink);
}

.toe-target-cluster {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toe-target-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--dp-surface-input);
  border: 1px solid var(--dp-border-strong);
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--dp-ink-muted);
}

.toe-target-pill strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--dp-brass-bright);
  line-height: 1;
}

.toe-target-pill.is-height strong {
  color: var(--dp-cyan);
}

.toe-target-pill.is-moves strong {
  color: var(--dp-amber);
}

/* Main Cold-Steel 4-Column Magnetic Rack */
.toe-rack-card {
  position: relative;
  border-radius: var(--dp-radius-lg);
  background:
    radial-gradient(ellipse 75% 55% at 50% 10%, var(--dp-brass-glow) 0%, transparent 62%),
    var(--dp-surface-card);
  border: 1px solid var(--dp-border);
  box-shadow: var(--dp-shadow-card);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 540px;
}

.toe-rack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--dp-ink-muted);
}

/* 4 Columns Container with Laser Height Gridlines */
.toe-columns-stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 12px 12px 34px;
  border-radius: 14px;
  background: var(--dp-surface-input);
  border: 1px solid var(--dp-border-subtle);
  min-height: 396px;
  align-items: end;
}

/* Calibrated Laser Height Lines (1F..6F) */
.toe-laser-lines {
  position: absolute;
  inset: 16px 12px 66px 8px;
  pointer-events: none;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 6px;
}

.toe-laser-row {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
}

.toe-laser-row::after {
  content: "";
  position: absolute;
  left: 26px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--dp-border-subtle);
  opacity: 0.7;
}

.toe-laser-row.is-target-line::after {
  height: 2px;
  background: var(--dp-cyan);
  opacity: 0.85;
}

.toe-laser-tag {
  width: 22px;
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  font-weight: 700;
  color: var(--dp-ink-faint);
  text-align: right;
  padding-right: 4px;
}

.toe-laser-row.is-target-line .toe-laser-tag {
  color: var(--dp-cyan);
  font-weight: 800;
}

/* Individual Magnetic Column */
.toe-col {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.toe-col-stack {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 6px;
  min-height: 300px;
  padding: 8px 6px 6px;
  border-radius: 11px;
  background: var(--dp-surface-row);
  border: 1.5px solid var(--dp-border-subtle);
  transition: border-color var(--dp-dur-fast) var(--dp-ease-apple),
    background-color var(--dp-dur-fast) var(--dp-ease-apple);
}

.toe-col.is-source .toe-col-stack {
  border-color: var(--dp-brass-bright);
  background: var(--dp-brass-glow);
}

.toe-col.is-drop-ready .toe-col-stack {
  border-style: dashed;
  border-color: var(--dp-cyan);
  cursor: pointer;
}

.toe-col.is-drop-ready .toe-col-stack:hover {
  background: rgba(56, 189, 248, 0.12);
}

.toe-col.is-matched .toe-col-stack {
  border-color: var(--dp-emerald);
  background: rgba(34, 197, 94, 0.1);
}

/* Chamfered Metal Equation Blocks */
.toe-block {
  position: relative;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border: 1.5px solid transparent;
  user-select: none;
  transition: transform var(--dp-dur-fast) var(--dp-ease-spring),
    border-color var(--dp-dur-fast) var(--dp-ease-apple),
    opacity var(--dp-dur-fast) var(--dp-ease-apple);
}

.toe-block.is-clickable {
  cursor: pointer;
}

.toe-block.is-clickable:hover {
  transform: translateY(-2px);
}

.toe-block.is-selected {
  transform: translateY(-4px) scale(1.03);
  border-color: #ffffff;
  z-index: 3;
}

/* Pure Number Blocks (2, 3, 5, 7) — Brushed Brass Gold */
.toe-block.is-num {
  background: linear-gradient(155deg, #e5c47c 0%, #b48636 100%);
  color: #0b0d14;
  border-color: rgba(255, 236, 190, 0.72);
}

/* Add/Sub Operator Blocks (+1..+5, -1..-3) — Cold Industrial Cyan */
.toe-block.is-addsub {
  background: linear-gradient(155deg, #1b364d 0%, #0f1f30 100%);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.45);
}

/* Mul/Div Operator Blocks (×2..×4, ÷2) — High-Voltage Crimson */
.toe-block.is-muldiv {
  background: linear-gradient(155deg, #4b1721 0%, #260a10 100%);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.5);
}

/* Ghost Stack Preview Block (Normal vs Flipped Upside-Down) */
.toe-block.is-ghost {
  opacity: 0.62;
  border-style: dashed;
  border-color: var(--dp-cyan);
  pointer-events: none;
}

.toe-block-badge {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.72;
}

/* Column Foot Readout (Live Expression & Exact Value) */
.toe-col-foot {
  border-radius: 9px;
  padding: 6px 8px;
  background: var(--dp-surface-tile);
  border: 1px solid var(--dp-border-subtle);
  text-align: center;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.toe-col-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: var(--dp-ink-muted);
}

.toe-col-val {
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 800;
  color: var(--dp-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toe-col-val.is-match {
  color: var(--dp-emerald);
}

.toe-col-val.is-invalid {
  color: var(--dp-ink-faint);
  font-weight: 600;
  font-size: 11px;
}

/* Execution Drop Toolbar (Normal vs Flipped Upside-Down) */
.toe-move-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--dp-surface-tile);
  border: 1px solid var(--dp-border-strong);
  min-height: 58px;
}

.toe-flip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1.5px solid var(--dp-border-strong);
  background: var(--dp-surface-btn);
  color: var(--dp-ink);
  font-size: 12.5px;
  font-weight: 700;
  transition: border-color var(--dp-dur-fast) var(--dp-ease-apple),
    background-color var(--dp-dur-fast) var(--dp-ease-apple),
    color var(--dp-dur-fast) var(--dp-ease-apple),
    transform var(--dp-dur-instant) var(--dp-ease-apple);
}

.toe-flip-toggle:active {
  transform: scale(0.97);
}

.toe-flip-toggle.is-flipped {
  border-color: var(--dp-amber);
  background: rgba(245, 158, 11, 0.18);
  color: var(--dp-amber);
}

.toe-drop-btns {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Right Control & Score Column */
.toe-side-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.toe-card {
  border-radius: var(--dp-radius-md);
  background: var(--dp-glass);
  border: 1px solid var(--dp-border);
  padding: 15px;
  box-shadow: var(--dp-shadow-card);
  backdrop-filter: blur(10px);
}

/* Reserve stable console height to keep Scoreboard & Log CLS = 0 */
.toe-card[data-motion-key="toe-console-card"] {
  min-height: 295px;
  display: flex;
  flex-direction: column;
}

.toe-card-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dp-brass);
  margin: 0 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toe-bid-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 10px 0 12px;
}

.toe-bid-chip {
  min-height: 38px;
  border-radius: 9px;
  border: 1px solid var(--dp-border);
  background: var(--dp-surface-btn);
  color: var(--dp-ink);
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
  transition: border-color var(--dp-dur-fast) var(--dp-ease-apple),
    background-color var(--dp-dur-fast) var(--dp-ease-apple),
    color var(--dp-dur-fast) var(--dp-ease-apple),
    transform var(--dp-dur-instant) var(--dp-ease-apple);
}

.toe-bid-chip:hover:not(:disabled) {
  border-color: var(--dp-brass);
}

.toe-bid-chip:active:not(:disabled) {
  transform: scale(0.96);
}

.toe-bid-chip.is-selected {
  border-color: var(--dp-brass-bright);
  background: var(--dp-brass-glow);
  color: var(--dp-brass-bright);
}

.toe-score-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.toe-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--dp-surface-row);
  border: 1px solid var(--dp-border-subtle);
  font-size: 13px;
  color: var(--dp-ink);
  transition: border-color var(--dp-dur-base) var(--dp-ease-apple),
    background-color var(--dp-dur-base) var(--dp-ease-apple);
}

.toe-score-row.is-active {
  border-color: var(--dp-brass-bright);
  background: var(--dp-brass-glow);
}

.toe-score-num {
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 800;
  color: var(--dp-brass-bright);
}

.toe-score-num.is-neg {
  color: var(--dp-crimson-bright);
}

/* Solution Replay Box */
.toe-solution-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--dp-surface-input);
  border: 1px dashed var(--dp-border-strong);
  font-family: var(--dp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--dp-ink-muted);
  line-height: 1.55;
}

.toe-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 165px;
  overflow-y: auto;
  font-size: 12px;
}

.toe-log-row {
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--dp-surface-row);
  border-left: 2px solid var(--dp-border-strong);
  color: var(--dp-ink-muted);
}

.toe-log-row.is-good {
  border-left-color: var(--dp-emerald);
  background: rgba(34, 197, 94, 0.1);
  color: var(--dp-emerald);
}

.toe-log-row.is-alert {
  border-left-color: var(--dp-crimson);
  background: rgba(220, 53, 69, 0.1);
  color: var(--dp-crimson-bright);
}

/* Light Porcelain Studio Refinements */
:root[data-theme="light"] .toe-block.is-num {
  background: linear-gradient(155deg, #d8b263 0%, #9a6e1f 100%);
  color: #ffffff;
  border-color: #7a5410;
}

:root[data-theme="light"] .toe-block.is-addsub {
  background: linear-gradient(155deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0369a1;
  border-color: #38bdf8;
}

:root[data-theme="light"] .toe-block.is-muldiv {
  background: linear-gradient(155deg, #ffe4e6 0%, #fecdd3 100%);
  color: #9f1239;
  border-color: #fb7185;
}

:root[data-theme="light"] .toe-block.is-selected {
  border-color: #14171f;
}

@media (max-width: 960px) {
  .toe-arena {
    grid-template-columns: 1fr;
  }
  .toe-columns-stage {
    gap: 8px;
    padding: 12px 8px 10px 28px;
  }
  .toe-block {
    height: 38px;
    font-size: 15px;
  }
  .toe-laser-row {
    height: 38px;
  }
  .toe-rack-card {
    padding: 12px;
    min-height: auto;
  }
  .toe-card[data-motion-key="toe-console-card"] {
    min-height: auto;
  }
}
