/* ═══════════════════════════════════════════════════════════════
   OUR PIXEL WORLD — Complete Design System
   Dark/Light theme + pixel art RPG aesthetic
   ═══════════════════════════════════════════════════════════════ */

/* ─── DARK THEME (Default) ─────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg-primary:     #0f0e17;
  --bg-secondary:   #1a1932;
  --bg-surface:     #232946;
  --bg-surface-alt: #353a5e;
  --bg-card:        #1e1e3a;

  --primary:        #ff6b97;
  --primary-glow:   #ff8fb3;
  --secondary:      #7f5af0;
  --accent:         #2cb67d;
  --gold:           #f9c74f;
  --danger:         #e53170;

  --text:           #fffffe;
  --text-dim:       #94a1b2;
  --text-muted:     #525a6b;

  --border:         #fffffe;
  --shadow-color:   rgba(127, 90, 240, 0.15);
  --overlay:        rgba(15, 14, 23, 0.92);

  --pixel: 4px;
  --pixel-sm: 2px;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;

  --font-pixel: 'Press Start 2P', monospace;
  --t-fast: 150ms;
  --t-normal: 300ms;
  --t-slow: 600ms;

  color-scheme: dark;
}

/* ─── LIGHT THEME ──────────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:     #faf5ff;
  --bg-secondary:   #ede4f7;
  --bg-surface:     #e0d4f5;
  --bg-surface-alt: #d0c4e8;
  --bg-card:        #ece2fa;

  --primary:        #e0457b;
  --primary-glow:   #f06595;
  --secondary:      #6c3ec9;
  --accent:         #1a9960;
  --gold:           #d4a017;
  --danger:         #c42858;

  --text:           #1a1a2e;
  --text-dim:       #4a4a6a;
  --text-muted:     #8888a8;

  --border:         #3a3a5c;
  --shadow-color:   rgba(127, 90, 240, 0.12);
  --overlay:        rgba(250, 245, 255, 0.92);

  color-scheme: light;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-pixel);
  background-color: var(--bg-primary);
  color: var(--text);
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-font-smoothing: none;
  transition: background-color var(--t-normal), color var(--t-normal);
}

/* ─── SCREEN SYSTEM ────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity var(--t-slow), visibility var(--t-slow);
  z-index: 1;
  background: var(--bg-primary);
}
.screen.active { opacity: 1; visibility: visible; z-index: 10; }

.hidden { display: none !important; }

/* ─── PIXEL BORDER ─────────────────────────────────────────── */
.pixel-border {
  position: relative;
  background: var(--bg-surface);
  border: var(--pixel) solid var(--border);
  box-shadow:
    inset calc(-1 * var(--pixel)) calc(-1 * var(--pixel)) 0 0 var(--bg-surface-alt),
    inset var(--pixel) var(--pixel) 0 0 var(--bg-secondary),
    0 0 0 var(--pixel) var(--bg-primary),
    0 0 30px var(--shadow-color);
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  padding: var(--sp-md) var(--sp-xl);
  border: var(--pixel-sm) solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-sm);
  transition: all var(--t-fast);
  letter-spacing: 1px;
  text-transform: uppercase;
  justify-content: center;
  white-space: nowrap;
}
.pixel-btn:active { transform: translate(var(--pixel-sm), var(--pixel-sm)); }
.pixel-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pixel-btn:disabled:active { transform: none; }

.primary-btn {
  background: var(--primary); color: #fff;
  box-shadow: var(--pixel) var(--pixel) 0 var(--danger), 0 0 20px rgba(255,107,151,0.3);
}
.primary-btn:hover:not(:disabled) {
  background: var(--primary-glow);
  box-shadow: var(--pixel) var(--pixel) 0 var(--danger), 0 0 30px rgba(255,107,151,0.5);
}
.primary-btn:active { box-shadow: 0 0 20px rgba(255,107,151,0.3); }

