:root {
  --bg-color: #1A0F0A;
  --panel-bg: #2B1810;
  --panel-border: #4A281A;
  
  --primary: #E17055;
  --primary-glow: rgba(225, 112, 85, 0.4);
  --primary-hover: #ff8b6b;
  
  --secondary: #FDCB6E;
  --accent: #00CEC9;
  
  --text-main: #F5F6FA;
  --text-muted: #8c7e77;
  
  --success: #00b894;
  --danger: #d63031;
  
  --border-rad: 12px;
  --font-mono: 'JetBrains Mono', monospace;
  --font-logo: 'Righteous', cursive;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Typography Utilities */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-20 { margin-top: 20px; }

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Cheat Sheet */
.cheat-sheet {
  background-color: var(--panel-bg);
  border-right: 2px solid var(--primary);
  width: 300px;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  box-shadow: 5px 0 15px rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.cheat-sheet.collapsed {
  transform: translateX(-300px);
}

.toggle-btn {
  position: absolute;
  right: -40px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 120px;
  background-color: var(--primary);
  color: var(--bg-color);
  border: none;
  border-radius: 0 8px 8px 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-logo);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 3px 0 10px var(--primary-glow);
  transition: background 0.2s;
}
.toggle-btn:hover {
  background-color: var(--primary-hover);
}
.cheat-sheet.collapsed .toggle-btn span {
  transform: rotate(0deg);
}
.cheat-sheet:not(.collapsed) .toggle-btn span {
  transform: rotate(180deg);
}

.cheat-content {
  padding: 20px;
  overflow-y: auto;
  height: 100%;
}

.cheat-content h2 {
  color: var(--secondary);
  font-size: 14px;
  margin: 20px 0 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.cheat-content h2:first-child { margin-top: 0; }

.cheat-content ul {
  list-style: none;
  font-size: 12px;
  color: var(--text-muted);
}
.cheat-content li {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cheat-content code {
  background: rgba(0,0,0,0.3);
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--accent);
  border: 1px solid rgba(0, 206, 201, 0.2);
  min-width: 45px;
  text-align: center;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: linear-gradient(to bottom, rgba(26,15,10,0.9) 0%, transparent 100%);
  z-index: 10;
}

.logo {
  font-family: var(--font-logo);
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
  font-size: 28px;
  letter-spacing: 2px;
}

.nav-links {
  display: flex;
  gap: 15px;
}
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: var(--border-rad);
  transition: all 0.2s;
}
.nav-btn:hover {
  color: var(--text-main);
}
.nav-btn.active {
  color: var(--secondary);
  border-color: rgba(253, 203, 110, 0.3);
  background: rgba(253, 203, 110, 0.1);
}

/* Screens */
.screens-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.screen {
  position: absolute;
  width: 100%;
  max-width: 800px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(20px);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  position: relative;
}

/* Common Card Style */
.menu-card, .stats-card, .creator-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-rad);
  padding: 40px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 20px rgba(225, 112, 85, 0.05);
}

.menu-card h2, .stats-card h2, .creator-card h2 {
  font-family: var(--font-logo);
  color: var(--text-main);
  font-size: 36px;
  margin-bottom: 20px;
}
.menu-card p {
  color: var(--text-muted);
  margin-bottom: 40px;
  line-height: 1.6;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

/* Buttons */
.btn {
  font-family: var(--font-mono);
  font-weight: 700;
  border: none;
  border-radius: var(--border-rad);
  padding: 12px 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn:active {
  transform: scale(0.95);
}
.btn-primary {
  background-color: var(--primary);
  color: var(--bg-color);
  box-shadow: 0 0 15px var(--primary-glow);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 0 25px var(--primary-glow);
}
.btn-large {
  font-size: 18px;
  padding: 16px 40px;
}
.btn-secondary {
  background-color: transparent;
  color: var(--secondary);
  border: 2px solid var(--secondary);
}
.btn-secondary:hover {
  background-color: rgba(253, 203, 110, 0.1);
}
.btn-danger {
  background-color: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background-color: rgba(214, 48, 49, 0.1);
}
.btn-text {
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
}
.btn-text:hover { color: var(--text-main); }

/* Arena (Gameplay) */
.arena-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.arena-stats {
  display: flex;
  gap: 30px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}

.stat-box .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-box .value {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-logo);
}
.stat-box.big .value {
  font-size: 36px;
}

.difficulty-badge {
  background: rgba(225, 112, 85, 0.1);
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 6px 15px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.challenge-board {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-rad);
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}

/* scanline effect over board */
.challenge-board::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 1;
}

