/* ============================================
   DEFINITELY NOT A TROLL GAME™ — Style System
   ============================================ */

/* --- Design Tokens (BRUTALIST) --- */
:root {
  --bg-deep: #050505;
  --bg-dark: #0a0a0a;
  --bg-card: #000000;
  --bg-glass: #000000;
  --border-glass: #333333;
  --border-glow: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --text-dim: #444444;
  --accent: #ff003c;
  --accent2: #ffffff;
  --accent3: #ff003c;
  --accent-gold: #ffd600;
  --danger: #ff003c;
  --success: #ffffff;
  --font-display: 'Inter', sans-serif;
  --font-body: 'JetBrains Mono', monospace;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 0px;
  --radius-sm: 0px;
  --radius-lg: 0px;
  --shadow-glow: 4px 4px 0px rgba(255,0,60,1);
  --transition: 0.1s linear;
}

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg-deep); color: var(--text-primary); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
html.menu-active, html.menu-active body { overflow-y: auto; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, select { font-family: inherit; }

#app { width: 100%; height: 100%; position: relative; }

/* --- Noise Overlay --- */
#app::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-repeat: repeat; background-size: 256px 256px; opacity: 0.4; mix-blend-mode: overlay;
}

/* --- Scanline Effect --- */
#app::before {
  content: ''; position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
}

/* --- Screens --- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.6s ease; z-index: 1; }
.screen.active { opacity: 1; pointer-events: all; z-index: 10; }

/* Menu screen needs to scroll on small viewports */
#menu.active { position: relative; min-height: 100vh; }

/* ==============================
   GLITCH TEXT EFFECT
   ============================== */
