:root {
  --bg: #0b0e17;
  --bg-elev: #121726;
  --bg-card: #171e31;
  --bg-soft: #1e2740;
  --ink: #f3efe6;
  --muted: #a9b4cc;
  --gold: #f5c86b;
  --emerald: #5be39b;
  --violet: #b589ff;
  --coral: #f06d5b;
  --cyan: #52e5d4;
  --brass: #e4a84f;
  --border: rgba(245, 200, 107, 0.2);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 15% 0%, #182038 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
}

.page-wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.hero {
  background: linear-gradient(135deg, rgba(26, 34, 56, 0.96), rgba(15, 20, 34, 0.96));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.badge-pill {
  background: rgba(91, 227, 155, 0.14);
  color: var(--emerald);
  border: 1px solid rgba(91, 227, 155, 0.4);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

h1 {
  margin: 0.45rem 0 0.55rem;
  font-family: "Georgia", "Times New Roman", serif;
  font-weight: 600;
  font-size: clamp(1.65rem, 3.1vw, 2.45rem);
  line-height: 1.18;
  color: #fffaf0;
}

.subtitle {
  margin: 0 0 1.1rem;
  color: var(--muted);
  max-width: 980px;
  font-size: 0.98rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.stat-card {
  background: rgba(11, 14, 23, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 0.75rem 0.95rem;
}

.stat-card .k {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-card .v {
  font-size: 1.32rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.stat-card .sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
  align-items: center;
}

button, .btn-link, select {
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid rgba(245, 200, 107, 0.28);
  border-radius: 9px;
  padding: 0.48rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

button:hover, .btn-link:hover, select:hover {
  border-color: var(--gold);
  background: #273354;
}

button.primary {
  background: linear-gradient(135deg, #f5c86b, #dfb04d);
  color: #111522;
  border-color: #f5c86b;
}

button.primary:hover {
  filter: brightness(1.06);
}

button.active-pill {
  background: rgba(82, 229, 212, 0.18);
  border-color: var(--cyan);
  color: var(--cyan);
}

.studio-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.studio-tab {
  text-align: left;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.studio-tab .t-num {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.studio-tab .t-name {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.studio-tab.active {
  background: linear-gradient(135deg, rgba(245, 200, 107, 0.18), rgba(82, 229, 212, 0.12));
  border-color: var(--gold);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.studio-panel {
  display: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
}

.studio-panel.active {
  display: block;
}

.studio-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.studio-header h2 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: 1.4rem;
  color: #fff8ea;
}

.studio-header p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 880px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.1rem;
}

.dual-canvas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  padding: 1rem;
}

.card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.02rem;
  color: var(--gold);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #090c14;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.7rem 0;
}

.slider-group {
  display: grid;
  gap: 0.25rem;
  margin: 0.55rem 0;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  color: var(--muted);
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.readout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.readout {
  background: rgba(9, 12, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
}

.readout .rk {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.readout .rv {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 0.15rem;
}

.mono {
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

.note-box {
  margin-top: 0.8rem;
  padding: 0.75rem 0.95rem;
  background: rgba(245, 200, 107, 0.07);
  border-left: 3px solid var(--gold);
  border-radius: 7px;
  font-size: 0.88rem;
  color: #e6ecf8;
}

/* Polygon Atlas Grid */
.poly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 0.42rem;
  margin-top: 0.75rem;
}

.poly-cell {
  padding: 0.42rem 0.25rem;
  text-align: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid transparent;
  transition: transform 0.12s ease;
}

.poly-cell:hover {
  transform: translateY(-2px);
}

.poly-cell .sub-deg {
  display: block;
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.85;
}

.poly-cell.compass {
  background: rgba(91, 227, 155, 0.15);
  color: var(--emerald);
  border-color: rgba(91, 227, 155, 0.38);
}

.poly-cell.origami_unlocked {
  background: rgba(181, 137, 255, 0.17);
  color: var(--violet);
  border-color: rgba(181, 137, 255, 0.42);
}

.poly-cell.forbidden_o6 {
  background: rgba(240, 109, 91, 0.13);
  color: var(--coral);
  border-color: rgba(240, 109, 91, 0.34);
}

.poly-cell.selected {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  transform: scale(1.05);
}

.tower-step {
  background: rgba(9, 12, 20, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-left: 3px solid var(--cyan);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.axiom-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.axiom-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.68rem;
  background: rgba(9, 12, 20, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 0.82rem;
}

.axiom-item.o6-highlight {
  border-color: var(--violet);
  background: rgba(181, 137, 255, 0.13);
}

.theorems-section {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 0.9rem;
}

.theorem-card {
  background: var(--bg-elev);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  padding: 1rem 1.1rem;
}

.theorem-card h4 {
  margin: 0 0 0.4rem;
  color: var(--gold);
  font-size: 0.96rem;
}

.theorem-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

footer {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--muted);
  font-size: 0.83rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

footer a {
  color: var(--cyan);
}

@media (max-width: 960px) {
  .studio-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col, .dual-canvas-grid {
    grid-template-columns: 1fr;
  }
}
