/* ============================================================
   ENIGMA Puzzle - Minimal Modern Theme
   Palette: Deep Slate (#0f172a), Soft Grey (#64748b), Blue Accent (#3b82f6)
   Responsive, FontAwesome icons, No Google Fonts/Emojis
============================================================ */

/* ROOT & RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #334155;
  --border:    #475569;
  --accent:    #3b82f6;
  --accent2:   #10b981;
  --accent3:   #f97316;
  --text:      #f1f5f9;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --danger:    #ef4444;
  --font-head: ui-sans-serif, system-ui;
  --font-body: ui-sans-serif, system-ui;
  --font-mono: ui-monospace, monospace;
  --r:         12px;
  --r2:        20px;
  --shadow:    0 8px 48px rgba(0,0,0,.55);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  font-size: 16px;
}

@media (max-width: 640px) {
  html { font-size: 15px; }
}

/* Noise overlay */
body::before {
  content:'';
  position:fixed;
  inset:0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events:none;
  z-index:9999;
  opacity:.4;
}

/* SCREENS */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: clamp(16px, 5vw, 24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease;
  transform: translateY(18px);
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* INTRO SCREEN */
#screen-intro {
  gap: clamp(24px, 6vw, 32px);
  text-align: center;
  max-width: 90vw;
}
.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: clamp(.7rem, 2vw, .85rem);
  color: var(--muted2);
  letter-spacing: .08em;
}
.intro-title {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 10vw, 5rem);
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--text) 40%, var(--muted2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.intro-title span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.intro-sub {
  font-size: clamp(.95rem, 3vw, 1.05rem);
  color: var(--muted2);
  max-width: 380px;
  line-height: 1.6;
}
.intro-levels {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.level-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: clamp(.8rem, 2.5vw, .95rem);
  font-family: var(--font-mono);
  color: var(--muted2);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: var(--r);
  padding: clamp(12px, 4vw, 16px) clamp(24px, 6vw, 32px);
  font-family: var(--font-head);
  font-size: clamp(.95rem, 3vw, 1.05rem);
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
  letter-spacing: -.01em;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.08);
  opacity: 0;
  transition: opacity .15s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #0f172a; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted2); }
.btn-sm { padding: clamp(6px, 2vw, 10px) clamp(12px, 3vw, 20px); font-size: .85rem; }

/* LEVEL HEADER */
.level-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(12px, 4vw, 24px);
  border-bottom: 1px solid var(--border);
  background: rgba(15,23,42,.95);
  backdrop-filter: blur(20px);
  z-index: 100;
}
.level-label {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.level-name {
  font-family: var(--font-head);
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 700;
}
.progress-dots {
  display: flex;
  gap: 6px;
}
.progress-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s;
}
.progress-dots span.done { background: var(--accent); }
.progress-dots span.active { background: var(--accent2); }

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: clamp(24px, 8vw, 48px);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: min(95vw, 560px);
}

/* LEVEL 1 */
#screen-l1 { padding-top: clamp(80px, 20vh, 120px); }
.riddle-num {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .1em;
  margin-bottom: 16px;
}
.riddle-icon-wrap {
  width: clamp(56px, 15vw, 72px); height: clamp(56px, 15vw, 72px);
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  font-size: clamp(1.4rem, 6vw, 2rem);
  color: var(--accent);
}
.riddle-q {
  font-family: var(--font-head);
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 28px;
}
.riddle-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.riddle-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: clamp(.9rem, 3vw, 1rem);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.riddle-input:focus { border-color: var(--accent2); }
.riddle-input.wrong { border-color: var(--danger); animation: shake .3s; }
.riddle-input.correct { border-color: var(--accent); }

@keyframes shake {
  0%,100%{ transform:translateX(0) }
  25%{ transform:translateX(-6px) }
  75%{ transform:translateX(6px) }
}

.clue-area { margin-top: 16px; }
.clue-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.clue-dots { display: flex; gap: 5px; flex-shrink: 0; }
.clue-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background .25s;
}
.clue-dots span.used { background: var(--accent3); }
.clue-text {
  background: var(--surface2);
  border-left: 3px solid var(--accent2);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 12px 16px;
  font-size: clamp(.85rem, 2.5vw, .95rem);
  color: var(--muted2);
  font-family: var(--font-mono);
  line-height: 1.5;
  display: none;
  animation: fadeUp .3s ease;
}
.clue-text.show { display: block; }

