:root {
  --bg-gradient: linear-gradient(135deg, #0f0c20 0%, #1a103c 100%);
  --card-bg: rgba(255, 255, 255, 0.96);
  --border-glow: #8b5cf6;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --green-primary: #7c3aed;
  --green-hover: #6d28d9;
  --green-shadow: #5b21b6;
  
  --blue-tile: #2563eb;
  --blue-shadow: #1d4ed8;
  
  --cue-bg: #fffbe3;
  --cue-border: #f59e0b;
  --cue-text: #78350f;
  
  --success: #16a34a;
  --error: #dc2626;
  
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

body.wh-body {
  background: var(--bg-gradient);
  min-height: 100vh;
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 24px 16px;
  display: flex;
  justify-content: center;
}

.wh-shell {
  width: 100%;
  max-width: 820px;
}

/* =====================================
   TOP BAR & HEADER
====================================== */
.wh-topbar {
  display: grid;
  grid-template-columns: 100px 1fr 100px;
  align-items: center;
  margin-bottom: 28px;
}

.arcade-back-btn {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
  width: fit-content;
}

.arcade-back-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  transform: translateX(-2px);
}

.wh-marquee {
  text-align: center;
}

.wh-marquee span {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #6ee7b7;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.wh-marquee h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.05rem;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 0 12px rgba(167, 139, 250, 0.6);
  line-height: 1.4;
}

.wh-brand {
  color: #ffffff;
  text-decoration: none;
  font-weight: 900;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  padding: 8px 14px;
  border-radius: 12px;
  justify-self: end;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* =====================================
   MAIN CARD CONTAINER
====================================== */
.wh-main-card {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(139, 92, 246, 0.2);
  backdrop-filter: blur(10px);
}

/* =====================================
   STATS HEAD
====================================== */
.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 28px;
  border: 1px solid #e2e8f0;
}

.mini-label, .score-box span {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  display: block;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-head strong {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-primary);
}

.score-box {
  text-align: center;
}

.score-box strong {
  color: var(--green-primary);
  font-size: 1.4rem;
}

/* =====================================
   STEP SECTIONS & TITLES
====================================== */
.step-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.step-title span {
  background: var(--green-primary);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 900;
}

.instruction {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 16px 0;
  font-weight: 500;
}

/* =====================================
   STEP 1: QUESTION BUILDER
====================================== */
.answer-line {
  min-height: 60px;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.answer-line:focus-within {
  border-color: var(--green-primary);
}

.empty-message {
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.9rem;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  min-height: 46px;
}

/* TILES */
.tile {
  background: #ffffff;
  color: var(--text-primary);
  border: 2px solid #0f172a;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 0 #0f172a;
  transition: all 0.1s ease;
}

.tile:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #0f172a;
}

.tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0f172a;
}

.tile.used {
  opacity: 0.25;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.selected-tile {
  background: #eff6ff;
  border-color: var(--blue-tile);
  color: var(--blue-tile);
  box-shadow: 0 3px 0 var(--blue-shadow);
}

/* DIVIDER */
.section-divider {
  border: none;
  border-top: 1px dashed #e2e8f0;
  margin: 28px 0;
}

/* =====================================
   STEP 2: TARGET CUE & INPUT
====================================== */
.cue-box {
  background: var(--cue-bg);
  border: 1.5px solid var(--cue-border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cue-label {
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--cue-text);
  background: rgba(245, 158, 11, 0.2);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.cue-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--cue-text);
}

.answer-form {
  display: flex;
  gap: 10px;
}

.answer-input {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  outline: none;
  transition: all 0.2s;
}

.answer-input:focus:not(:disabled) {
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.answer-input:disabled {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

/* =====================================
   BUTTONS
====================================== */
.primary-btn, .check-btn, .submit-btn {
  background: var(--green-primary);
  color: #ffffff;
  border: none;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--green-shadow);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.primary-btn:hover:not(:disabled), 
.check-btn:hover:not(:disabled), 
.submit-btn:hover:not(:disabled) {
  background: var(--green-hover);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--green-shadow);
}

.primary-btn:active:not(:disabled), 
.check-btn:active:not(:disabled), 
.submit-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--green-shadow);
}

.primary-btn:disabled, .check-btn:disabled, .submit-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* =====================================
   FEEDBACK
====================================== */
.feedback {
  font-weight: 700;
  font-size: 0.88rem;
  margin-top: 10px;
  min-height: 20px;
}

.feedback.good {
  color: var(--success);
}

.feedback.bad {
  color: var(--error);
}

/* =====================================
   RESPONSIVE LAYOUT
====================================== */
@media (max-width: 640px) {
  .wh-topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    justify-items: center;
  }
  
  .arcade-back-btn, .wh-brand {
    justify-self: center;
  }

  .wh-main-card {
    padding: 20px;
  }

  .answer-form {
    flex-direction: column;
  }

  .submit-btn {
    width: 100%;
  }
}


/* ========== UNIFIED GRAMMAR BACK BUTTON ========== */
.back-button,
a.back-button,
button.back-button,
.arcade-back-btn.back-button,
.arcade-back-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  height: auto !important;
  min-height: 40px !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  border: 1px solid #dcefe9 !important;
  background: #ffffff !important;
  color: #202636 !important;
  text-decoration: none !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  box-shadow: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
}

.back-button:hover,
a.back-button:hover,
button.back-button:hover,
.arcade-back-btn:hover {
  border-color: #079d73 !important;
  background: #ffffff !important;
  color: #202636 !important;
  box-shadow: 0 6px 16px rgba(7, 157, 115, 0.12) !important;
  transform: translateY(-1px) !important;
  filter: none !important;
}

.back-button:focus-visible,
.arcade-back-btn:focus-visible {
  outline: 3px solid rgba(7, 157, 115, 0.28) !important;
  outline-offset: 2px !important;
}

html[data-theme="dark"] .back-button,
html[data-theme="dark"] .arcade-back-btn,
body:not(.light-mode) .back-button,
body.dark-mode .back-button {
  background: #17201c !important;
  border-color: #24463b !important;
  color: #eef5f1 !important;
}

html[data-theme="dark"] .back-button:hover,
body:not(.light-mode) .back-button:hover,
body.dark-mode .back-button:hover {
  border-color: #079d73 !important;
  box-shadow: 0 6px 16px rgba(7, 157, 115, 0.2) !important;
}

@media (max-width: 700px) {
  .back-button,
  .arcade-back-btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    min-height: 36px !important;
    border-radius: 10px !important;
  }
}
/* ========== END UNIFIED BACK BUTTON ========== */