.secondary-btn {
  background: var(--bg-surface); color: var(--text-dim);
  box-shadow: var(--pixel) var(--pixel) 0 var(--bg-secondary);
}
.secondary-btn:hover { background: var(--bg-surface-alt); color: var(--text); }

.danger-btn {
  background: var(--danger); color: #fff;
  box-shadow: var(--pixel) var(--pixel) 0 #8b1a3a;
  padding: var(--sp-sm) var(--sp-md);
  font-size: 0.6rem;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════════ */
#login-screen { overflow: hidden; }
#stars-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }

.login-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; padding: var(--sp-md);
}
.login-box {
  padding: var(--sp-2xl) var(--sp-lg);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-lg);
}

/* Pixel Heart */
.pixel-heart-container {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  animation: heartbeat 1.2s ease-in-out infinite;
}
.pixel-heart {
  width: 32px; height: 28px;
  background: var(--primary); position: relative;
  clip-path: polygon(0% 35%,5% 20%,15% 10%,25% 5%,35% 5%,45% 15%,50% 25%,55% 15%,65% 5%,75% 5%,85% 10%,95% 20%,100% 35%,100% 50%,85% 70%,65% 85%,50% 100%,35% 85%,15% 70%,0% 50%);
  box-shadow: 0 0 20px var(--primary), 0 0 40px rgba(255,107,151,0.3);
}
@keyframes heartbeat {
  0%,100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
}

.game-title {
  font-size: 1.45rem; line-height: 1.8; color: var(--text);
  text-shadow: var(--pixel) var(--pixel) 0 var(--secondary), calc(-1 * var(--pixel-sm)) 0 0 var(--primary);
  letter-spacing: 2px;
}
.subtitle {
  font-size: 0.65rem; color: var(--primary-glow);
  letter-spacing: 3px; animation: subtitlePulse 3s ease-in-out infinite;
}
@keyframes subtitlePulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

/* Password Field */
.password-field { width: 100%; display: flex; flex-direction: column; gap: var(--sp-sm); }
.pixel-label { font-size: 0.6rem; color: var(--gold); letter-spacing: 2px; text-align: left; }
.input-wrapper { position: relative; width: 100%; }
.input-wrapper input {
  width: 100%;
  padding: var(--sp-md) var(--sp-xl) var(--sp-md) var(--sp-md);
  font-family: var(--font-pixel); font-size: 0.82rem;
  background: var(--bg-primary); color: var(--text);
  border: var(--pixel-sm) solid var(--text-muted);
  outline: none; letter-spacing: 3px;
  transition: border-color var(--t-fast);
}
.input-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(255,107,151,0.2);
}
.input-wrapper input::placeholder { color: var(--text-muted); letter-spacing: 5px; }
.toggle-btn {
  position: absolute; right: var(--sp-sm); top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 0.8rem;
  padding: var(--sp-xs); opacity: 0.5; transition: opacity var(--t-fast);
}
.toggle-btn:hover { opacity: 1; }

/* Messages */
.message {
  font-size: 0.58rem; padding: var(--sp-sm) var(--sp-md);
  text-align: center; line-height: 1.8; transition: all var(--t-normal);
}
.message.error { color: var(--danger); animation: msgShake 0.4s ease; }
.message.success { color: var(--accent); }
@keyframes msgShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

.hint-text { font-size: 0.52rem; color: var(--text-muted); letter-spacing: 1px; }

/* Floating Pixels */
.floating-pixels { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.fpx {
  position: absolute; bottom: -20px; left: var(--x);
  font-size: 1.2rem; opacity: 0;
  animation: floatUp 6s var(--delay) ease-in-out infinite;
  color: var(--primary); filter: drop-shadow(0 0 8px var(--primary));
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  20% { opacity: 0.8; } 80% { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-100vh) scale(1) rotate(180deg); }
}

/* Landscape/rotation styles removed — orientation check deleted */

/* ═══════════════════════════════════════════════════════════════
   MAIN MENU SCREEN
   ═══════════════════════════════════════════════════════════════ */