@keyframes fadeUp {
  from { opacity:0; transform:translateY(8px) }
  to { opacity:1; transform:translateY(0) }
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 24px;
  font-size: .88rem;
  font-family: var(--font-mono);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 500;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--accent2); color: var(--accent2); }

/* TRANSITION */
#screen-transition {
  gap: clamp(16px, 5vw, 32px);
  text-align: center;
  max-width: 90vw;
}
.trans-icon {
  width: clamp(64px, 18vw, 88px); height: clamp(64px, 18vw, 88px);
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 8vw, 2.5rem);
  margin: 0 auto;
}
.trans-title {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
}
.trans-sub {
  font-family: var(--font-mono);
  font-size: clamp(.85rem, 2.5vw, 1rem);
  color: var(--muted2);
  max-width: 400px;
}
.taunt-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  font-size: clamp(.85rem, 2.5vw, 1rem);
  color: var(--muted2);
  font-family: var(--font-mono);
  max-width: min(95vw, 400px);
  text-align: left;
  position: relative;
}
.taunt-box::before {
  content: '// taunt';
  display: block;
  font-size: .68rem;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: .06em;
}

/* LEVEL 2 */
#screen-l2 { padding-top: clamp(80px, 20vh, 120px); }
.connect-stage {
  position: relative;
  width: 100%;
  max-width: min(95vw, 620px);
  height: clamp(320px, 55vh, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  margin: 0 auto;
}
.connect-stage svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}
.connect-title {
  font-family: var(--font-head);
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
}
.connect-hint {
  font-family: var(--font-mono);
  font-size: clamp(.75rem, 2.5vw, .9rem);
  color: var(--muted);
  margin-bottom: 16px;
  text-align: center;
}
.node {
  position: absolute;
  width: 54px; height: 54px;
  border-radius: 12px;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  font-size: 1.2rem;
  color: var(--accent2);
  z-index: 5;
  user-select: none;
  transition: border-color .2s, transform .15s;
}
.node:hover { border-color: var(--accent2); transform: scale(1.08); }
.node.dragging { cursor: grabbing; border-color: var(--accent); z-index: 10; }
.node.connected { border-color: var(--accent); color: var(--accent); }
.node.source { cursor: crosshair; }

.target-zone {
  position: absolute;
  width: 54px; height: 54px;
  border-radius: 12px;
  border: 2px dashed var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--muted);
  z-index: 3;
  transition: all .2s;
}
.target-zone.highlight { border-color: var(--accent2); color: var(--accent2); }
.target-zone.connected { 
  border-color: var(--accent); 
  color: var(--accent); 
  background: rgba(59,130,246,.08); 
}

.obstacle {
  position: absolute;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .7rem;
  font-family: var(--font-mono);
  letter-spacing: .05em;
  z-index: 4;
}

.portal {
  position: absolute;
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 2px solid var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent2);
  font-size: 1.1rem;
  z-index: 4;
  animation: portalPulse 2s ease-in-out infinite;
  cursor: default;
}

@keyframes portalPulse {
  0%,100%{ box-shadow: 0 0 0 0 rgba(16,185,129,.3) }
  50%{ box-shadow: 0 0 0 12px rgba(16,185,129,0) }
}

.connect-instruction {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: clamp(.75rem, 2.5vw, .88rem);
  color: var(--muted);
  margin-top: clamp(8px, 3vw, 16px);
  justify-content: center;
}

