/* ═══════════════════════════════════════════════════════ */
/*  AGENTIC TETRIS — Playful Geometric Design System       */
/* ═══════════════════════════════════════════════════════ */
/*
 * TABLE OF CONTENTS:
 *
 *  1. BASE LAYER
 *    1.1  CSS Variables  (colors, shadows, fonts, blocks)
 *    1.2  Reset / HTML body
 *    1.3  Animated Blob Background
 *    1.4  Noise Grain Overlay
 *    1.5  Glass Card
 *
 *  2. UI COMPONENTS
 *    2.1  Buttons  (neu-btn, primary, danger, small)
 *    2.2  Switch Toggle
 *    2.3  Slider / Range
 *    2.4  Inputs / Selects / Textareas
 *    2.5  Screen System  (show/hide)
 *
 *  3. SCREENS
 *    3.1  Intro Splash  (<KD/> parallax)
 *    3.2  Credits — Star Wars Scroll
 *    3.3  Intro Screen  (logo + loading bar)
 *    3.4  Menu Screen  (7 buttons with reveal)
 *    3.5  Settings Screen
 *    3.6  Achievements Screen
 *    3.7  AI Setup Screen
 *    3.8  Game Screen — HUD
 *    3.9  Game Screen — Content Layout (1P / 2P)
 *    3.10 Game Screen — Typing Zone / Input
 *    3.11 Game Screen — Board Overlay / Pause / Game Over
 *    3.12 FAQ Screen
 *    3.13 How It Works Screen  (flow diagram)
 *    3.14 Credits Screen
 *
 *  4. RESPONSIVE
 *    4.1  Tablet  (768–1023px)
 *    4.2  Mobile  (≤767px)
 *    4.3  Small Mobile  (≤480px)
 *    4.4  Ultra Small  (≤360px)
 *
 *  5. ANIMATIONS / KEYFRAMES
 *    5.1  blob-move  (8 variants)
 *    5.2  kd-pulse, start-pulse, credits-roll, glow-pulse
 *    5.3  cooldown-ring, shimmer, scanline
 *    5.4  fadeIn, slideUp, slideUpFade
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@300;400;700&display=swap');

/* ═══════════════════════════════════════════════════════ */
/*  INTRO SPLASH — <KD/> Parallax                          */
/* ═══════════════════════════════════════════════════════ */

#intro-splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  cursor: pointer;
  perspective: 1200px;
  overflow: hidden;
}

#intro-kd {
  position: relative;
  z-index: 1;
  transform-style: preserve-3d;
  transition: transform 1.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 1s ease;
}

#intro-kd-tag {
  font-family: "Outfit", "Inter", sans-serif;
  font-size: clamp(5rem, 18vw, 16rem);
  font-weight: 800;
  color: var(--accent);
  text-shadow:
    4px 4px 0px #1E293B,
    8px 8px 0px rgba(139, 92, 246, 0.3);
  cursor: pointer;
  user-select: none;
  animation: kd-pulse 3s ease-in-out infinite alternate;
  transition: font-variation-settings 0.4s ease, text-shadow 0.4s ease;
}

#intro-kd-tag:hover {
  font-variation-settings: "wght" 100;
  text-shadow:
    2px 2px 0px #1E293B,
    4px 4px 0px rgba(139, 92, 246, 0.3);
}

#intro-start {
  display: block;
  font-family: "Outfit", "Inter", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--text-primary);
  text-align: center;
  margin: 28px auto 0;
  padding: 10px 32px;
  background: var(--bg-surface);
  border: 2px solid #1E293B;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  animation: start-pulse 2s ease-in-out infinite;
  transition: all 0.2s var(--ease-spring);
}

#intro-start:hover {
  background: var(--tertiary);
  border-color: #1E293B;
  box-shadow: var(--shadow-hard-hover);
  transform: translate(-2px, -2px);
  color: #1E293B;
}

#intro-start:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-hard-active);
}

@keyframes start-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.8; }
}

#intro-splash.parallax-out #intro-kd {
  transform: translateZ(-600px) scale(2.5) rotateX(15deg);
  opacity: 0;
}

#intro-splash.parallax-out #intro-start {
  opacity: 0;
  transition: opacity 0.4s ease;
}

#intro-splash.parallax-out {
  background: transparent;
  pointer-events: none;
  transition: background 1s ease 0.4s;
}

@keyframes kd-pulse {
  0% { filter: brightness(1) drop-shadow(0 0 10px rgba(255,255,255,0.2)); }
  100% { filter: brightness(1.1) drop-shadow(0 0 25px rgba(196,181,253,0.4)); }
}

/* ═══════════════════════════════════════════════════════ */
/*  CREDITS — Star Wars Scroll + Lower Third                */
/* ═══════════════════════════════════════════════════════ */

.credits-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.credits-perspective {
  position: absolute;
  inset: 0;
  perspective: 350px;
  overflow: hidden;
}

.credits-scroll {
  position: absolute;
  bottom: -120vh;
  left: 50%;
  width: 700px;
  max-width: 90vw;
  transform: translateX(-50%) rotateX(22deg);
  transform-origin: center 120%;
  animation: credits-roll 50s linear forwards;
  padding-bottom: 30vh;
}

@keyframes credits-roll {
  0% { transform: translateX(-50%) rotateX(22deg) translateY(0); }
  100% { transform: translateX(-50%) rotateX(22deg) translateY(-200vh); }
}

.credits-header {
  text-align: center;
  margin-bottom: 80px;
}

.credits-star {
  font-size: 52px;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  margin-bottom: 20px;
  animation: credits-star-glow 2s ease-in-out infinite alternate;
}

@keyframes credits-star-glow {
  0% { text-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }
  100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.3); }
}

.credits-title {
  font-family: var(--font-heading);
  font-size: 54px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 4px 4px 0px #1E293B;
  margin-bottom: 12px;
}

.credits-subtitle {
  font-family: var(--font-body);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--secondary);
}