#menu-screen { overflow: hidden; }
#menu-stars-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; z-index: 0;
}

.menu-container {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-xl);
  padding: var(--sp-lg);
}

.menu-title-area {
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-md);
}
.menu-heart-big {
  width: 48px; height: 42px;
  background: var(--primary);
  clip-path: polygon(0% 35%,5% 20%,15% 10%,25% 5%,35% 5%,45% 15%,50% 25%,55% 15%,65% 5%,75% 5%,85% 10%,95% 20%,100% 35%,100% 50%,85% 70%,65% 85%,50% 100%,35% 85%,15% 70%,0% 50%);
  box-shadow: 0 0 25px var(--primary);
  animation: heartbeat 1.2s ease-in-out infinite;
}
.menu-game-title {
  font-size: 1.1rem; color: var(--text);
  text-shadow: var(--pixel) var(--pixel) 0 var(--secondary);
  letter-spacing: 2px;
}
.menu-tagline {
  font-size: 0.52rem; color: var(--primary-glow);
  letter-spacing: 2px; animation: subtitlePulse 3s ease-in-out infinite;
}

.menu-buttons {
  display: flex; flex-direction: column;
  gap: var(--sp-sm);
  width: 100%; max-width: 300px;
}
.menu-btn {
  width: 100%;
  padding: var(--sp-md) var(--sp-lg);
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--pixel) var(--pixel) 0 var(--bg-secondary);
  justify-content: flex-start;
  gap: var(--sp-md);
  transition: all var(--t-fast);
}
.menu-btn:hover:not(:disabled) {
  background: var(--bg-surface-alt);
  transform: translateX(var(--pixel));
  box-shadow: var(--pixel-sm) var(--pixel) 0 var(--secondary);
}
.menu-btn:disabled {
  opacity: 0.3;
}
.menu-btn-icon { font-size: 0.9rem; width: 24px; text-align: center; }
.menu-btn-label { font-size: 0.65rem; letter-spacing: 1px; }

.quit-btn { border-color: var(--danger); }
.quit-btn:hover { background: var(--danger); color: #fff; }

/* DEV menu button — neon green accent */
.dev-menu-btn { border-color: #00ff88 !important; }
.dev-menu-btn:hover { background: rgba(0,255,136,0.12) !important; color: #00ff88 !important; }

.menu-version {
  font-size: 0.46rem; color: var(--text-muted);
  letter-spacing: 1px; position: absolute; bottom: var(--sp-md);
}

/* ═══════════════════════════════════════════════════════════════
   MODE SELECT SCREEN
   ═══════════════════════════════════════════════════════════════ */
#mode-screen { overflow-y: auto; }
.mode-container {
  width: 100%; max-width: 900px;
  padding: var(--sp-xl);
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-xl);
}
.mode-title {
  font-size: 0.95rem; color: var(--gold);
  letter-spacing: 3px;
  text-shadow: var(--pixel-sm) var(--pixel-sm) 0 var(--secondary);
}
.mode-sub {
  font-size: 0.52rem; color: var(--text-dim);
  letter-spacing: 1px;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-md);
  width: 100%;
}
.mode-card {
  padding: var(--sp-xl) var(--sp-md);
  text-align: center; cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-sm);
  transition: all var(--t-normal);
  border: none; font-family: var(--font-pixel);
}
.mode-card--tutorial {
  border-color: var(--gold) !important;
  background: rgba(249,199,79,0.07);
}
.mode-card--tutorial .mode-name { color: var(--gold); }
.mode-card--highlight {
  border-color: var(--primary) !important;
  background: rgba(255,107,151,0.07);
  box-shadow: 0 0 20px rgba(255,107,151,0.2);
}
.mode-card:hover {
  transform: translateY(calc(-1 * var(--pixel)));
  box-shadow:
    inset calc(-1 * var(--pixel)) calc(-1 * var(--pixel)) 0 0 var(--bg-surface-alt),
    inset var(--pixel) var(--pixel) 0 0 var(--bg-secondary),
    0 0 0 var(--pixel) var(--bg-primary),
    0 0 40px var(--shadow-color),
    0 8px 25px rgba(127,90,240,0.2);
}
.mode-card:active { transform: translateY(var(--pixel-sm)); }