/* LEVEL 3 */
#screen-l3 { padding-top: clamp(80px, 20vh, 120px); }
.elusive-stage {
  position: relative;
  width: 100%;
  max-width: min(95vw, 580px);
  height: clamp(300px, 50vh, 400px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  margin: 0 auto;
  cursor: default;
}
.elusive-title-text {
  font-family: var(--font-head);
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  margin-bottom: 6px;
  text-align: center;
}
.elusive-hint {
  font-family: var(--font-mono);
  font-size: clamp(.75rem, 2.5vw, .95rem);
  color: var(--muted);
  margin-bottom: 16px;
  text-align: center;
}

.run-btn {
  position: absolute;
  padding: clamp(8px, 2.5vw, 12px) clamp(18px, 5vw, 28px);
  background: var(--accent);
  color: #0f172a;
  border: none;
  border-radius: 10px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(.9rem, 3vw, 1rem);
  cursor: pointer;
  transition: background .15s;
  z-index: 10;
}
.run-btn:hover { background: #60a5fa; }

.decoy-btn {
  position: absolute;
  padding: clamp(8px, 2.5vw, 12px) clamp(18px, 5vw, 28px);
  background: var(--surface2);
  color: var(--muted2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(.9rem, 3vw, 1rem);
  cursor: pointer;
  transition: all .15s;
  z-index: 10;
}
.decoy-btn:hover { border-color: var(--muted2); color: var(--text); }

.bg-trigger {
  position: absolute;
  width: 44px; height: 44px;
  border-radius: 10px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.05);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: .9rem;
  transition: all .2s;
  z-index: 5;
}
.bg-trigger:hover {
  background: rgba(59,130,246,.08);
  border-color: var(--accent);
  color: var(--accent);
}

.combo-indicator {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 20;
}
.combo-key {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: clamp(.65rem, 2vw, .8rem);
  color: var(--muted);
  transition: all .2s;
}
.combo-key.pressed {
  background: var(--accent);
  color: #0f172a;
  border-color: var(--accent);
}

/* END SCREEN */
#screen-end {
  gap: 0;
  text-align: center;
  overflow: auto;
  padding: clamp(60px, 20vh, 100px) 24px clamp(40px, 10vh, 60px);
}
.end-confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -20px;
  animation: confettiFall linear forwards;
  border-radius: 2px;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.end-crown {
  font-size: clamp(2.8rem, 12vw, 4.5rem);
  margin-bottom: 24px;
  animation: crownBounce .6s ease;
  display: block;
}
@keyframes crownBounce {
  0%{ transform: scale(0) rotate(-20deg) }
  60%{ transform: scale(1.25) rotate(5deg) }
  100%{ transform: scale(1) rotate(0) }
}
.end-title {
  font-family: var(--font-head);
  font-size: clamp(2rem, 9vw, 4rem);
  font-weight: 800;
  line-height: .95;
  letter-spacing: -.04em;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleReveal .8s ease .2s both;
}
@keyframes titleReveal {
  from { opacity:0; transform:translateY(24px) }
  to { opacity:1; transform:translateY(0) }
}
.end-sub {
  font-size: clamp(.95rem, 3vw, 1.2rem);
  color: var(--muted2);
  margin-bottom: clamp(24px, 8vw, 40px);
  max-width: min(95vw, 500px);
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
  animation: titleReveal .8s ease .35s both;
}
.end-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: clamp(24px, 8vw, 48px);
  flex-wrap: wrap;
  animation: titleReveal .8s ease .5s both;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: clamp(16px, 5vw, 24px);
  min-width: clamp(100px, 25vw, 140px);
}
.stat-num {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 8vw, 2.4rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: clamp(.65rem, 2vw, .85rem);
  color: var(--muted);
  letter-spacing: .08em;
}
.end-quote {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  padding: clamp(16px, 5vw, 24px);
  max-width: min(95vw, 520px);
  margin: 0 auto clamp(24px, 8vw, 48px);
  font-family: var(--font-mono);
  font-size: clamp(.85rem, 2.5vw, 1.05rem);
  color: var(--muted2);
  line-height: 1.6;
  text-align: left;
  animation: titleReveal .8s ease .65s both;
}
.end-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  animation: titleReveal .8s ease .8s both;
}

/* UTILITIES */
.hidden { display: none !important; }
.flex-col { flex-direction: column; }
.mt-16 { margin-top: 16px; }

/* Grid pattern */
.grid-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* Glow blobs */
.glow-blob {
  position: fixed;
  width: 400px; height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .07;
  pointer-events: none;
  z-index: 0;
}
.blob-1 { background: var(--accent); top: -100px; left: -100px; }
.blob-2 { background: var(--accent2); bottom: -100px; right: -100px; }

/* Animations */
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,.4) }
  100% { box-shadow: 0 0 0 24px rgba(59,130,246,0) }
}
.pulse { animation: pulseRing .6s ease-out; }

.wire-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 8 4;
  animation: wireDash 1s linear infinite;
}
.wire-path.connected {
  stroke: var(--accent);
  animation: none;
  stroke-dasharray: none;
}
@keyframes wireDash {
  to { stroke-dashoffset: -24; }
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(59,130,246,.15);
  animation: ripple .5s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}
@keyframes ripple {
  from { width:0;height:0;opacity:1; }
  to { width:120px;height:120px;margin:-60px;opacity:0; }
}