.credits-section {
  text-align: center;
  margin-bottom: 60px;
}

.credits-role {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.credits-name {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.credits-detail {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.credits-spacer {
  height: 60px;
}

.credits-lowerthird {
  text-align: center;
  opacity: 0;
  animation: lowerthird-in 1.5s ease-out 24s forwards;
}

@keyframes lowerthird-in {
  0% { opacity: 0; transform: translateY(30px); }
  20% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

.lowerthird-bar {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.lowerthird-event {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.05em;
}

.lowerthird-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
}

.lowerthird-social {
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

.lowerthird-x {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.lowerthird-url {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.credits-back-btn {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

:root {
  --bg-primary: #FFFDF5;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --glass: rgba(255, 255, 255, 0.9);
  --glass-hover: rgba(255, 255, 255, 1);
  --border-glass: #E2E8F0;
  --border-accent: #8B5CF6;
  --accent: #8B5CF6;
  --accent-dim: rgba(139, 92, 246, 0.6);
  --glow: rgba(139, 92, 246, 0.35);
  --glow-soft: rgba(139, 92, 246, 0.1);
  --text-primary: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --danger: #F472B6;
  --danger-dim: rgba(244, 114, 182, 0.15);
  --warning: #FBBF24;
  --success: #34D399;
  --purple: #8B5CF6;
  --secondary: #F472B6;
  --tertiary: #FBBF24;
  --quaternary: #34D399;
  --shadow-hard: 4px 4px 0px 0px #1E293B;
  --shadow-hard-lg: 8px 8px 0px 0px #E2E8F0;
  --shadow-hard-hover: 6px 6px 0px 0px #1E293B;
  --shadow-hard-active: 2px 2px 0px 0px #1E293B;
  --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --block-I: rgba(165, 214, 255, 0.4);
  --block-O: rgba(255, 241, 118, 0.4);
  --block-T: rgba(206, 147, 255, 0.4);
  --block-S: rgba(129, 227, 173, 0.4);
  --block-Z: rgba(255, 154, 154, 0.4);
  --block-J: rgba(144, 164, 255, 0.4);
  --block-L: rgba(255, 204, 128, 0.4);
  --border-I: rgba(165, 214, 255, 0.7);
  --border-O: rgba(255, 241, 118, 0.7);
  --border-T: rgba(206, 147, 255, 0.7);
  --border-S: rgba(129, 227, 173, 0.7);
  --border-Z: rgba(255, 154, 154, 0.7);
  --border-J: rgba(144, 164, 255, 0.7);
  --border-L: rgba(255, 204, 128, 0.7);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════ */
/*  ANIMATED BLOB BACKGROUND                               */
/* ═══════════════════════════════════════════════════════ */

@keyframes blob-move {
  100% {
    transform: translate3d(0, 0, 1px) rotate(360deg);
  }
}

.background {
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
  background: var(--bg-primary);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.ball {
  position: absolute;
  width: 20vmin;
  height: 20vmin;
  border-radius: 50%;
  backface-visibility: hidden;
  animation: blob-move linear infinite;
  filter: blur(60px);
}

.ball:nth-child(odd) {
  color: rgba(139, 92, 246, 0.15);
}

.ball:nth-child(even) {
  color: rgba(244, 114, 182, 0.12);
}

.ball:nth-child(1) {
  top: 77%;
  left: 88%;
  animation-duration: 40s;
  animation-delay: -3s;
  transform-origin: 16vw -2vh;
  box-shadow: 40vmin 0 5.703076368487546vmin currentColor;
}
.ball:nth-child(2) {
  top: 42%;
  left: 2%;
  animation-duration: 53s;
  animation-delay: -29s;
  transform-origin: -19vw 21vh;
  box-shadow: -40vmin 0 5.17594621519026vmin currentColor;
}
.ball:nth-child(3) {
  top: 28%;
  left: 18%;
  animation-duration: 49s;
  animation-delay: -8s;
  transform-origin: -22vw 3vh;
  box-shadow: 40vmin 0 5.248179047256236vmin currentColor;
}
.ball:nth-child(4) {
  top: 50%;
  left: 79%;
  animation-duration: 26s;
  animation-delay: -21s;
  transform-origin: -17vw -6vh;
  box-shadow: 40vmin 0 5.279749632220298vmin currentColor;
}
.ball:nth-child(5) {
  top: 46%;
  left: 15%;
  animation-duration: 36s;
  animation-delay: -40s;
  transform-origin: 4vw 0vh;
  box-shadow: -40vmin 0 5.964309466052033vmin currentColor;
}
.ball:nth-child(6) {
  top: 77%;
  left: 16%;
  animation-duration: 31s;
  animation-delay: -10s;
  transform-origin: 18vw 4vh;
  box-shadow: 40vmin 0 5.178483653434181vmin currentColor;
}
.ball:nth-child(7) {
  top: 22%;
  left: 17%;
  animation-duration: 55s;
  animation-delay: -6s;
  transform-origin: 1vw -23vh;
  box-shadow: -40vmin 0 5.703026794398318vmin currentColor;
}
.ball:nth-child(8) {
  top: 41%;
  left: 47%;
  animation-duration: 43s;
  animation-delay: -28s;
  transform-origin: 25vw -3vh;
  box-shadow: 40vmin 0 5.196265905749415vmin currentColor;
}

#bg-grid { display: none; }
#bg-particles { display: none; }

/* ═══════════════════════════════════════════════════════ */
/*  NOISE GRAIN OVERLAY                                    */
/* ═══════════════════════════════════════════════════════ */

.grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.015;
  background: 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.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ═══════════════════════════════════════════════════════ */
/*  GLASS CARD                                             */
/* ═══════════════════════════════════════════════════════ */

.glass-card {
  background: var(--bg-surface);
  border: 2px solid #1E293B;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard-lg);
  transition: all 0.3s var(--ease-spring);
}

.glass-card:hover {
  box-shadow: 10px 10px 0px 0px #E2E8F0;
  transform: rotate(-0.5deg) scale(1.01);
}

/* ═══════════════════════════════════════════════════════ */
/*  BUTTONS — macOS Micro-interactions                     */
/* ═══════════════════════════════════════════════════════ */

.neu-btn {
  background: var(--bg-surface);
  border: 2px solid #1E293B;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-hard);
}

.neu-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(139,92,246,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.neu-btn:hover {
  background: var(--tertiary);
  border-color: #1E293B;
  box-shadow: var(--shadow-hard-hover);
  transform: translate(-2px, -2px);
}

.neu-btn:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-hard-active);
  transition-duration: 0.08s;
}

.neu-btn:hover::after {
  opacity: 1;
}

.primary-btn {
  background: var(--accent);
  border-color: #1E293B;
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: var(--shadow-hard);
}

.primary-btn:hover {
  background: #7C3AED;
  box-shadow: var(--shadow-hard-hover);
  transform: translate(-2px, -2px);
}

.primary-btn:active {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-hard-active);
}

.danger-btn {
  background: var(--danger);
  border-color: #1E293B;
  color: #FFFFFF;
}

.danger-btn:hover {
  background: #EC4899;
  box-shadow: var(--shadow-hard);
}

.small-btn {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--radius-full);
}

/* ═══════════════════════════════════════════════════════ */
/*  SWITCH                                                 */
/* ═══════════════════════════════════════════════════════ */

.neu-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.neu-switch input { display: none; }

.neu-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: #E2E8F0;
  border: 2px solid #1E293B;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
}

.neu-switch-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.3s var(--ease-spring);
}

.neu-switch input:checked + .neu-switch-slider {
  background: var(--quaternary);
  border-color: #1E293B;
}

.neu-switch input:checked + .neu-switch-slider::after {
  left: 23px;
  background: #FFFFFF;
}

/* ═══════════════════════════════════════════════════════ */
/*  SLIDER                                                 */
/* ═══════════════════════════════════════════════════════ */

.neu-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.neu-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 6px;
  border-radius: var(--radius-full);
  background: #E2E8F0;
  border: 1px solid #1E293B;
  outline: none;
  transition: background 0.2s;
}

.neu-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1E293B;
  cursor: pointer;
  transition: transform 0.2s var(--ease-spring);
}

.neu-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-value {
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 36px;
}

/* ═══════════════════════════════════════════════════════ */
/*  INPUTS                                                 */
/* ═══════════════════════════════════════════════════════ */

.neu-input, .neu-select, .neu-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: all 0.25s var(--ease-out);
}

.neu-input:focus, .neu-select:focus, .neu-textarea:focus {
  border-color: var(--accent);
  box-shadow: 4px 4px 0px 0px var(--accent);
}

.neu-select {
  cursor: pointer;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231E293B' fill='none' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.neu-select option {
  background: #FFFFFF;
  color: var(--text-primary);
}

.neu-textarea {
  resize: vertical;
  min-height: 80px;
}

/* ═══════════════════════════════════════════════════════ */
/*  SCREENS                                                */
/* ═══════════════════════════════════════════════════════ */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-out), visibility 0.4s;
  z-index: 50;
  overflow-y: auto;
  padding: 20px;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 28px;
}