.mode-icon { font-size: 2.5rem; }
.mode-name {
  font-size: 0.72rem; color: var(--primary);
  letter-spacing: 1px; line-height: 1.6;
}
.mode-desc {
  font-size: 0.5rem; color: var(--text-dim);
  line-height: 2; letter-spacing: 0.5px;
}
.mode-chapter {
  font-size: 0.46rem; color: var(--accent);
  padding: var(--sp-xs) var(--sp-sm);
  background: rgba(44,182,125,0.1);
  border: 1px solid rgba(44,182,125,0.3);
  letter-spacing: 1px;
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS SCREEN
   ═══════════════════════════════════════════════════════════════ */
.settings-container {
  width: 100%; max-width: 400px;
  padding: var(--sp-xl);
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-xl);
}
.section-title {
  font-size: 0.85rem; color: var(--gold);
  letter-spacing: 3px;
  text-shadow: var(--pixel-sm) var(--pixel-sm) 0 var(--secondary);
}

.settings-list {
  width: 100%;
  display: flex; flex-direction: column; gap: var(--sp-md);
}
.setting-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: var(--sp-md);
  background: var(--bg-surface);
  border: var(--pixel-sm) solid var(--bg-surface-alt);
}
.setting-label {
  font-size: 0.6rem; color: var(--text-dim);
  letter-spacing: 1px;
}

.theme-toggle {
  display: flex; gap: 2px;
}
.theme-opt {
  font-family: var(--font-pixel);
  font-size: 0.52rem;
  padding: var(--sp-sm) var(--sp-md);
  border: var(--pixel-sm) solid var(--text-muted);
  background: var(--bg-primary);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--t-fast);
}
.theme-opt.active {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}
.theme-opt:hover:not(.active) {
  background: var(--bg-surface-alt);
  color: var(--text);
}

/* ─── DEV Screen styles ──────────────────────────────────── */
.dev-container { border: 2px solid #00ff88; box-shadow: 0 0 20px rgba(0,255,136,0.15); }
.dev-warning {
  font-size: 0.5rem; color: #ff9900;
  letter-spacing: 1px; text-align: center;
}
.dev-controls-hint {
  background: rgba(0,0,0,0.4); border: 1px solid #00ff88;
  padding: var(--sp-md); width: 100%;
  font-size: 0.5rem; color: #00ff88;
  line-height: 2.2; letter-spacing: 0.5px; text-align: center;
}
.dev-launch-btn {
  background: rgba(0,255,136,0.15) !important;
  border-color: #00ff88 !important;
  color: #00ff88 !important;
  font-size: 0.65rem !important;
}
.dev-launch-btn:hover { background: rgba(0,255,136,0.3) !important; }

/* DEV badge in HUD */
.hud-dev {
  background: #00ff88; color: #000;
  font-size: 0.5rem; padding: 2px 6px;
  letter-spacing: 1px; font-weight: bold;
  animation: devBlink 2s step-end infinite;
}
@keyframes devBlink { 0%,49%{ opacity:1; } 50%,100%{ opacity:0.5; } }

/* ═══════════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════════ */
#game-screen { justify-content: flex-start; gap: 0; }

.hud-bar {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-secondary);
  border-bottom: var(--pixel-sm) solid var(--bg-surface-alt);
  font-size: 0.65rem; z-index: 20; flex-shrink: 0;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: var(--sp-md); }
.hud-hearts { color: var(--primary); font-size: 0.75rem; letter-spacing: 2px; }
.hud-player { color: var(--gold); }
.hud-chapter { color: var(--secondary); }
.hud-easter { color: var(--accent); font-size: 0.58rem; }

