/* ============================================================
   Matematik ve Geometri Laboratuvarı v8.0 — Light Theme
   ============================================================ */
:root {
  --primary: #2c3e50;
  --accent: #d35400;
  --green: #27ae60;
  --bg: #f8faff;
  --panel: #ffffff;
  --border: #dde3ef;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 4px 24px rgba(44, 62, 80, .10);
  --radius: 16px;
  --stroke-game: #1e293b;
}

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

body {
  font-family: "Inter", "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f4f8 50%, #fef9f0 100%);
  min-height: 100vh;
  color: var(--text);
  padding: 20px 16px 40px;
}

/* ===== XP BAR ===== */
#xp-bar-wrap {
  max-width: 1200px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border-radius: 16px;
  padding: 12px 22px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}

#xp-label {
  font-weight: 800;
  font-size: .9rem;
  color: var(--primary);
  white-space: nowrap;
}

#xp-track {
  flex: 1;
  height: 14px;
  background: #e8efff;
  border-radius: 999px;
  overflow: hidden;
}

#xp-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #3498db);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

#xp-count {
  font-weight: 900;
  font-size: 1rem;
  color: var(--green);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

#xp-level-badge {
  background: linear-gradient(135deg, var(--accent), #e67e22);
  color: #fff;
  font-weight: 900;
  font-size: .8rem;
  padding: 5px 12px;
  border-radius: 999px;
}

/* ===== APP HEADER ===== */
.app-header {
  max-width: 1200px;
  margin: 0 auto 18px;
  text-align: center;
}

.app-header h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 5px;
}

.app-header p {
  color: var(--muted);
  font-size: .9rem;
}

/* ===== MAIN CONTAINER ===== */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--panel);
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(44, 62, 80, .12);
  overflow: hidden;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  padding: 16px 16px 0;
  background: linear-gradient(135deg, #f8faff, #fff8f3);
  border-bottom: 2px solid var(--border);
  gap: 6px;
}

.tab {
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  border-radius: 14px 14px 0 0;
  transition: all .25s;
  font-size: .85rem;
  user-select: none;
  border: 2px solid transparent;
  border-bottom: none;
}

.tab:hover {
  background: #eef2ff;
  color: var(--primary);
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 -4px 14px rgba(44, 62, 80, .18);
}

.tab-content {
  display: none;
  padding: 28px 24px;
  animation: fadeIn .35s;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== SHARED ===== */
.lab-input {
  padding: 11px 16px;
  font-size: 1rem;
  border-radius: 10px;
  border: 2px solid var(--border);
  margin: 4px;
  font-family: inherit;
  transition: border-color .2s;
  outline: none;
  background: #fafbff;
  color: var(--text);
}

.lab-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 62, 80, .08);
}

.lab-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 700;
  font-family: inherit;
  transition: all .2s;
  box-shadow: 0 3px 10px rgba(44, 62, 80, .18);
}

.lab-btn:hover {
  background: #1a252f;
  transform: translateY(-1px);
}

.lab-btn.accent {
  background: var(--accent);
}

.lab-btn.accent:hover {
  background: #b34600;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
}

.section-desc {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 22px;
  line-height: 1.65;
}

/* ===== MODULE 1: CONVERTER ===== */
.converter-controls {
  text-align: center;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.result-area {
  margin-top: 20px;
  padding: 36px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8faff, #fdfcff);
  transition: all .35s;
}

.result-area.has-content {
  border-style: solid;
  border-color: #c5d5f7;
  background: #f4f7ff;
}

.ancient-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  align-items: flex-end;
}

/* Maya */
.maya-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px dashed #c5cee0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(44, 62, 80, .07);
}

.maya-dot {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-block;
  margin: 2px;
}

.maya-bar {
  width: 55px;
  height: 11px;
  background: var(--primary);
  border-radius: 4px;
  margin: 2px 0;
}