.glitch-text {
  position: relative;
  display: inline-block;
}
.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
}
.glitch-text::before { color: #ff003c; z-index: -1; }
.glitch-text::after { color: #00e5ff; z-index: -2; }

@keyframes glitch {
  0%, 90%, 100% { opacity: 0; transform: none; }
  91% { opacity: 0.8; transform: translate(-3px, -2px); clip-path: inset(20% 0 30% 0); }
  93% { opacity: 0.8; transform: translate(3px, 2px); clip-path: inset(50% 0 10% 0); }
  95% { opacity: 0; transform: none; }
}

.glitch-text:hover::before,
.glitch-text:hover::after {
  animation: glitch 2s infinite;
}
.glitch-text:hover::after {
  animation-delay: 0.1s;
}

/* Periodic glitch on the title */
.glitch-active::before,
.glitch-active::after {
  animation: glitch 0.3s steps(2) 1 !important;
  opacity: 1 !important;
}

/* ==============================
   SPLASH SCREEN
   ============================== */
#splash { background: var(--bg-deep); flex-direction: column; z-index: 100; }
#splash.active { z-index: 100; }
.splash-content { text-align: center; }
.studio-logo { margin-bottom: 8px; }
.logo-icon { font-size: 48px; display: block; margin-bottom: 12px; animation: float 3s ease-in-out infinite; }
.studio-name { font-family: var(--font-display); font-size: 36px; font-weight: 900; letter-spacing: 12px; text-transform: uppercase; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.studio-suffix { display: block; font-size: 11px; letter-spacing: 8px; color: var(--text-dim); margin-top: 4px; font-family: var(--font-mono); }
.studio-tagline { color: var(--text-secondary); font-size: 13px; margin: 16px 0 40px; font-style: italic; letter-spacing: 2px; }
.loading-container { width: 320px; margin: 0 auto; }
.loading-bar { width: 100%; height: 4px; background: rgba(255,255,255,0.06); border-radius: 4px; overflow: hidden; }
.loading-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width 0.3s ease; }
.loading-text { font-size: 11px; color: var(--text-dim); margin-top: 12px; font-family: var(--font-mono); letter-spacing: 1px; }

/* ==============================
   MAIN MENU (SUBTLE ELEGANCE)
   ============================== */
#menu { background-color: #030304; display: flex; align-items: center; justify-content: center; overflow-y: auto; overflow-x: hidden; position: relative; background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px); background-size: 40px 40px; min-height: 100%; }

.menu-particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.menu-content { text-align: center; position: relative; z-index: 2; width: 90%; max-width: 700px; padding: 40px 32px; background: rgba(10, 10, 12, 0.95); border: 1px solid rgba(255, 0, 60, 0.15); border-radius: 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), inset 0 0 40px rgba(255, 0, 60, 0.03); margin: 24px auto; display: flex; flex-direction: column; align-items: center; }

.title-pre { font-family: var(--font-mono); font-size: 11px; letter-spacing: 6px; color: rgba(255,255,255,0.3); margin-bottom: 8px; }

.game-title { margin-bottom: 28px; }
.game-title h1 { font-family: var(--font-display); font-size: clamp(40px, 8vw, 64px); font-weight: 900; line-height: 1.1; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 2px; color: #ffffff; text-shadow: 0 4px 20px rgba(255, 0, 60, 0.5); }
.game-title .tagline { color: rgba(255,255,255,0.4); font-size: 13px; letter-spacing: 1px; font-style: italic; }

.menu-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 30px; margin: 0 0 24px 0; padding: 20px 30px; border-top: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.05); background: rgba(0, 0, 0, 0.3); width: 100%; border-radius: 8px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; color: #ff003c; text-shadow: 0 0 16px rgba(255, 0, 60, 0.3); }
.stat-label { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: rgba(255, 255, 255, 0.4); font-weight: 600; }

#fake-rating-stat { cursor: pointer; transition: all 0.2s ease; }
#fake-rating-stat:hover .stat-value { text-shadow: 0 0 20px rgba(255,0,60,0.6); }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-bottom: 24px; width: 100%; max-width: 280px; }
.menu-btn { position: relative; width: 100%; padding: 18px 24px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.03); border-radius: 8px; font-family: var(--font-mono); font-size: 14px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; transition: all 0.2s ease; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; color: rgba(255, 255, 255, 0.8); cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.menu-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.3); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.menu-btn.primary { background: #ff003c; color: #fff; border: none; box-shadow: 0 4px 16px rgba(255, 0, 60, 0.3); }
.menu-btn.primary:hover { background: #ff1a53; transform: scale(1.03) translateY(-2px); box-shadow: 0 8px 24px rgba(255, 0, 60, 0.5); color: #fff; border: none; }
.menu-btn .btn-text { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 8px; }

.menu-reviews { color: rgba(255, 255, 255, 0.4); font-size: 13px; font-style: italic; letter-spacing: 0.5px; margin-bottom: 16px; min-height: 24px; transition: opacity 0.3s ease; }
.menu-reviews em { color: rgba(255, 255, 255, 0.6); font-weight: 600; }

.menu-highscores { background: rgba(255,214,0,0.03); border: 1px solid rgba(255,214,0,0.1); border-radius: 8px; padding: 16px 20px; font-size: 12px; color: rgba(255,255,255,0.5); font-family: var(--font-mono); line-height: 1.8; width: 100%; margin-bottom: 16px; }

.konami-hint { margin-top: 8px; }
.konami-hint-text { font-family: var(--font-mono); font-size: 9px; color: rgba(255,255,255,0.08); letter-spacing: 2px; transition: color 0.5s ease; }
.konami-hint-text:hover { color: rgba(255,255,255,0.25); }

/* ==============================
   GAME SCREEN
   ============================== */
#game-screen { flex-direction: column; background: #000; align-items: stretch; justify-content: stretch; position: absolute; inset: 0; }
#game-screen.active { z-index: 20; }
#game-canvas { width: 100%; flex: 1; display: block; min-height: 0; }

/* --- HUD --- */
#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; padding: 20px 32px; pointer-events: none; }
.hud-left, .hud-center, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }
.hud-health { display: flex; gap: 8px; }
.heart { width: 20px; height: 20px; font-size: 18px; transition: transform 0.2s ease; color: #ff003c; text-shadow: 0 0 10px rgba(255, 0, 60, 0.4); }
.heart.lost { opacity: 0.2; transform: scale(0.7); filter: grayscale(1); box-shadow: none; }
.hud-score, .hud-deaths, .hud-fps, .hud-timer, .hud-level { font-family: var(--font-mono); font-size: 13px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.7); font-weight: 500; }
.hud-level { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: 3px; }
.hud-fps { color: rgba(255, 255, 255, 0.4); font-size: 10px; }
.hud-pause-btn { pointer-events: auto; background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.9); border-radius: 8px; font-size: 18px; width: 44px; height: 44px; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); transition: all 0.2s ease; margin-top: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.hud-pause-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.4); transform: scale(1.05); }

/* --- Game Overlays --- */
.game-overlay { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(12px); animation: fadeIn 0.4s ease; }
.game-overlay.hidden { display: none; }