/* ═══════════════════════════════════════════════════════ */
/*  INTRO SCREEN                                           */
/* ═══════════════════════════════════════════════════════ */

.intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  position: relative;
  z-index: 60;
}

.desktop-notice-content {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 60;
}

.desktop-notice-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  opacity: 0;
  animation: fadeInNotice 1.5s ease 0.5s forwards, fadeOutNotice 1.5s ease 3.5s forwards;
}

@keyframes fadeInNotice {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOutNotice {
  from { opacity: 1; }
  to { opacity: 0; }
}

.logo-placeholder {
  padding: 48px 64px;
  text-align: center;
}

.logo-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 52px;
  letter-spacing: -2px;
  line-height: 1.05;
  color: var(--accent);
  text-shadow: 4px 4px 0px #1E293B;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.loading-bar-container {
  padding: 20px 30px;
  width: 320px;
}

.loading-bar {
  width: 100%;
  height: 6px;
  background: #E2E8F0;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid #1E293B;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.3s var(--ease-out);
}

.loading-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 10px;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════ */
/*  MENU SCREEN                                            */
/* ═══════════════════════════════════════════════════════ */

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 420px;
  width: 100%;
  position: relative;
  z-index: 60;
}

.menu-logo {
  padding: 28px 44px;
  text-align: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.menu-logo .logo-text {
  font-size: 38px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-full);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out), background 0.2s var(--ease-spring), box-shadow 0.2s var(--ease-spring);
}

.menu-btn.reveal {
  opacity: 1;
  transform: translateY(0);
}

.menu-logo.reveal {
  opacity: 1;
  transform: translateY(0);
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent);
  flex-shrink: 0;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: #FFFFFF;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.btn-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  font-family: var(--font-mono);
}

/* ═══════════════════════════════════════════════════════ */
/*  SETTINGS SCREEN                                        */
/* ═══════════════════════════════════════════════════════ */

.settings-content {
  padding: 36px;
  max-width: 500px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  position: relative;
  z-index: 60;
}

.settings-group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 2px solid #E2E8F0;
}

.settings-group:last-of-type {
  border-bottom: none;
}

.settings-group-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--tertiary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 16px;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.setting-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.setting-icon svg {
  width: 16px;
  height: 16px;
  stroke: #FFFFFF;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back-btn {
  margin-top: 24px;
  padding: 10px 20px;
  font-size: 13px;
  align-self: flex-start;
}

/* ═══════════════════════════════════════════════════════ */
/*  ACHIEVEMENTS SCREEN                                    */
/* ═══════════════════════════════════════════════════════ */

.achievements-content {
  max-width: 800px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 60;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
}

.achieve-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 2px solid #1E293B;
  transition: all 0.3s var(--ease-spring);
  box-shadow: var(--shadow-hard);
}

.achieve-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hard-hover);
}