#challenge-title {
  font-size: 24px;
  color: var(--text-main);
  margin-bottom: 10px;
}
#challenge-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 30px;
}

.test-cases {
  display: flex;
  gap: 20px;
  position: relative;
  z-index: 2;
}
.case-col {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.05);
}
.col-title {
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 15px;
  border-bottom: 1px dashed rgba(255,255,255,0.1);
  padding-bottom: 10px;
}

.case-list {
  list-style: none;
  font-size: 16px;
}
.case-list li {
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  position: relative;
}

/* Regex Highlighting Magic */
.highlight {
  background-color: rgba(0, 206, 201, 0.3);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}
.highlight.error {
  background-color: rgba(214, 48, 49, 0.3);
  color: var(--danger);
  text-decoration: line-through;
}

/* Match States */
li.state-pass { 
  border-left: 3px solid var(--success);
  background: linear-gradient(90deg, rgba(0,184,148,0.1) 0%, transparent 100%);
}
li.state-fail { 
  border-left: 3px solid var(--danger);
  background: linear-gradient(90deg, rgba(214,48,49,0.1) 0%, transparent 100%);
}

.input-area {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.regex-wrapper {
  display: flex;
  align-items: center;
  background: #111;
  border: 2px solid var(--panel-border);
  border-radius: var(--border-rad);
  padding: 0 20px;
  box-shadow: inset 0 3px 10px rgba(0,0,0,0.5);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.regex-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: inset 0 3px 10px rgba(0,0,0,0.5), 0 0 15px rgba(225, 112, 85, 0.2);
}
.regex-wrapper.shake {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
  border-color: var(--danger);
}

.regex-slash {
  color: var(--primary);
  font-size: 24px;
  font-weight: 800;
  user-select: none;
}

.regex-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 24px;
  padding: 20px 10px;
  outline: none;
}
.regex-input::placeholder {
  color: rgba(255,255,255,0.1);
}

.hint-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
}
.hint-text {
  color: var(--secondary);
  font-size: 14px;
  background: rgba(253, 203, 110, 0.1);
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(253, 203, 110, 0.3);
}
.hidden { display: none !important; }

/* In-game Overlay (Level Clear) */
.game-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(26, 15, 10, 0.9);
  backdrop-filter: blur(5px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-rad);
  text-align: center;
}
.game-overlay h2 {
  font-family: var(--font-logo);
  font-size: 48px;
  color: var(--success);
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(0,184,148,0.5);
}
.game-overlay p {
  color: var(--secondary);
  font-size: 20px;
  margin-bottom: 30px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  text-align: left;
}

/* Creator Form */
.form-group {
  display: flex;
  flex-direction: column;
  text-align: left;
  margin-bottom: 20px;
}
.form-group label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.form-group textarea {
  background: #111;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-family: var(--font-mono);
  padding: 15px;
  border-radius: 8px;
  resize: vertical;
  outline: none;
}
.form-group textarea:focus {
  border-color: var(--secondary);
}
.creator-results {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
  font-size: 14px;
  min-height: 80px;
}

/* Animations */
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

@media (max-width: 900px) {
  .cheat-sheet {
    position: absolute;
    height: 100%;
  }
  .test-cases {
    flex-direction: column;
  }
  .regex-input { font-size: 18px; }
  .arena-stats { gap: 10px; }
}