.death-content, .intro-content, .complete-content, .victory-content, .pause-content { text-align: center; background: rgba(10, 10, 12, 0.95); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(255, 0, 60, 0.05); padding: 48px; max-width: 500px; width: 90%; animation: modalPop 0.3s cubic-bezier(0.2, 0, 0, 1.2); }

/* Death */
.death-icon { font-size: 48px; margin-bottom: 16px; filter: drop-shadow(0 0 12px rgba(230, 57, 70, 0.4)); }
.death-message { font-family: var(--font-display); font-size: clamp(28px, 5vw, 42px); font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: #fff; }
.death-sub { color: rgba(255, 255, 255, 0.6); font-size: 14px; margin-top: 12px; font-family: var(--font-mono); font-weight: normal; line-height: 1.6; white-space: pre-line; }
.death-hint { color: #e63946; font-size: 13px; font-style: italic; margin-top: 24px; font-weight: 500; }

/* Level Intro */
.intro-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 6px; color: rgba(255, 255, 255, 0.5); margin-bottom: 12px; font-weight: 600; }
.intro-content h2 { font-family: var(--font-display); font-size: clamp(28px, 5vw, 42px); font-weight: 800; margin-bottom: 16px; text-transform: uppercase; color: #fff; }
.intro-content p { color: rgba(255, 255, 255, 0.7); font-size: 15px; letter-spacing: 0.5px; font-weight: normal; }
.intro-hint { margin-top: 32px !important; color: rgba(255, 255, 255, 0.3); font-family: var(--font-mono); font-size: 12px; animation: pulse 2.5s ease-in-out infinite; font-weight: 500; }

/* Level Complete */
.complete-icon { font-size: 56px; margin-bottom: 12px; }
.complete-content h2 { font-family: var(--font-display); font-size: 36px; font-weight: 800; color: var(--success); margin-bottom: 8px; text-transform: uppercase; }
.complete-hint { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; margin-top: 24px; animation: pulse 2s ease-in-out infinite; }

/* Victory */
.victory-content { max-width: 550px; }
.victory-content h2 { font-family: var(--font-display); font-size: 36px; font-weight: 800; color: var(--success); margin-bottom: 16px; text-transform: uppercase; }
#victory-stats { font-family: var(--font-mono); font-size: 13px; color: var(--text-secondary); line-height: 2; margin: 20px 0; }
.ai-review { font-family: var(--font-mono); font-size: 12px; color: rgba(255,214,0,0.8); background: rgba(255,214,0,0.05); border: 1px solid rgba(255,214,0,0.15); border-radius: 8px; padding: 16px; margin: 16px 0; text-align: left; line-height: 1.6; display: none; }
.ai-review.visible { display: block; animation: fadeIn 0.5s ease; }
.ai-review .review-label { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: rgba(255,214,0,0.5); margin-bottom: 8px; display: block; }
.victory-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 16px; }
.victory-buttons .menu-btn { width: 260px; }
.share-btn { background: rgba(255,214,0,0.1) !important; border-color: rgba(255,214,0,0.3) !important; color: #ffd600 !important; }
.share-btn:hover { background: rgba(255,214,0,0.2) !important; }

/* Pause */
.pause-content h2 { font-family: var(--font-display); font-size: 36px; font-weight: 800; margin-bottom: 8px; text-transform: uppercase; }
.pause-content p { color: var(--text-secondary); font-size: 13px; margin-bottom: 24px; font-weight: bold; }
.pause-content .menu-btn { width: 240px; margin: 8px auto; display: inline-flex; }
.quit-troll-msg { font-family: var(--font-mono); font-size: 14px; color: var(--accent-gold); font-weight: 600; padding: 10px 16px; background: rgba(255, 214, 0, 0.08); border: 1px solid rgba(255, 214, 0, 0.2); border-radius: var(--radius); margin-bottom: 16px; text-shadow: 0 0 12px rgba(255, 214, 0, 0.4); animation: fadeIn 0.3s ease; }

/* ==============================
   TEAPOT 418 SCREEN — Ode to Larry Masinter
   ============================== */
#teapot-screen {
  background: linear-gradient(135deg, #0a0608, #12080e, #0a0a12);
  color: #fff;
  flex-direction: column;
  text-align: center;
  overflow-y: auto;
  overflow-x: hidden;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px;
}
#teapot-screen.active { z-index: 150; }

#teapot-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 100, 50, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.teapot-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px;
  max-width: 550px;
  animation: fadeIn 0.8s ease;
}

.teapot-steam {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 80px;
  pointer-events: none;
}

.teapot-icon-lg {
  font-size: 100px;
  display: block;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(255, 150, 50, 0.3));
}