.achieve-card.locked {
  opacity: 0.35;
  filter: grayscale(0.8);
}

.achieve-card.unlocked {
  border-color: var(--accent);
  box-shadow: 6px 6px 0px 0px var(--accent);
}

.achieve-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent);
  margin-bottom: 10px;
}

.achieve-icon svg {
  width: 20px;
  height: 20px;
  stroke: #FFFFFF;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.achieve-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.achieve-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.achieve-progress {
  margin-top: 10px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.achieve-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 2px;
  transition: width 0.5s var(--ease-out);
}

/* ═══════════════════════════════════════════════════════ */
/*  AI SETUP SCREEN                                        */
/* ═══════════════════════════════════════════════════════ */

.ai-setup-content {
  max-width: 900px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 60;
}

.ai-setup-panels {
  display: flex;
  gap: 20px;
  width: 100%;
  align-items: stretch;
}

.ai-panel {
  flex: 1;
  padding: 24px;
}

.panel-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

.panel-field {
  margin-bottom: 14px;
}

.panel-field label {
  display: block;
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vs-divider span {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 36px;
  color: var(--secondary);
  text-shadow: 4px 4px 0px #1E293B;
}

.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  text-align: center;
}

.mode-btn.active {
  background: var(--accent);
  border-color: #1E293B;
  color: #FFFFFF;
  box-shadow: var(--shadow-hard);
}

.ai-config.hidden {
  display: none;
}

.compatibility-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  font-size: 12px;
  margin-bottom: 14px;
}

.compat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.3s var(--ease-out);
}

.compatibility-badge.testing .compat-dot {
  background: var(--warning);
  animation: pulse-dot 1s infinite;
}

.compatibility-badge.testing .compat-text {
  color: var(--warning);
}

.compatibility-badge.compatible .compat-dot {
  background: var(--quaternary);
}

.compatibility-badge.compatible .compat-text {
  color: var(--quaternary);
}

.compatibility-badge.incompatible .compat-dot {
  background: var(--secondary);
}

.compatibility-badge.incompatible .compat-text {
  color: var(--secondary);
}

.ai-setup-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.ai-setup-actions .primary-btn {
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.ai-disclaimer {
  margin-top: 4px;
  padding: 10px 16px;
  font-size: 11px;
  line-height: 1.5;
  color: #94A3B8;
  text-align: center;
  border-top: 1px solid rgba(148,163,184,0.15);
  max-width: 520px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* ═══════════════════════════════════════════════════════ */
/*  GAME SCREEN                                            */
/* ═══════════════════════════════════════════════════════ */

.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 1280px;
  height: 100%;
  max-height: 100%;
  padding: 0 24px;
  box-sizing: border-box;
  position: relative;
  z-index: 60;
  overflow: visible;
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  width: 100%;
  max-width: 1280px;
  box-sizing: border-box;
  overflow: hidden;
  flex-shrink: 0;
}

.hud-left {
  display: flex;
  gap: 20px;
  flex-shrink: 1;
  min-width: 0;
}

.hud-score, .hud-level, .hud-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.hud-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
}

.hud-center {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: center;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.leaderboard-box {
  padding: 8px 14px;
  min-width: 240px;
  max-width: 320px;
  text-align: center;
  background: #FFFFFF;
  border: 2px solid #1E293B;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard);
  overflow: hidden;
}

.leaderboard-header {
  margin-bottom: 6px;
}

.leaderboard-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--tertiary);
  text-transform: uppercase;
}

.leaderboard-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 110px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(139,92,246,0.06);
  transition: all 0.4s var(--ease-spring);
}

.leaderboard-row.lb-exit {
  opacity: 0;
  transform: translateX(-20px);
}

.leaderboard-row.lb-enter {
  opacity: 0;
  transform: translateX(20px);
}

.leaderboard-row.lb-enter.lb-show {
  opacity: 1;
  transform: translateX(0);
}

.lb-rank {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  color: var(--accent);
  min-width: 20px;
  text-align: right;
}