#game-viewport { flex: 1; width: 100%; position: relative; overflow: hidden; }
#game-canvas {
  width: 100%; height: 100%; display: block;
  image-rendering: pixelated; image-rendering: crisp-edges;
}

/* Dialog */
.dialog {
  position: absolute;
  bottom: var(--sp-md); left: var(--sp-md); right: var(--sp-md);
  padding: var(--sp-md); max-height: 40%; z-index: 100;
  cursor: pointer; animation: dialogSlideUp 0.3s ease;
}
@keyframes dialogSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.dialog-speaker { font-size: 0.65rem; color: var(--gold); margin-bottom: var(--sp-sm); letter-spacing: 1px; }
.dialog-text { font-size: 0.63rem; line-height: 2; color: var(--text); min-height: 3em; }
.dialog-continue {
  font-size: 0.55rem; color: var(--text-muted);
  text-align: right; margin-top: var(--sp-sm);
  background: rgba(255,255,255,0.1);
  padding: 4px 8px; border-radius: 4px;
  display: inline-block; float: right;
  animation: pulse 1.5s infinite;
}
.dialog-continue:hover {
  background: rgba(255,255,255,0.2);
  color: var(--text-main);
}
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* Chapter Select Overlay */
#chapter-select {
  position: absolute; inset: 0;
  background: var(--overlay); z-index: 25;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--sp-xl); gap: var(--sp-lg);
}
.chapter-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md); width: 100%; max-width: 500px;
}
.chapter-card {
  padding: var(--sp-md); text-align: center;
  font-size: 0.45rem; cursor: pointer;
  transition: all var(--t-fast);
  display: flex; flex-direction: column;
  gap: var(--sp-sm); align-items: center;
}
.chapter-card .chapter-num { font-size: 1.2rem; display: block; }
.chapter-card .chapter-name { color: var(--text-dim); line-height: 1.6; }
.chapter-card.unlocked { border-color: var(--accent); }
.chapter-card.unlocked:hover { background: var(--bg-surface-alt); transform: scale(1.05); }
.chapter-card.locked { opacity: 0.4; cursor: not-allowed; border-color: var(--text-muted); }
.chapter-card.locked .chapter-num::after { content: '🔒'; font-size: 0.8rem; }

/* Bottom Nav */
.bottom-nav {
  width: 100%;
  display: flex; justify-content: space-around; align-items: center;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-secondary);
  border-top: var(--pixel-sm) solid var(--bg-surface-alt);
  flex-shrink: 0;
}
.nav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; padding: var(--sp-sm);
  transition: transform var(--t-fast); filter: grayscale(0.3);
}
.nav-btn:hover { transform: scale(1.2); filter: grayscale(0); }
.nav-btn:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════════════════════════ */
.loading-content {
  display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-lg);
}
.pixel-spinner {
  width: 32px; height: 32px;
  background: var(--primary);
  animation: spinnerRotate 1s steps(4) infinite;
  box-shadow: 0 0 0 var(--pixel-sm) var(--secondary), 0 0 20px var(--primary);
}
@keyframes spinnerRotate { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.loading-text { font-size: 0.65rem; color: var(--text-dim); letter-spacing: 2px; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .game-title { font-size: 1.1rem; }
  .login-box { padding: var(--sp-xl) var(--sp-md); }
  .hud-bar { font-size: 0.52rem; }
  .mode-cards { grid-template-columns: 1fr 1fr; gap: var(--sp-md); }
  .mode-card { min-width: unset; }
  .mode-title { font-size: 0.72rem; }
}
@media (max-width: 380px) {
  .mode-cards { grid-template-columns: 1fr; }
}
@media (max-height: 500px) {
  .menu-heart-big { width: 32px; height: 28px; }
  .menu-game-title { font-size: 0.65rem; }
  .menu-buttons { gap: var(--sp-xs); }
  .menu-btn { padding: var(--sp-sm) var(--sp-md); }
  .touch-controls { height: 110px; }
  .touch-btn { width: 48px; height: 48px; }
}

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-surface-alt); }