.teapot-content h1 {
  font-size: clamp(80px, 15vw, 140px);
  font-weight: 900;
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -3px;
  background: linear-gradient(135deg, #ff6b35, #ffd600, #ff003c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  line-height: 1;
}

.teapot-content h2 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 500;
  font-family: var(--font-display);
  margin-bottom: 24px;
  font-style: italic;
  color: rgba(255, 200, 150, 0.8);
}

.teapot-rfc {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 150, 50, 0.5);
  margin-bottom: 24px;
}

.teapot-body {
  font-size: 14px;
  max-width: 450px;
  margin: 0 auto 20px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.6);
}

.teapot-poem {
  font-size: 16px;
  font-style: italic;
  color: rgba(255, 200, 150, 0.7);
  margin: 24px auto;
  padding: 16px 24px;
  border-left: 3px solid rgba(255, 150, 50, 0.3);
  max-width: 400px;
  text-align: left;
  line-height: 1.8;
}

.teapot-details {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255, 150, 50, 0.4);
  text-align: left;
  max-width: 350px;
  margin: 24px auto;
  line-height: 2;
}

.teapot-details p { margin: 0; }

#btn-teapot-back {
  background: rgba(255, 150, 50, 0.15);
  color: rgba(255, 200, 150, 0.9);
  border: 1px solid rgba(255, 150, 50, 0.3);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  width: auto;
  padding: 16px 32px;
  margin-top: 24px;
}
#btn-teapot-back:hover {
  background: rgba(255, 150, 50, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 150, 50, 0.2);
}

/* ==============================
   CHAT & AI COMPANION
   ============================== */
#chat-toggle { position: fixed; bottom: 24px; right: 24px; z-index: 200; width: 56px; height: 56px; border-radius: 28px; background: rgba(10, 10, 12, 0.8); border: 1px solid rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6); cursor: pointer; transition: all 0.3s cubic-bezier(0.2, 0, 0, 1.2); backdrop-filter: blur(12px); color: rgba(255,255,255,0.7); }
#chat-toggle:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.4); transform: scale(1.08); color: #fff; }
#chat-toggle .chat-icon { font-size: 24px; font-weight: 600; font-family: var(--font-display); }

#chat-popup { position: fixed; bottom: 90px; right: 24px; z-index: 200; width: 360px; max-height: 70vh; background: rgba(10, 10, 12, 0.95); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8); backdrop-filter: blur(20px); display: flex; flex-direction: column; overflow: hidden; animation: chatSlideUp 0.3s cubic-bezier(0.2, 0, 0, 1); }
#chat-popup.hidden { display: none; }

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

.chat-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); background: rgba(0, 0, 0, 0.4); }
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-avatar { width: 36px; height: 36px; border-radius: 18px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.chat-header-info { display: flex; flex-direction: column; gap: 2px; }
.chat-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: #fff; letter-spacing: 0.5px; text-transform: uppercase; }
.chat-status { font-size: 10px; color: rgba(255, 255, 255, 0.4); display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); }
.status-dot { width: 6px; height: 6px; border-radius: 3px; background: #00e676; display: inline-block; box-shadow: 0 0 8px rgba(0, 230, 118, 0.6); animation: pulse 2s ease-in-out infinite; }
#chat-close { font-size: 18px; color: rgba(255, 255, 255, 0.4); width: 32px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: transparent; border: none; transition: all 0.2s ease; }
#chat-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; min-height: 250px; max-height: 350px; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.chat-msg { max-width: 85%; animation: msgPop 0.3s ease; }
.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }
.chat-msg p { padding: 12px 14px; font-size: 13px; line-height: 1.5; font-family: var(--font-body); border-radius: 12px; font-weight: 400; }
.chat-msg.bot p { background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.9); border-bottom-left-radius: 4px; }
.chat-msg.user p { background: #ff003c; color: #fff; border-bottom-right-radius: 4px; }

.typing-indicator { display: flex; gap: 6px; padding: 12px 16px; }
.typing-indicator span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.3); animation: typingBounce 1.4s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-area { display: flex; gap: 10px; padding: 16px; border-top: 1px solid rgba(255, 255, 255, 0.05); background: rgba(0, 0, 0, 0.4); }
#chat-input { flex: 1; padding: 12px 16px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; color: #fff; font-family: var(--font-body); font-size: 13px; outline: none; transition: border-color 0.2s ease; }
#chat-input:focus { border-color: rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.05); }
#chat-send { width: 42px; height: 42px; border-radius: 8px; background: #ff003c; border: none; display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff; cursor: pointer; transition: all 0.2s ease; }
#chat-send:hover { background: #ff1a53; transform: scale(1.05); box-shadow: 0 4px 12px rgba(255, 0, 60, 0.3); }