.lb-rank.lb-rank-gold { color: #F59E0B; }
.lb-rank.lb-rank-silver { color: #94A3B8; }
.lb-rank.lb-rank-bronze { color: #D97706; }

.lb-name {
  flex: 1;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-xp {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.lb-xp.high-xp { color: var(--quaternary); font-weight: 600; }

.leaderboard-dots {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
}

.lb-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-glass);
  transition: all 0.3s var(--ease-spring);
}

.lb-dot.active {
  background: var(--tertiary);
  transform: scale(1.3);
}

.next-label {
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: 1px;
}

.hud-right {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

.hud-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.hud-btn svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud-btn:hover svg {
  stroke: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════ */
/*  GAME CONTENT LAYOUT (Player columns side by side)          */
/* ═══════════════════════════════════════════════════════════════ */

.game-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: stretch;
  width: 100%;
  max-width: 1280px;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
}

/* 2P mode: two player columns side by side + VS badge */
.game-content.two-player {
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  padding-top: 16px;
}

.player-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 0;
}

.game-content:not(.two-player) .player-column {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.game-content:not(.two-player) .input-slot {
  width: 280px;
  justify-content: center;
}

.game-content.two-player .player-column {
  gap: 20px;
}

.game-content.two-player .input-slot {
  border-top: 1px solid #E2E8F0;
  padding-top: 20px;
  margin-top: 8px;
}

.player-column.hidden {
  display: none;
}

.board-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.board-slot.hidden {
  display: none;
}

.board-slot canvas {
  display: block;
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border: 2px solid #1E293B;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hard-lg);
  transition: border-color 0.3s;
}

.board-slot canvas:hover {
  border-color: var(--accent);
}

.input-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.input-slot.hidden {
  display: none;
}

.input-slot .typing-zone {
  width: 100%;
}

.input-slot .ai-info-card {
  width: 100%;
}

.player-label {
  padding: 6px 16px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.3px;
  border: 2px solid #1E293B;
}

.p1-board .player-label { color: var(--accent); border-color: #1E293B; background: rgba(139, 92, 246, 0.1); }
.p2-board .player-label { color: var(--secondary); border-color: #1E293B; background: rgba(244, 114, 182, 0.1); }

.ai-info-card {
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  border-radius: var(--radius-md);
}

.ai-info-model {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}

.ai-info-stats {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.vs-badge {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 44px;
  color: var(--secondary);
  text-shadow: 4px 4px 0px #1E293B;
  align-self: center;
  padding: 40px 0;
  letter-spacing: -1px;
}

/* ═══════════════════════════════════════════════════════ */
/*  TYPING ZONE — Word Input for Piece Spawning           */
/* ═══════════════════════════════════════════════════════ */

.typing-zone {
  width: 100%;
  padding: 12px 16px;
  margin-top: 10px;
  box-sizing: border-box;
  transition: all 0.3s var(--ease-out);
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-md);
  background: #FFFFFF;
}

.typing-zone.active {
  border-color: var(--accent);
  box-shadow: 4px 4px 0px 0px var(--accent);
}

.typing-zone.waiting {
  border-color: var(--tertiary);
  background: rgba(251, 191, 36, 0.05);
}

.typing-zone.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.typing-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.typing-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.typing-input {
  flex: 1;
  background: #F8FAFC;
  border: 2px solid #CBD5E1;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 8px 12px;
  outline: none;
  transition: all 0.2s var(--ease-out);
  caret-color: var(--accent);
}

.typing-input:focus {
  border-color: var(--accent);
  box-shadow: 4px 4px 0px 0px var(--accent);
}

.typing-input.ai-typing {
  caret-color: var(--tertiary);
}

.typing-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 1px;
  font-size: 14px;
}

.piece-preview {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: #F1F5F9;
  border: 2px solid #1E293B;
  border: 2px solid #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-spring);
  flex-shrink: 0;
}

.piece-preview.matched {
  border-color: var(--accent);
  box-shadow: 4px 4px 0px 0px var(--accent);
}

.preview-letter {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-secondary);
  transition: all 0.3s var(--ease-out);
}

.piece-preview.matched .preview-letter {
  color: var(--accent);
}

.typing-status {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  min-height: 16px;
  transition: all 0.2s var(--ease-out);
}

.typing-status.verifying {
  color: var(--tertiary);
}

.typing-status.valid {
  color: var(--quaternary);
}

.typing-status.invalid {
  color: var(--secondary);
}

.typing-status.ai-thinking {
  color: var(--accent);
}

.cooldown-overlay {
  display: none;
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.cooldown-overlay.active {
  display: flex;
}
.cooldown-ring {
  position: absolute;
  inset: 0;
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}
.cooldown-ring circle {
  fill: none;
  stroke: rgba(244, 114, 182, 0.3);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.3s linear;
}
.cooldown-overlay.active .cooldown-ring circle {
  animation: cooldown-countdown 3s linear forwards;
}
@keyframes cooldown-countdown {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: 125.66; }
}
.cooldown-number {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: var(--secondary);
}
.cooldown-overlay.cooldown-flash {
  animation: cooldown-pulse 0.3s ease;
}
@keyframes cooldown-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes typing-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-input.ai-typing {
  animation: none;
}

/* ═══════════════════════════════════════════════════════ */
.board-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.85);
  border-radius: var(--radius-md);
  z-index: 10;
}

.board-overlay.visible {
  display: flex;
}

.overlay-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 32px;
  color: var(--accent);
  text-shadow: 4px 4px 0px #1E293B;
}

.pause-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.8);
  z-index: 100;
}

.pause-overlay.hidden { display: none; }

.pause-card {
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.pause-card h2 {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 32px;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.gameover-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.85);
  z-index: 100;
}

.gameover-overlay.hidden { display: none; }

.gameover-card {
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  min-width: 320px;
}

.gameover-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 32px;
  color: var(--accent);
  letter-spacing: -0.5px;
  text-shadow: 4px 4px 0px #1E293B;
}