.maya-shell {
  width: 40px;
  height: 24px;
  border: 3px solid var(--primary);
  border-radius: 50% 50% 12% 12%;
  position: relative;
}

.maya-shell::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 10%;
  width: 80%;
  height: 50%;
  border-top: 2px solid var(--primary);
  border-radius: 50%;
}

/* Egypt */
.egypt-icon {
  height: 52px;
  width: auto;
  margin: 2px;
}

/* Babylon */
.babylon-group {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
}

.babylon-wedge {
  width: 20px;
  height: 40px;
}

.babylon-corner {
  width: 30px;
  height: 30px;
}

/* Greek Ionic */
.greek-text {
  font-size: 3.4em;
  color: #8e44ad;
  font-weight: 700;
  letter-spacing: 6px;
  line-height: 1.2;
  font-family: serif;
}

/* Roman */
.roman-text {
  font-size: 3.5em;
  font-family: "Times New Roman", serif;
  color: var(--primary);
  font-weight: 700;
}

/* Arabic/Chinese/Korean */
.arabic-text {
  font-size: 3.8em;
  direction: rtl;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 6px;
}

.chinese-text {
  font-size: 3em;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 6px;
}

.korean-text {
  font-size: 2.6em;
  color: #8e44ad;
  font-weight: 700;
  letter-spacing: 4px;
}

/* Binary / Hex */
.binary-text {
  font-size: 2em;
  font-family: "Courier New", monospace;
  color: var(--primary);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 1.4;
  word-break: break-all;
}

.hex-text {
  font-size: 3em;
  font-family: "Courier New", monospace;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 6px;
}

/* Braille */
.braille-output {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.braille-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.braille-cell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  background: #f8faff;
  padding: 8px;
  border-radius: 10px;
  border: 1.5px solid #c5d5f7;
}

.braille-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  border: 1.5px solid #b0bec5;
  transition: background .2s;
}

.braille-dot.on {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(44, 62, 80, .35);
}

.braille-label {
  font-size: .7rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Morse */
.morse-output {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.morse-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.morse-symbols {
  display: flex;
  gap: 3px;
  align-items: center;
}

.morse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.morse-dash {
  width: 28px;
  height: 10px;
  border-radius: 5px;
  background: var(--primary);
}

.morse-char-label {
  font-size: .7rem;
  color: var(--muted);
}

/* Sign Language */
.sign-output {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.sign-digit {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 3.8em;
  line-height: 1;
  gap: 4px;
}

.sign-digit span {
  font-size: .25em;
  color: var(--muted);
}

/* NATO */
.nato-output {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.nato-card {
  background: linear-gradient(135deg, #f0f4f8, #e8f0fe);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  min-width: 80px;
}

.nato-num {
  font-size: 1.6em;
  font-weight: 900;
  color: var(--primary);
}

.nato-word {
  font-size: .78em;
  font-weight: 700;
  color: var(--accent);
}

.nato-info {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff8f0;
  border-left: 4px solid var(--accent);
  font-size: .84rem;
  color: var(--primary);
  line-height: 1.6;
}

.system-desc-box {
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 12px;
  background: #eef2ff;
  color: var(--primary);
  font-size: .84rem;
  font-style: italic;
  border-left: 4px solid var(--primary);
  text-align: left;
}

/* ===== MODULE 2: INFINITY ===== */
.infinity-visual {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  color: #fff;
  padding: 36px 20px;
  border-radius: 22px;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 36px rgba(15, 52, 96, .35);
}

#particleContainer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.viz-icon {
  font-size: 4.5em;
  margin: 10px 0;
  z-index: 2;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(255, 255, 255, .3));
}

/* Scale/zoom wrapper */
#vizZoom {
  transition: transform .6s cubic-bezier(.4, 0, .2, 1);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

#sciNot {
  font-size: 2.8em;
  font-family: "Courier New", monospace;
  z-index: 2;
  font-weight: 900;
  text-shadow: 0 2px 16px rgba(255, 255, 255, .2);
}

#scaleName {
  font-size: 1.6em;
  font-weight: 800;
  z-index: 2;
  margin: 6px 0;
  opacity: .95;
}

.fact-box {
  background: rgba(255, 255, 255, .13);
  padding: 14px 20px;
  border-radius: 14px;
  margin-top: 12px;
  max-width: 620px;
  z-index: 2;
  backdrop-filter: blur(10px);
  text-align: center;
  line-height: 1.7;
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: .9rem;
}

.fact-example {
  font-size: .8em;
  opacity: .75;
  margin-top: 5px;
  font-style: italic;
}

.scale-slider {
  width: 80%;
  cursor: pointer;
  margin: 18px 0;
  accent-color: var(--accent);
  height: 6px;
}

.quick-btns {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-btns .lab-btn {
  padding: 7px 12px;
  font-size: .78rem;
  box-shadow: none;
}

/* Concrete examples */
.scale-examples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.scale-ex-card {
  background: #f8faff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  cursor: pointer;
  transition: all .2s;
}

.scale-ex-card:hover,
.scale-ex-card.active {
  border-color: var(--accent);
  background: #fff4ee;
}

.scale-ex-card .ex-icon {
  font-size: 2em;
}

.scale-ex-card .ex-pow {
  font-weight: 900;
  color: var(--primary);
  font-size: .9rem;
}

.scale-ex-card .ex-name {
  font-size: .75rem;
  color: var(--muted);
}

/* ===== MODULE 3: DETECTIVE ===== */
.det-input-row {
  text-align: center;
  margin-bottom: 8px;
}

.badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
}

.det-badge {
  padding: 13px 18px;
  border-radius: 18px;
  color: white;
  font-size: .9rem;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .13);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 145px;
  transition: transform .2s, box-shadow .2s;
  cursor: default;
}