/* ─── Touch / On-screen Controls ──────────────────────────── */
.touch-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 150px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 16px 14px;
  pointer-events: none;
  z-index: 22;
}

/* Auto-hide on non-touch devices via CSS, JS can override */
@media (hover: hover) and (pointer: fine) {
  /* Desktop: hidden unless JS adds .force-show */
  .touch-controls:not(.force-show) {
    display: none;
  }
}

.touch-left-pad,
.touch-right-pad {
  display: flex;
  gap: 4px;
  align-items: center;
  pointer-events: all;
}

/* D-pad cross layout */
.touch-dpad-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.touch-btn {
  width: 58px; height: 58px;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.45);
  background: rgba(15, 14, 23, 0.65);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 80ms, transform 80ms, border-color 80ms;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.touch-btn:active,
.touch-btn.pressed {
  transform: scale(0.85);
  background: rgba(255, 107, 151, 0.50);
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary);
}

.touch-move  { border-color: rgba(255,255,255,0.55); }
.touch-jump {
  width: 56px; height: 56px;
  background: rgba(127,90,240,0.40);
  border-color: rgba(127,90,240,0.85);
}
.touch-jump.pressed  { background: rgba(127,90,240,0.75); }

.touch-down {
  width: 56px; height: 56px;
  background: rgba(44,182,125,0.25);
  border-color: rgba(44,182,125,0.7);
  color: #6ee7b7;
}
.touch-down.pressed { background: rgba(44,182,125,0.55); }

.touch-defend {
  width: 62px; height: 62px;
  background: rgba(127,90,240,0.30);
  border-color: rgba(167,139,250,0.80);
  color: #c4b5fd;
  font-size: 1.3rem;
}
.touch-defend.pressed { background: rgba(127,90,240,0.65); box-shadow: 0 0 14px #7f5af0; }

.touch-attack {
  width: 62px; height: 62px;
  background: rgba(255,70,30,0.30);
  border-color: rgba(255,100,50,0.80);
  color: #fca97a;
  font-size: 1.3rem;
}
.touch-attack.pressed { background: rgba(255,70,30,0.65); box-shadow: 0 0 14px #ff4500; }

/* ─── Photo Frame Overlay ─────────────────────────────────── */
#photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 20, 0.88);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
  padding: var(--sp-xl);
  cursor: pointer;
  animation: dialogSlideUp 0.3s ease;
}
#photo-overlay img {
  max-width: min(90vw, 420px);
  max-height: 55vh;
  object-fit: contain;
  border: 4px solid var(--border);
  box-shadow:
    0 0 0 8px var(--bg-surface),
    0 0 0 10px var(--primary),
    0 0 40px rgba(255,107,151,0.35);
  image-rendering: auto;
}
#photo-overlay .photo-caption {
  font-size: 0.58rem;
  color: var(--primary-glow);
  text-align: center;
  letter-spacing: 2px;
  line-height: 2;
  max-width: 340px;
}
#photo-overlay .photo-close-hint {
  font-size: 0.42rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,49%{opacity:1} 50%,100%{opacity:0} }

/* ─── Enemy Health Bar ────────────────────────────────────── */
.enemy-hpbar-bg {
  position: absolute;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 2px;
}
.enemy-hpbar-fill {
  background: var(--danger);
  border-radius: 2px;
  transition: width 0.1s;
}

/* ─── Collectible item drop glow ─────────────────────────── */
.item-drop-pulse {
  animation: itemPulse 0.8s ease-in-out infinite alternate;
}
@keyframes itemPulse {
  from { filter: drop-shadow(0 0 4px var(--gold)); }
  to   { filter: drop-shadow(0 0 14px var(--gold)); }
}

/* ─── Mode chapter tutorial badge ─────────────────────────── */
.mode-chapter--tutorial {
  background: rgba(249,199,79,0.15);
  border-color: rgba(249,199,79,0.5);
  color: var(--gold);
}