.gameover-score {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gameover-label {
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.gameover-value {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 48px;
  color: var(--accent);
}

.gameover-narrative {
  display: flex;
  gap: 12px;
  width: 100%;
}

.gameover-narrative.hidden { display: none; }

.narrative-card {
  flex: 1;
  padding: 14px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
  border-radius: var(--radius-md);
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
}

.gameover-actions {
  display: flex;
  gap: 12px;
}

.gameover-actions .primary-btn {
  padding: 12px 28px;
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════ */
/*  FAQ SCREEN                                             */
/* ═══════════════════════════════════════════════════════ */

.faq-content {
  padding: 36px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  z-index: 60;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.faq-item {
  padding: 16px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  border: 2px solid #1E293B;
  transition: all 0.3s var(--ease-spring);
  box-shadow: var(--shadow-hard);
}

.faq-item:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hard-hover);
}

.faq-q {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 8px;
  cursor: pointer;
}

.faq-a {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.faq-a a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.faq-a a:hover {
  color: var(--secondary);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════ */
/*  HOW IT WORKS SCREEN                                    */
/* ═══════════════════════════════════════════════════════ */

.how-it-works-content {
  padding: 36px;
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 60;
}

.how-it-works-subtitle {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════════════════════ */
/*  HOW IT WORKS — Animated Flow Diagram                    */
/* ═══════════════════════════════════════════════════════ */

.flow-diagram {
  position: relative;
  padding: 24px 8px;
  margin-bottom: 24px;
  overflow: hidden;
}

.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  margin-bottom: 4px;
}

.flow-row-human { margin-bottom: 4px; }
.flow-row-engine { margin-bottom: 4px; }
.flow-row-ai { margin-bottom: 12px; }
.flow-row-post { justify-content: center; margin-top: 0; }

/* ── Flow Nodes ─────────────────────────────────────── */
.flow-node {
  background: #FFFFFF;
  border: 2px solid #1E293B;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: center;
  min-width: 110px;
  max-width: 140px;
  box-shadow: var(--shadow-hard);
  position: relative;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s var(--ease-spring);
  animation: flowNodePop 0.5s var(--ease-spring) both;
  animation-delay: var(--delay, 0s);
  flex-shrink: 1;
}

.flow-node:hover {
  transform: translate(-2px, -2px) scale(1.03);
  box-shadow: var(--shadow-hard-hover);
  z-index: 10;
}

@keyframes flowNodePop {
  0% { opacity: 0; transform: scale(0.7) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.flow-node-icon {
  font-size: 24px;
  margin-bottom: 6px;
  line-height: 1;
}

.flow-node-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.flow-node-desc {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.flow-node-desc em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.flow-node-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  font-family: var(--font-heading);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1.5px solid #1E293B;
  white-space: nowrap;
  box-shadow: 2px 2px 0px #1E293B;
}

.flow-badge-pink { background: var(--secondary); color: #FFF; }
.flow-badge-red { background: var(--danger); color: #FFF; }

/* ── Node color accents (left border) ───────────────── */
.flow-player { border-left: 4px solid var(--accent); }
.flow-typing { border-left: 4px solid var(--accent); }
.flow-verify { border-left: 4px solid var(--secondary); }
.flow-spawn { border-left: 4px solid var(--quaternary); }
.flow-gravity { border-left: 4px solid var(--tertiary); }
.flow-input { border-left: 4px solid var(--accent); }
.flow-collision { border-left: 4px solid var(--secondary); }
.flow-phase1 { border-left: 4px solid var(--tertiary); }
.flow-api { border-left: 4px solid var(--quaternary); }
.flow-phase2 { border-left: 4px solid var(--accent); }
.flow-execute { border-left: 4px solid var(--quaternary); }
.flow-narrative { border-left: 4px solid var(--tertiary); }

/* ── Flow Arrows ────────────────────────────────────── */
.flow-arrow {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 1;
  width: 36px;
  position: relative;
  animation: flowNodePop 0.4s var(--ease-spring) both;
  animation-delay: var(--delay, 0s);
}

.flow-arrow-dash {
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    #1E293B 0px,
    #1E293B 4px,
    transparent 4px,
    transparent 8px
  );
  animation: flowDashMove 1s linear infinite;
}

@keyframes flowDashMove {
  0% { background-position: 0 0; }
  100% { background-position: 8px 0; }
}

.flow-arrow-head {
  font-size: 10px;
  color: #1E293B;
  font-weight: 900;
  line-height: 1;
}

.flow-arrow-ai .flow-arrow-dash {
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0px,
    var(--accent) 4px,
    transparent 4px,
    transparent 8px
  );
}

.flow-arrow-ai .flow-arrow-head {
  color: var(--accent);
}

/* ── Vertical Connectors ────────────────────────────── */
.flow-connector-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 24px;
  position: relative;
  z-index: 2;
}

.flow-vert-line {
  flex: 1;
  width: 2px;
  background: repeating-linear-gradient(
    180deg,
    #1E293B 0px,
    #1E293B 4px,
    transparent 4px,
    transparent 8px
  );
  animation: flowVertDashMove 1s linear infinite;
}

@keyframes flowVertDashMove {
  0% { background-position: 0 0; }
  100% { background-position: 0 8px; }
}

.flow-vert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1E293B;
  flex-shrink: 0;
  animation: flowPulse 2s ease-in-out infinite;
}

.flow-vert-dot-ai {
  background: var(--tertiary);
}

@keyframes flowPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(139,92,246,0.4); }
  50% { transform: scale(1.3); box-shadow: 0 0 0 6px rgba(139,92,246,0); }
}

/* ── Loop-back Arrows ───────────────────────────────── */
.flow-loop-section {
  display: flex;
  justify-content: center;
  gap: 80px;
  margin: 8px 0;
  position: relative;
  z-index: 2;
}

.flow-loop-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.flow-loop-line {
  width: 2px;
  height: 18px;
  background: repeating-linear-gradient(
    180deg,
    #1E293B 0px,
    #1E293B 3px,
    transparent 3px,
    transparent 6px
  );
  animation: flowVertDashMove 1s linear infinite;
}

.flow-loop-head {
  font-size: 8px;
  color: #1E293B;
  font-weight: 900;
  line-height: 1;
}

.flow-loop-label {
  font-family: var(--font-heading);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.flow-loop-human .flow-loop-line {
  background: repeating-linear-gradient(
    180deg,
    var(--accent) 0px,
    var(--accent) 3px,
    transparent 3px,
    transparent 6px
  );
}

.flow-loop-human .flow-loop-head { color: var(--accent); }

.flow-loop-ai .flow-loop-line {
  background: repeating-linear-gradient(
    180deg,
    var(--tertiary) 0px,
    var(--tertiary) 3px,
    transparent 3px,
    transparent 6px
  );
}

.flow-loop-ai .flow-loop-head { color: var(--tertiary); }

/* ── Animated Flow Particles ────────────────────────── */
.flow-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.flow-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0;
}

.fp1 {
  background: var(--accent);
  animation: flowParticlePath1 6s ease-in-out infinite;
  animation-delay: 0s;
}

.fp2 {
  background: var(--secondary);
  animation: flowParticlePath2 7s ease-in-out infinite;
  animation-delay: 1.5s;
}

.fp3 {
  background: var(--tertiary);
  animation: flowParticlePath3 5s ease-in-out infinite;
  animation-delay: 3s;
}

.fp4 {
  background: var(--quaternary);
  animation: flowParticlePath4 8s ease-in-out infinite;
  animation-delay: 0.8s;
}

@keyframes flowParticlePath1 {
  0%   { left: 5%;  top: 8%;  opacity: 0; }
  10%  { opacity: 0.7; }
  50%  { left: 50%; top: 45%; opacity: 0.5; }
  90%  { opacity: 0.7; }
  100% { left: 90%; top: 85%; opacity: 0; }
}

@keyframes flowParticlePath2 {
  0%   { left: 90%; top: 10%; opacity: 0; }
  10%  { opacity: 0.6; }
  50%  { left: 40%; top: 50%; opacity: 0.4; }
  90%  { opacity: 0.6; }
  100% { left: 10%; top: 90%; opacity: 0; }
}

@keyframes flowParticlePath3 {
  0%   { left: 20%; top: 95%; opacity: 0; }
  10%  { opacity: 0.5; }
  50%  { left: 60%; top: 50%; opacity: 0.4; }
  90%  { opacity: 0.5; }
  100% { left: 80%; top: 5%;  opacity: 0; }
}

@keyframes flowParticlePath4 {
  0%   { left: 80%; top: 90%; opacity: 0; }
  10%  { opacity: 0.6; }
  50%  { left: 30%; top: 40%; opacity: 0.4; }
  90%  { opacity: 0.6; }
  100% { left: 15%; top: 10%; opacity: 0; }
}

.how-it-works-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-card {
  padding: 14px;
  border: 2px solid #1E293B;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  box-shadow: var(--shadow-hard);
  min-width: 0;
  overflow: hidden;
}

.detail-card h3 {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.detail-card p {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.detail-card code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--purple);
}

.detail-card strong {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .how-it-works-details { grid-template-columns: 1fr; }
  .how-it-works-content { padding: 24px; max-width: 100%; }
  .flow-row { flex-wrap: wrap; gap: 8px; }
  .flow-node { min-width: 100px; max-width: 130px; padding: 8px 10px; }
  .flow-arrow { width: 28px; }
  .flow-loop-section { gap: 40px; }
}

@media (max-width: 480px) {
  .how-it-works-content { padding: 16px; }
  .flow-diagram { padding: 16px 8px; }
  .flow-row { flex-wrap: wrap; gap: 8px; justify-content: center; }
  .flow-node { min-width: 100px; max-width: 140px; padding: 10px 12px; }
  .flow-node-icon { font-size: 20px; }
  .flow-node-label { font-size: 11px; }
  .flow-node-desc { font-size: 9px; }
  .flow-arrow { width: 32px; }
  .flow-loop-section { gap: 40px; }
  .flow-loop-label { font-size: 8px; }
}

/* ═══════════════════════════════════════════════════════ */
/*  STICKMAN                                               */
/* ═══════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════ */
/*  SCREEN: GAME                                           */
/* ═══════════════════════════════════════════════════════ */

#screen-game {
  flex-direction: column;
  gap: 0;
  padding: 10px 20px 70px;
  overflow: hidden;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════ */
/*  BLOCK COLORS                                           */
/* ═══════════════════════════════════════════════════════ */

.block-I { background: var(--block-I); border: 1px solid var(--border-I); box-shadow: 0 0 6px rgba(165,214,255,0.2) inset; }
.block-O { background: var(--block-O); border: 1px solid var(--border-O); box-shadow: 0 0 6px rgba(255,241,118,0.2) inset; }
.block-T { background: var(--block-T); border: 1px solid var(--border-T); box-shadow: 0 0 6px rgba(206,147,255,0.2) inset; }
.block-S { background: var(--block-S); border: 1px solid var(--border-S); box-shadow: 0 0 6px rgba(129,227,173,0.2) inset; }
.block-Z { background: var(--block-Z); border: 1px solid var(--border-Z); box-shadow: 0 0 6px rgba(255,154,154,0.2) inset; }
.block-J { background: var(--block-J); border: 1px solid var(--border-J); box-shadow: 0 0 6px rgba(144,164,255,0.2) inset; }
.block-L { background: var(--block-L); border: 1px solid var(--border-L); box-shadow: 0 0 6px rgba(255,204,128,0.2) inset; }
.block-ghost { opacity: 0.2; border-style: dashed; }

/* ═══════════════════════════════════════════════════════ */
/*  ANIMATIONS                                             */
/* ═══════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-15px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 15px var(--glow-soft), 0 0 30px transparent; }
  50% { box-shadow: 0 0 20px var(--glow), 0 0 40px var(--glow-soft); }
}

.fade-in {
  animation: fadeIn 0.5s var(--ease-out) forwards;
}

.slide-up {
  animation: slideUp 0.5s var(--ease-out) forwards;
}

.glow-pulse {
  animation: glow-pulse 3s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════ */
/*  RESPONSIVE — 12-8-4 Grid System                        */
/*  Desktop ≥1024px: 12-col, 24px gaps, max 1280px        */
/*  Tablet  768–1023px: 8-col, 24px gaps                  */
/*  Mobile  ≤767px: 4-col, 18px gaps                      */
/* ═══════════════════════════════════════════════════════ */

/* ── Tablet 768–1023px: 8-col, 24px gaps ─────────────── */
@media (max-width: 1023px) {
  .logo-text { font-size: 36px; }
  .menu-logo .logo-text { font-size: 32px; }

  #intro-line {
    -webkit-text-stroke: 2px #39ff14;
    text-shadow:
      0 0 6px rgba(57, 255, 20, 0.6),
      0 0 18px rgba(57, 255, 20, 0.35),
      0 0 35px rgba(57, 255, 20, 0.2),
      4px 4px 0px rgba(0, 80, 0, 0.5),
      8px 8px 0px rgba(0, 50, 0, 0.3);
  }

  .ai-setup-panels { flex-direction: column; }
  .vs-divider { padding: 8px 0; }
  .vs-divider span { font-size: 28px; }

  .game-layout { padding: 0 24px; gap: 12px; }

  .game-content.two-player {
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
  }

  .game-hud { flex-wrap: wrap; gap: 8px; }
  .hud-left { gap: 12px; }
  .hud-value { font-size: 18px; }

  .typing-zone { padding: 8px 12px; }
  .typing-input { font-size: 14px; padding: 6px 10px; }
  .piece-preview { width: 36px; height: 36px; }
  .preview-letter { font-size: 18px; }

  .vs-badge {
    font-size: 28px;
    padding: 16px 0;
    text-shadow: 2px 2px 0px #1E293B;
  }

  .player-label {
    padding: 4px 10px;
    font-size: 11px;
    margin-bottom: 4px;
  }

  .ai-info-card { padding: 6px 8px; margin-top: 4px; }
  .ai-info-model { font-size: 10px; }
  .ai-info-stats { font-size: 9px; }

  .typing-label { font-size: 9px; }
}

/* ── Mobile ≤767px: 4-col, 18px gaps ─────────────────── */
@media (max-width: 767px) {
  .game-layout { padding: 0 18px; gap: 10px; }

  .game-content { gap: 18px; }
  .game-content.two-player {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  #game-canvas, #game-canvas-p1, #game-canvas-p2 {
    width: 100%;
    max-width: 320px;
    height: auto;
    aspect-ratio: 1 / 2;
  }

  .game-content:not(.two-player) .player-column {
    flex-direction: column;
  }

  .game-content:not(.two-player) .input-slot {
    width: 100%;
    max-width: 320px;
  }

  .board-slot canvas {
    border-width: 1.5px;
    border-radius: var(--radius-sm);
  }

  .game-hud { padding: 6px 10px; gap: 6px; }
  .hud-left { gap: 8px; }
  .hud-value { font-size: 15px; }
  .hud-label { font-size: 8px; }
  .leaderboard-box { padding: 6px 10px; min-width: 180px; max-width: 220px; }
  .leaderboard-row { padding: 3px 5px; }
  .lb-rank { font-size: 9px; min-width: 16px; }
  .lb-name { font-size: 9px; }
  .lb-xp { font-size: 8px; }
  .infographic-widget { min-width: 140px; max-width: 180px; padding: 8px 10px; }
  .infographic-icon { font-size: 18px; }
  .infographic-title { font-size: 11px; }
  .infographic-subtitle { font-size: 9px; }
  .infographic-fact { font-size: 10px; }

  .typing-zone { padding: 6px 8px; margin-top: 6px; }
  .typing-input { font-size: 13px; letter-spacing: 0.5px; padding: 5px 8px; }
  .typing-label { font-size: 8px; }
  .piece-preview { width: 28px; height: 28px; border-radius: 6px; }
  .preview-letter { font-size: 15px; }

  .vs-badge {
    font-size: 22px;
    padding: 10px 0;
  }

  .player-label {
    padding: 3px 8px;
    font-size: 10px;
    margin-bottom: 3px;
  }

  .board-overlay { border-radius: var(--radius-sm); }
  .overlay-text { font-size: 16px; }
}

/* ── Small Mobile ≤480px ─────────────────────────────── */
@media (max-width: 480px) {
  .game-layout { padding: 0 12px; gap: 8px; }

  .game-content { gap: 12px; }
  .game-content.two-player { gap: 12px; }

  #game-canvas, #game-canvas-p1, #game-canvas-p2 {
    max-width: 260px;
  }

  .settings-content, .faq-content { padding: 20px; }

  .typing-input { font-size: 12px; padding: 4px 6px; }
  .typing-label { font-size: 7px; }
  .typing-zone { padding: 4px 6px; margin-top: 4px; }
  .piece-preview { width: 24px; height: 24px; }
  .preview-letter { font-size: 13px; }

  .hud-value { font-size: 13px; }
  .hud-label { font-size: 7px; }
  .leaderboard-box { min-width: 140px; max-width: 180px; padding: 5px 7px; }
  .leaderboard-row { gap: 4px; padding: 3px 4px; }
  .leaderboard-body { min-height: 80px; gap: 3px; }
  .lb-rank { font-size: 9px; min-width: 16px; }
  .lb-name { font-size: 9px; }
  .lb-xp { font-size: 8px; }
}