/* ==============================
   MODALS
   ============================== */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); }
.glass-panel { position: relative; width: 420px; max-width: 90vw; max-height: 85vh; overflow-y: auto; padding: 40px; background: #000; border: 2px solid #333; box-shadow: 10px 10px 0 #111; animation: modalPop 0.3s cubic-bezier(0.2, 0, 0, 1.2); }
.glass-panel h2 { font-family: var(--font-display); font-size: 22px; font-weight: 800; margin-bottom: 24px; letter-spacing: 2px; }

.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-glass); }
.setting-row label { font-size: 13px; color: var(--text-secondary); }
.setting-row select, .setting-row input[type="range"] { background: rgba(255,255,255,0.06); border: 1px solid var(--border-glass); color: var(--text-primary); padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; }
.setting-row input[type="range"] { width: 120px; accent-color: var(--accent); }
.setting-note { font-size: 10px; color: var(--text-dim); margin-top: 16px; text-align: center; font-style: italic; }
.modal .menu-btn { width: 100%; margin-top: 20px; }

.danger-row { border-bottom-color: rgba(255,0,60,0.2); }
.uninstall-btn { padding: 8px 16px; background: rgba(255,0,60,0.15); border: 1px solid rgba(255,0,60,0.3); color: #ff4466; font-family: var(--font-mono); font-size: 12px; border-radius: 4px; cursor: pointer; transition: all 0.2s ease; }
.uninstall-btn:hover { background: rgba(255,0,60,0.25); color: #ff6688; }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: rgba(255,255,255,0.1); border-radius: 24px; cursor: pointer; transition: var(--transition); }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-secondary); transition: var(--transition); }
.toggle-switch input:checked + .toggle-slider { background: rgba(255, 0, 60, 0.3); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: var(--accent); }

.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.control-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; background: rgba(255,255,255,0.03); border-radius: var(--radius); border: 1px solid var(--border-glass); }
.control-item .keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.control-item span { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
kbd { padding: 4px 10px; border-radius: 6px; background: rgba(255,255,255,0.08); border: 1px solid var(--border-glass); font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }
.tips-box { background: rgba(255,255,255,0.03); border-radius: var(--radius); padding: 16px 20px; border: 1px solid var(--border-glass); }
.tips-box h3 { font-family: var(--font-display); font-size: 14px; margin-bottom: 10px; color: var(--accent); }
.tips-box ul { list-style: none; }
.tips-box li { font-size: 13px; padding: 4px 0; color: var(--text-secondary); }
.tips-box li::before { content: '→ '; color: var(--accent); }

.credits-line { font-size: 13px; color: var(--text-secondary); padding: 8px 0; border-bottom: 1px solid var(--border-glass); }
.teapot-credit { color: var(--accent-gold); }

/* ==============================
   COOKIE BANNER
   ============================== */
#cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 500; padding: 16px 24px; background: var(--bg-card); border-top: 1px solid var(--border-glass); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: space-between; gap: 16px; animation: slideUp 0.5s 2s both; }
#cookie-banner.hidden { display: none; }
#cookie-banner p { font-size: 13px; color: var(--text-secondary); flex: 1; }
#cookie-accept { padding: 8px 20px; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent3), var(--accent2)); color: #fff; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; transition: all var(--transition); white-space: nowrap; }
#cookie-accept:hover { transform: scale(1.05); }

/* ==============================
   ACHIEVEMENT TOAST
   ============================== */
#achievement { position: fixed; top: 24px; right: 24px; z-index: 400; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid rgba(255, 214, 0, 0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.4); animation: achieveSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
#achievement.hidden { display: none; }
.achievement-glow { position: absolute; inset: 0; border-radius: var(--radius); background: radial-gradient(ellipse at center, rgba(255,214,0,0.1), transparent 70%); pointer-events: none; }
.achievement-icon { font-size: 28px; position: relative; }
.achievement-label { font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent-gold); font-family: var(--font-mono); font-weight: 600; }
.achievement-desc { font-size: 13px; color: var(--text-primary); font-weight: 500; margin-top: 2px; }

/* ==============================
   NOTIFICATION TOAST
   ============================== */
#notification { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 350; padding: 14px 28px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border-glass); font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); box-shadow: 0 8px 40px rgba(0,0,0,0.5); animation: fadeIn 0.3s ease; white-space: nowrap; }
#notification.hidden { display: none; }

/* ==============================
   GEMINI BADGE
   ============================== */
.gemini-badge { position: fixed; bottom: 90px; right: 24px; z-index: 190; font-family: var(--font-mono); font-size: 9px; letter-spacing: 2px; color: rgba(255,255,255,0.25); background: rgba(0,0,0,0.4); padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.06); pointer-events: none; }
.gemini-badge.hidden { display: none; }
.gemini-sparkle { color: #ffd600; }

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes gradientShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes deathSlam { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes introSlide { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes chatPulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes chatSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes msgPop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes modalPop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes achieveSlide { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes steamRise {
  0% { transform: translateY(0) scale(1); opacity: 0.4; }
  100% { transform: translateY(-60px) scale(2); opacity: 0; }
}

/* ==============================
   Z-INDEX & MOBILE CONTROLS
   ============================== */
.mobile-controls { position: absolute; inset: 0; z-index: 50; pointer-events: none; display: none; justify-content: space-between; align-items: flex-end; padding: 20px; }
.mobile-controls.hidden { display: none; }
.dpad, .action-pad { pointer-events: auto; display: flex; gap: 10px; }
.touch-btn { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.3); color: #fff; font-size: 24px; font-weight: bold; border-radius: 50%; opacity: 0.5; user-select: none; -webkit-tap-highlight-color: transparent; }
.touch-btn:active { background: rgba(255,255,255,0.3); opacity: 1; transform: scale(0.95); }
.action-pad .touch-btn { width: 80px; height: 80px; border-radius: 50%; font-size: 16px; background: rgba(255,0,60,0.2); border-color: rgba(255,0,60,0.5); }
.action-pad .touch-btn:active { background: rgba(255,0,60,0.5); }

/* ==============================
   RESPONSIVE SCALING
   ============================== */
@media (max-width: 900px), (max-height: 500px) and (orientation: landscape) {
  .menu-content { margin: 20px auto; padding: 32px 20px; border-radius: 0; border-left: none; border-right: none; }
  .game-title h1 { font-size: clamp(28px, 10vw, 44px); }
  .menu-stats { gap: 20px; flex-direction: row; flex-wrap: wrap; justify-content: space-around; padding: 16px; }
  .stat-value { font-size: 18px; }
  
  #chat-popup { bottom: 90px; right: 16px; left: 16px; width: auto; max-width: none; max-height: 50vh; }
  .chat-messages { min-height: 150px; }

  .glass-panel { padding: 30px 20px; }
  .controls-grid { grid-template-columns: 1fr; }
  
  /* Touch Controls Overlay */
  #game-screen.active .mobile-controls { display: flex !important; pointer-events: none; }
  .mobile-controls { align-items: flex-end; padding: 20px; z-index: 50; flex-direction: row; }
  .touch-btn { opacity: 0.9; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
  .touch-btn, .action-pad .touch-btn, .dpad .touch-btn { pointer-events: auto; }
  
  #chat-toggle { bottom: 120px; top: auto; right: 16px; }

  /* Teapot page: ensure button visible */
  #teapot-screen { align-items: flex-start; padding-top: 20px; }
  .teapot-content { padding: 24px; padding-bottom: 40px; }
  .teapot-icon-lg { font-size: 60px; }
  .teapot-content h1 { font-size: 64px; }
  .teapot-content h2 { font-size: 20px; margin-bottom: 16px; }
  .teapot-poem { font-size: 13px; padding: 12px 16px; }
  .teapot-rfc { font-size: 8px; margin-bottom: 16px; }
  .teapot-body { font-size: 13px; margin-bottom: 12px; }
  .teapot-details { font-size: 10px; margin: 16px auto; }

  .gemini-badge { bottom: 100px; right: 16px; font-size: 8px; }
}