.det-badge:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
}

.det-badge b {
  font-size: 1em;
}

.det-badge small {
  font-size: .7em;
  opacity: .9;
  margin-top: 4px;
  font-weight: 400;
  text-align: center;
  line-height: 1.4;
}

.badge-prime {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.badge-perfect {
  background: linear-gradient(135deg, #8e44ad, #6c3483);
}

.badge-armstrong {
  background: linear-gradient(135deg, #2980b9, #1a5276);
}

.badge-fibonacci {
  background: linear-gradient(135deg, #d4ac0d, #b7950b);
  color: #1a1a1a;
}

.badge-square {
  background: linear-gradient(135deg, #27ae60, #1e8449);
}

.badge-cube {
  background: linear-gradient(135deg, #16a085, #0e6655);
}

.badge-harshad {
  background: linear-gradient(135deg, #d35400, #a04000);
}

.badge-abundant {
  background: linear-gradient(135deg, #e91e63, #880e4f);
}

.badge-deficient {
  background: linear-gradient(135deg, #607d8b, #37474f);
}

.badge-squarefree {
  background: linear-gradient(135deg, #00897b, #004d40);
}

.badge-palindrome {
  background: linear-gradient(135deg, #5c6bc0, #303f9f);
}

.badge-even {
  background: linear-gradient(135deg, #78909c, #455a64);
}

.badge-odd {
  background: linear-gradient(135deg, #8d6e63, #5d4037);
}

.badge-triangular {
  background: linear-gradient(135deg, #00acc1, #006064);
}

.no-badges {
  color: var(--muted);
  font-size: 1rem;
  padding: 30px;
  text-align: center;
}

/* Visual Proof */
.visual-proof {
  margin-top: 24px;
}

.visual-proof h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
}

.proof-dot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 600px;
  margin: 0 auto;
}

.proof-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #e67e22);
  box-shadow: 0 2px 5px rgba(211, 84, 0, .3);
  animation: popIn .2s ease forwards;
  opacity: 0;
}

@keyframes popIn {
  to {
    opacity: 1;
    transform: scale(1);
  }

  from {
    opacity: 0;
    transform: scale(0.3);
  }
}

.proof-rect-attempt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: .82rem;
  color: var(--muted);
}

.proof-attempt-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.proof-attempt-row .proof-dot {
  width: 14px;
  height: 14px;
}

.proof-label {
  font-size: .78rem;
  color: var(--muted);
  margin-top: 4px;
}

.proof-square-grid {
  display: inline-grid;
  gap: 4px;
  margin: 0 auto;
}

.proof-square-dot {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--green), #1e8449);
  box-shadow: 0 2px 5px rgba(39, 174, 96, .25);
  animation: popIn .2s ease forwards;
  opacity: 0;
}

/* ===== MODULE 4: GEOMETRY GAME ===== */
.game-header {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.game-title h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.game-title p {
  font-size: .8rem;
  color: var(--muted);
  margin: 3px 0 0;
}

.game-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: #f0f4f8;
  border: 1.5px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
}

.game-controls button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}

.game-controls button:hover {
  background: #1a252f;
}

.g-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}

.g-chip b {
  color: var(--primary);
  font-weight: 800;
}

.levels-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.lvlbtn {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: .8rem;
  display: flex;
  gap: 6px;
  align-items: center;
  background: #f0f4f8;
  border: 2px solid var(--border);
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  transition: all .2s;
  color: var(--text);
}

.lvlbtn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.lvlbtn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.lvlbtn .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .25);
  font-size: 11px;
  font-weight: 800;
}

.lvlbtn:not(.active) .pill {
  background: #dde3ef;
  color: var(--primary);
}

.game-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media(max-width:900px) {
  .game-board {
    grid-template-columns: 1fr;
  }
}

.g-panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.g-panel>h2 {
  margin: 0;
  padding: 12px 16px;
  font-size: .88rem;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border);
  background: #f8faff;
}

.g-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media(max-width:520px) {
  .g-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.g-card {
  background: #fafbff;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform .1s, border-color .15s, box-shadow .15s;
  user-select: none;
  cursor: pointer;
}

.g-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(44, 62, 80, .12);
}

.g-card.selected {
  outline: 2.5px solid var(--primary);
  border-color: var(--primary);
  background: #eef2ff;
  box-shadow: 0 0 0 4px rgba(44, 62, 80, .08);
}

.g-card.locked {
  cursor: default;
  border-color: var(--green);
  background: #f0faf4;
  opacity: .93;
}

.g-badge {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: 9px;
  font-weight: 700;
  color: var(--primary);
  background: #e8f0fe;
  border: 1px solid #c5d5f7;
  padding: 3px 7px;
  border-radius: 999px;
}

.g-name {
  font-weight: 800;
  font-size: .82rem;
  text-align: center;
  line-height: 1.25;
  color: var(--primary);
}

.g-hint {
  font-size: .7rem;
  color: var(--muted);
  text-align: center;
}

/* Larger shapes */
.svgwrap {
  width: 110px;
  height: 110px;
}

.svgwrap svg {
  width: 100%;
  height: 100%;
}

.g-stroke {
  stroke: #1e293b;
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.polywrap {
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

canvas.poly3d {
  width: 110px;
  height: 110px;
  border-radius: 12px;
  background: rgba(30, 41, 59, .03);
  border: none;
  touch-action: none;
  display: block;
}

.g-toast {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #f8faff;
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .83rem;
  color: var(--muted);
}

.g-toast .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 3px;
  flex: 0 0 auto;
}

.g-board-locked {
  pointer-events: none;
  filter: blur(1px);
  opacity: .9;
}

@keyframes flashOk {
  0% {
    box-shadow: 0 0 0 rgba(39, 174, 96, 0);
  }

  40% {
    box-shadow: 0 0 0 8px rgba(39, 174, 96, .28);
  }

  100% {
    box-shadow: 0 0 0 rgba(39, 174, 96, 0);
  }
}

@keyframes flashBad {
  0% {
    box-shadow: 0 0 0 rgba(231, 76, 60, 0);
  }

  40% {
    box-shadow: 0 0 0 8px rgba(231, 76, 60, .23);
  }

  100% {
    box-shadow: 0 0 0 rgba(231, 76, 60, 0);
  }
}

.flash-ok {
  animation: flashOk .45s ease;
}

.flash-bad {
  animation: flashBad .45s ease;
}

.g-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, .45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  backdrop-filter: blur(5px);
}

.g-modal-overlay.show {
  display: flex;
}

.g-modal-card {
  width: min(540px, 100%);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 64px rgba(44, 62, 80, .22);
  padding: 24px;
}

.g-modal-title {
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.g-modal-text {
  color: var(--muted);
  font-size: .88rem;
  margin-bottom: 14px;
  line-height: 1.55;
}

.g-modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0 18px;
}

.g-stat-box {
  border: 2px solid var(--border);
  background: #f8faff;
  border-radius: 14px;
  padding: 12px;
}

.g-stat-box .k {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.g-stat-box .v {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--primary);
}

.g-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.g-btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: .95rem;
  font-weight: 900;
  cursor: pointer;
  font-family: inherit;
  min-width: 190px;
  transition: background .2s;
}

.g-btn-primary:hover {
  background: #1a252f;
}

.g-btn-secondary {
  background: #f0f4f8;
  color: var(--primary);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}

.g-btn-secondary:hover {
  border-color: var(--primary);
}

/* ===== MODULE 5: KNOWLEDGE ROOM ===== */
.knowledge-section {
  margin-bottom: 36px;
}

.knowledge-section h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.constants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.const-card {
  background: linear-gradient(135deg, #f8faff, #fff8f3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .2s;
}

.const-card:hover {
  transform: translateY(-3px);
}

.const-symbol {
  font-size: 3em;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
}

.const-name {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.const-value {
  font-family: "Courier New", monospace;
  font-size: .85rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.const-desc {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Pi animation */
.pi-anim-wrap {
  margin-top: 14px;
  overflow: hidden;
  height: 60px;
  position: relative;
}

.pi-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  position: absolute;
  left: 0;
  top: 3px;
  animation: unrollCircle 3s ease-in-out infinite;
}

@keyframes unrollCircle {
  0% {
    border-radius: 50%;
    transform: translateX(0);
  }

  50% {
    border-radius: 50%;
    transform: translateX(20px);
  }

  100% {
    border-radius: 50% 50% 0 0;
    width: 170px;
    height: 4px;
    top: 25px;
    transform: translateX(0);
  }
}

.pi-line {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

/* Flip cards */
.flip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.flip-card {
  width: 100%;
  height: 200px;
  perspective: 900px;
  cursor: pointer;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.4, 0, .2, 1);
}

.flip-card:hover .flip-inner,
.flip-card.flipped .flip-inner {
  transform: rotateY(180deg);
}

.flip-front,
.flip-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.flip-front {
  background: linear-gradient(135deg, var(--primary), #3d5166);
  color: #fff;
  gap: 10px;
  box-shadow: var(--shadow);
}

.flip-front .math-emoji {
  font-size: 3.5em;
  line-height: 1;
}

.flip-front .math-name {
  font-weight: 900;
  font-size: 1rem;
}

.flip-front .math-era {
  font-size: .78rem;
  opacity: .75;
}

.flip-back {
  background: linear-gradient(135deg, var(--accent), #e67e22);
  color: #fff;
  transform: rotateY(180deg);
  box-shadow: var(--shadow);
  gap: 8px;
}

.flip-back .back-label {
  font-size: .75rem;
  font-weight: 700;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.flip-back .back-text {
  font-size: .88rem;
  line-height: 1.5;
}

/* ===== FOOTER ===== */
.signature {
  text-align: center;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 2px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
}

.signature strong {
  color: var(--primary);
  font-weight: 800;
}