/* ── Ultra Small ≤360px ──────────────────────────────── */
@media (max-width: 360px) {
  .game-layout { padding: 0 10px; gap: 6px; }
  .game-content { gap: 10px; }

  #game-canvas, #game-canvas-p1, #game-canvas-p2 {
    max-width: 200px;
  }

  .hud-value { font-size: 12px; }
  .hud-label { font-size: 6px; }
  .game-hud { padding: 4px 8px; gap: 4px; }
  .hud-left { gap: 6px; }
  .leaderboard-box { min-width: 120px; max-width: 150px; padding: 4px 6px; }
  .leaderboard-body { min-height: 70px; gap: 2px; }
  .leaderboard-row { padding: 2px 4px; gap: 2px; }
  .lb-rank { font-size: 8px; min-width: 14px; }
  .lb-name { font-size: 8px; }
  .lb-xp { font-size: 7px; }

  .vs-badge { font-size: 18px; padding: 6px 0; }
  .player-label { padding: 2px 6px; font-size: 9px; margin-bottom: 2px; }
}

/* ═══════════════════════════════════════════════════════ */
/*  INFOGRAPHIC WIDGET                                      */
/* ═══════════════════════════════════════════════════════ */

.infographic-widget {
  position: relative;
  z-index: 1000;
  background: #FFFFFF;
  border: 2px solid #1E293B;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-hard);
  min-width: 180px;
  max-width: 240px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
  transition: all 0.4s var(--ease-spring);
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}

.infographic-widget.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.infographic-widget.hiding {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
}

.infographic-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border: none;
  background: var(--danger);
  color: #FFF;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.2s var(--ease-spring);
}

.infographic-close:hover {
  transform: scale(1.1);
}

.infographic-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.infographic-content {
  flex: 1;
  min-width: 0;
}

.infographic-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 1px;
}

.infographic-subtitle {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 10px;
  color: var(--secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.infographic-fact {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.infographic-fact strong {
  color: var(--text-primary);
  font-weight: 600;
}

@media (max-width: 768px) {
  .infographic-widget {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════ */
/*  SCROLLBAR                                              */
/* ═══════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 10px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ═══════════════════════════════════════════════════════ */
/*  UTILITY                                                */
/* ═══════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* by ctaxnagomi */
