/* ============================================
   style.css — Portfolio Datacenter
   ============================================ */

:root {
  /* Primary palette */
  --neon-blue:       #00cfff;
  --neon-green:      #7fffb2;
  --neon-pink:       #ff4488;
  --neon-purple:     #8844ff;
  --neon-orange:     #ff6644;
  --neon-yellow:     #ffcc00;

  /* Backgrounds */
  --dark-bg:         #000510;
  --mid-dark:        #050d1a;
  --header-bg:       rgba(10, 15, 30, 0.95);

  /* Terminal */
  --terminal-green:  #7fffb2;

  /* Status colors */
  --color-error:     #ff5f56;
  --color-warning:   #ffbd2e;
  --color-success:   #27c93f;

  /* Gradients helpers */
  --neon-blue-dark:  #0088cc;
  --neon-green-dark: #44aa77;

  /* Notification badge */
  --notif-red:       #ff3b30;
}

/* ---- WebGL fallback ---- */
#webgl-fallback {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--dark-bg);
  color: var(--neon-green);
  font-family: 'JetBrains Mono', monospace;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  padding: 2rem;
  z-index: 9999;
}
.wf-icon  { font-size: 2rem; }
.wf-title { font-size: 1.1rem; font-weight: bold; }
.wf-body  { font-size: 0.85rem; opacity: 0.7; max-width: 360px; }
.wf-link  { color: var(--neon-blue); font-size: 0.85rem; }

/* ============================================
   LIGHT MODE — [data-theme="light"]
   ============================================ */
[data-theme="light"] {
  --neon-blue:       #0077bb;
  --neon-green:      #00995c;
  --neon-pink:       #cc1166;
  --neon-purple:     #6622cc;
  --neon-orange:     #cc4400;
  --neon-yellow:     #cc8800;
  --dark-bg:         #eef2f9;
  --mid-dark:        #d8e2f0;
  --header-bg:       rgba(215, 228, 245, 0.97);
  --terminal-green:  #00884d;
  --color-error:     #cc2200;
  --color-warning:   #cc8800;
  --color-success:   #007744;
  --neon-blue-dark:  #005588;
  --neon-green-dark: #006633;
  --notif-red:       #cc2200;
}

[data-theme="light"] body {
  color: #0a1628;
}

/* Terminal keeps dark bg in light mode — terminals are always dark */
[data-theme="light"] #terminal-overlay,
[data-theme="light"] #mini-terminal {
  background: #111827;
  border-color: rgba(0, 153, 92, 0.4);
}

[data-theme="light"] #terminal-header {
  background: rgba(15, 23, 42, 0.98);
  border-bottom-color: rgba(0, 153, 92, 0.25);
}

/* Phone overlay adapts to light */
[data-theme="light"] #phone-frame {
  background: #dce8f5;
  border-color: rgba(0, 119, 187, 0.4);
  box-shadow: 0 20px 60px rgba(0, 50, 100, 0.25), 0 0 0 1px rgba(0, 119, 187, 0.2);
}

[data-theme="light"] #phone-statusbar {
  background: rgba(200, 220, 245, 0.95);
  color: #0a1628;
  border-bottom-color: rgba(0, 119, 187, 0.2);
}

[data-theme="light"] .phone-screen {
  background: #eef4fc;
  color: #0a1628;
}

[data-theme="light"] #phone-apps {
  background: transparent;
}

[data-theme="light"] .phone-app span {
  color: #0a1628;
}

[data-theme="light"] #phone-music {
  background: linear-gradient(180deg, #d0e4f5, #e8f2fc);
}

[data-theme="light"] #contact-form input,
[data-theme="light"] #contact-form textarea {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 119, 187, 0.3);
  color: #0a1628;
}

[data-theme="light"] .legal-text p,
[data-theme="light"] .credits-text {
  color: #1a2e4a;
}

[data-theme="light"] .phone-app-title {
  color: #0a1628;
  border-bottom-color: rgba(0, 119, 187, 0.25);
}

[data-theme="light"] #phone-navbar {
  background: rgba(200, 220, 245, 0.9);
  border-top-color: rgba(0, 119, 187, 0.2);
}

/* Phone trigger button */
[data-theme="light"] #phone-btn {
  background: rgba(200, 220, 245, 0.9);
  border-color: rgba(0, 100, 180, 0.35);
  color: #0055aa;
  box-shadow: 0 0 20px rgba(0, 100, 180, 0.12), 0 4px 15px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] #phone-btn:hover {
  border-color: #0077bb;
  box-shadow: 0 0 28px rgba(0, 100, 180, 0.22), 0 4px 18px rgba(0, 0, 0, 0.15);
}

/* Scroll indicator */
[data-theme="light"] #scroll-indicator {
  color: #0a1628;
}

/* Mini terminal btn */
[data-theme="light"] #mini-terminal-btn {
  color: var(--neon-green);
  border-color: rgba(0, 153, 92, 0.4);
  background: rgba(238, 242, 249, 0.9);
}

/* Achievement toast */
[data-theme="light"] #achievement-toast {
  background: rgba(220, 235, 250, 0.97);
  border-color: rgba(0, 119, 187, 0.4);
  color: #0a1628;
}

/* Music app — light mode
   IMPORTANT: selectors must include #phone-music to beat dark-mode specificity
   (dark mode uses "#phone-music #music-controls button" = 2 IDs, so we need the same) */
[data-theme="light"] #phone-music #music-track-name {
  color: #0a1628;
}
[data-theme="light"] #phone-music #music-track-artist {
  color: rgba(10, 22, 40, 0.72);
}
[data-theme="light"] #phone-music #music-controls button,
[data-theme="light"] #phone-music #music-volume button {
  color: #0a1628;
}
[data-theme="light"] #phone-music #music-controls button:hover {
  color: #0055aa;
}
[data-theme="light"] #phone-music #music-progress-bar {
  background: rgba(10, 22, 40, 0.22);
  height: 6px;
}
[data-theme="light"] #phone-music #music-volume-bar {
  background: rgba(10, 22, 40, 0.22);
}
[data-theme="light"] #phone-music #music-progress-fill {
  background: linear-gradient(90deg, #0055aa, #006e3c);
}
[data-theme="light"] #phone-music #music-volume-fill {
  background: linear-gradient(90deg, #006e3c, #0055aa);
}
[data-theme="light"] #phone-music #music-play {
  border-color: #0055aa !important;
  color: #0a1628 !important;
  background: rgba(0, 85, 170, 0.1);
}
[data-theme="light"] #phone-music #music-play:hover {
  border-color: #003d80 !important;
  background: rgba(0, 85, 170, 0.18);
  color: #0a1628 !important;
}
/* Trophy / Achievements in light mode */
[data-theme="light"] .achievement-item.unlocked {
  background: rgba(0, 100, 180, 0.08);
  border-color: rgba(0, 100, 180, 0.35);
}
[data-theme="light"] .achievement-item.locked {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .achievement-name {
  color: #0050a0;
}
[data-theme="light"] .achievement-item.locked .achievement-name {
  color: rgba(0, 40, 80, 0.35);
}
[data-theme="light"] .achievement-desc {
  color: rgba(10, 22, 40, 0.65);
}
[data-theme="light"] .achievements-counter {
  color: #005a28;
  border-top-color: rgba(0, 0, 0, 0.1);
}

/* Contact form */
[data-theme="light"] #contact-form input::placeholder,
[data-theme="light"] #contact-form textarea::placeholder {
  color: rgba(10, 22, 40, 0.35);
}

/* Legal */
[data-theme="light"] .legal-text {
  color: rgba(10, 22, 40, 0.75);
}
[data-theme="light"] .legal-link {
  color: rgba(10, 22, 40, 0.7);
  background: rgba(10, 22, 40, 0.04);
  border-color: rgba(0, 119, 187, 0.15);
}
[data-theme="light"] .legal-link:hover {
  background: rgba(0, 119, 187, 0.08);
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}

/* Credits */
[data-theme="light"] .credit-item {
  color: rgba(10, 22, 40, 0.8);
}
[data-theme="light"] .credit-source {
  color: rgba(10, 22, 40, 0.45);
}
[data-theme="light"] .credit-section {
  border-bottom-color: rgba(10, 22, 40, 0.08);
}

/* ---- Theme flash overlay ---- */
#theme-flash {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: 9998;
}

/* ---- Breaker switch ---- */
#theme-switch {
  position: fixed;
  top: 1.4rem;
  right: 1.4rem;
  z-index: 100;
  cursor: pointer;
  outline: none;
  transition: opacity 0.25s ease;
}

#theme-switch:focus-visible .breaker-panel {
  box-shadow: 0 0 0 2px var(--neon-blue), 0 4px 16px rgba(0,0,0,0.5);
}

.breaker-panel {
  width: 48px;
  background: linear-gradient(180deg, #1c2a3a 0%, #0d1520 100%);
  border: 1px solid rgba(127, 255, 178, 0.25);
  border-radius: 8px;
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#theme-switch:hover .breaker-panel {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.08);
}

#theme-switch:active .breaker-panel {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.breaker-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.42rem;
  letter-spacing: 0.12em;
  color: rgba(127, 255, 178, 0.55);
  text-transform: uppercase;
}

.breaker-track {
  width: 18px;
  height: 34px;
  background: #080e18;
  border-radius: 4px;
  border: 1px solid rgba(127, 255, 178, 0.12);
  position: relative;
}

.breaker-lever {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 3px;
  width: 12px;
  height: 14px;
  background: linear-gradient(180deg, #6b7280, #374151);
  border-radius: 3px;
  border-top: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  transition: top 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.breaker-lever.is-on {
  top: calc(100% - 17px);
}

.breaker-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-error);
  box-shadow: 0 0 5px var(--color-error), 0 0 10px rgba(255,95,86,0.3);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.breaker-indicator.is-on {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success), 0 0 12px rgba(39,201,63,0.4);
}

.breaker-state {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.42rem;
  letter-spacing: 0.1em;
  color: rgba(127, 255, 178, 0.45);
}

/* Light mode: panel gets a metallic bright look */
[data-theme="light"] .breaker-panel {
  background: linear-gradient(180deg, #b8cce0 0%, #96afc8 100%);
  border-color: rgba(0, 119, 187, 0.35);
  box-shadow: 0 4px 20px rgba(0, 50, 100, 0.3), inset 0 1px 0 rgba(255,255,255,0.5);
}

[data-theme="light"] .breaker-label,
[data-theme="light"] .breaker-state {
  color: rgba(0, 50, 100, 0.7);
}

[data-theme="light"] .breaker-track {
  background: #1a2a3a;
  border-color: rgba(0, 119, 187, 0.2);
}

/* Mobile: smaller switch — z-index elevated, safe-area-aware */
@media (max-width: 768px) {
  #theme-switch {
    top: max(0.9rem, env(safe-area-inset-top, 0px) + 0.5rem);
    right: 0.9rem;
    z-index: 600;
    touch-action: manipulation;
  }
  .breaker-panel {
    width: 40px;
    padding: 6px 0 5px;
    gap: 4px;
    /* More visible on mobile: stronger border + glow */
    border-color: rgba(127, 255, 178, 0.55);
    box-shadow: 0 0 10px rgba(127, 255, 178, 0.2), 0 3px 12px rgba(0,0,0,0.7);
  }
  .breaker-track  { width: 15px; height: 28px; }
  .breaker-lever  { width: 10px; height: 12px; }
  .breaker-lever.is-on { top: calc(100% - 15px); }
  .breaker-indicator { width: 7px; height: 7px; }
  [data-theme="light"] .breaker-panel {
    border-color: rgba(0, 119, 187, 0.55);
    box-shadow: 0 0 10px rgba(0, 119, 187, 0.25), 0 3px 12px rgba(0,0,0,0.3);
  }
}

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

html {
  overflow-x: hidden;
  overflow-y: scroll;
  background: var(--dark-bg);
}

body {
  overflow-x: hidden;
  background: var(--dark-bg);
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-x pan-y;
}

/* ---- Canvas ---- */
#three-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  /* Prevent double-tap zoom on canvas */
  touch-action: none;
}

/* ---- Scroll spacer ---- */
#scroll-spacer {
  position: relative;
  z-index: 1;
  height: 500vh;
  pointer-events: none;
}

/* ---- Loading screen ---- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--dark-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

#loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-inner {
  text-align: center;
}

.loader-title {
  font-family: 'Orbitron', monospace;
  font-size: 2rem;
  font-weight: 900;
  color: var(--neon-blue);
  text-shadow: 0 0 20px rgba(0, 207, 255, 0.5);
  letter-spacing: 0.3em;
  margin-bottom: 2rem;
}

.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.loader-bar-container {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 1rem;
}

.loader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-green));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.loader-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.1em;
}

/* ---- Scroll indicator ---- */
#scroll-indicator {
  position: fixed;
  bottom: max(2rem, env(safe-area-inset-bottom, 0px) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  text-align: center;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#scroll-indicator span {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.arrow-down {
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border-right: 2px solid var(--neon-blue);
  border-bottom: 2px solid var(--neon-blue);
  transform: rotate(45deg);
  animation: bounce 2s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50%      { transform: rotate(45deg) translateY(8px); }
}

/* ---- Terminal overlay ---- */
#terminal-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 750px;
  max-width: 92vw;
  height: 480px;
  max-height: 75vh;
  max-height: 75dvh;
  z-index: 100;
  border-radius: 10px;
  overflow: hidden;
  touch-action: pan-y; /* prevent horizontal swipe on the overlay */
  border: 1px solid rgba(127, 255, 178, 0.3);
  box-shadow:
    0 0 40px rgba(0, 207, 255, 0.15),
    0 0 80px rgba(0, 5, 16, 0.8),
    inset 0 0 60px rgba(0, 5, 16, 0.4);
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#terminal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.95);
}

/* Scanline effect */
#terminal-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 100, 0.015) 2px,
    rgba(0, 255, 100, 0.015) 4px
  );
  pointer-events: none;
  z-index: 2;
}

#terminal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(127, 255, 178, 0.15);
}

/* Terminal close button — visible on all devices */
#terminal-mobile-close {
  display: inline-block;
  margin-left: auto;
  background: rgba(255, 95, 86, 0.15);
  border: 1px solid var(--color-error);
  border-radius: 6px;
  color: var(--color-error);
  font-size: 0.9rem;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.2s;
}
#terminal-mobile-close:hover {
  background: rgba(255, 95, 86, 0.28);
}
#terminal-mobile-close:active {
  background: rgba(255, 95, 86, 0.35);
}

/* Snake fullscreen mode on mobile */
/* Game mode transition (applied before size changes) */
#terminal-overlay.snake-fullscreen,
#terminal-overlay.game-mode {
  transition: width 0.35s ease, height 0.35s ease,
              top 0.35s ease, left 0.35s ease,
              transform 0.35s ease, border-radius 0.35s ease,
              max-width 0.35s ease, max-height 0.35s ease;
}

/* snake-fullscreen: legacy mobile fullscreen (unchanged) */
#terminal-overlay.snake-fullscreen {
  top: 0;
  left: 0;
  transform: none;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  z-index: 200;
}

/* game-mode: desktop expand */
@media (min-width: 769px) {
  #terminal-overlay.game-mode {
    width: 90vw;
    max-width: 90vw;
    height: 88vh;
    max-height: 88vh;
  }
}

/* game-mode: mobile fullscreen */
@media (max-width: 768px) {
  #terminal-overlay.game-mode {
    top: 0;
    left: 0;
    transform: none;
    width: 100vw;
    max-width: 100vw;
    /* 100lvh = large viewport height (browser bar hidden), fallback to 100vh */
    height: 100vh;
    height: 100lvh;
    max-height: 100vh;
    max-height: 100lvh;
    border-radius: 0;
    z-index: 200;
  }
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot.red    { background: var(--color-error); }
.dot.yellow { background: var(--color-warning); }
.dot.green  { background: var(--color-success); }

.terminal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

#terminal-body {
  height: calc(100% - 38px);
  background: rgba(0, 5, 16, 0.95);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  position: relative;
}

#terminal-output {
  flex: 1;
  min-height: 0; /* allow flex child to shrink below content size */
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y; /* iOS: no horizontal swipe on the terminal output */
  font-family: 'VT323', 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--terminal-green);
  text-shadow: 0 0 6px rgba(127, 255, 178, 0.3);
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(127, 255, 178, 0.2) transparent;
  padding: 0.5rem 0.75rem 0.75rem;
}

#terminal-output::-webkit-scrollbar {
  width: 6px;
}
#terminal-output::-webkit-scrollbar-track {
  background: transparent;
}
#terminal-output::-webkit-scrollbar-thumb {
  background: rgba(127, 255, 178, 0.2);
  border-radius: 3px;
}

#terminal-output .cmd-line {
  color: var(--neon-blue);
}
#terminal-output .error {
  color: var(--color-error);
}
#terminal-output .highlight {
  color: var(--neon-blue);
}
#terminal-output .success {
  color: var(--neon-green);
}
#terminal-output .warning {
  color: var(--color-warning);
}

#terminal-input-line {
  display: flex;
  align-items: center;
  font-family: 'VT323', 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: var(--terminal-green);
  text-shadow: 0 0 6px rgba(127, 255, 178, 0.3);
  margin-top: 0.25rem;
}

.prompt {
  white-space: nowrap;
  color: var(--neon-blue);
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--terminal-green);
  font-family: 'VT323', 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  text-shadow: 0 0 6px rgba(127, 255, 178, 0.3);
  caret-color: var(--terminal-green);
}

/* ---- Quick keys bar (terminal shortcuts) ---- */
#terminal-quickkeys {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(127, 255, 178, 0.1);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#terminal-quickkeys::-webkit-scrollbar { display: none; }

.qk-btn {
  flex-shrink: 0;
  background: rgba(127, 255, 178, 0.08);
  border: 1px solid rgba(127, 255, 178, 0.25);
  border-radius: 6px;
  color: var(--terminal-green);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.qk-btn:hover {
  background: rgba(127, 255, 178, 0.18);
}
.qk-btn:active {
  background: rgba(127, 255, 178, 0.28);
}

/* ---- Phone trigger button ---- */
#phone-btn {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 0px) + 0.75rem);
  right:  max(1.5rem, env(safe-area-inset-right,  0px) + 0.75rem);
  z-index: 100;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(0, 207, 255, 0.3);
  background: rgba(5, 13, 26, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--neon-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 207, 255, 0.15), 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  animation: phonePulse 3s ease-in-out infinite;
}

#phone-btn:hover {
  transform: scale(1.1);
  border-color: var(--neon-blue);
  box-shadow: 0 0 30px rgba(0, 207, 255, 0.3), 0 4px 20px rgba(0, 0, 0, 0.5);
}

#phone-btn svg {
  width: 22px;
  height: 22px;
}

@keyframes phonePulse {
  0%, 100% { box-shadow: 0 0 20px rgba(0, 207, 255, 0.15), 0 4px 15px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 30px rgba(0, 207, 255, 0.3), 0 4px 20px rgba(0, 0, 0, 0.5); }
}

/* ---- Phone overlay ---- */
#phone-overlay {
  position: fixed;
  bottom: 5rem;
  right: 1.5rem;
  z-index: 99;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#phone-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px) scale(0.95);
}

#phone-frame {
  width: 260px;
  height: 460px;
  background: rgba(8, 12, 24, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(0, 207, 255, 0.25);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 40px rgba(0, 207, 255, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ---- Phone status bar ---- */
#phone-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

#phone-carrier {
  font-size: 0.6rem;
  color: var(--neon-blue);
  opacity: 0.7;
}

/* Battery — low blink animation */
@keyframes batteryBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}
#phone-battery[data-low] {
  animation: batteryBlink 1s ease-in-out infinite;
}
#phone-battery {
  transition: color 0.4s ease;
  user-select: none;
}

/* ---- Phone screens ---- */
.phone-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 207, 255, 0.2) transparent;
}

.phone-screen.active {
  display: flex;
}

/* ---- Home screen app grid ---- */
#phone-apps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.5rem 0.5rem;
  align-content: center;
  flex: 1;
}

.phone-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0.75rem;
  border-radius: 12px;
  transition: background 0.2s, transform 0.15s;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

.phone-app:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: scale(1.05);
}

.phone-app:active {
  transform: scale(0.95);
}

.app-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.music-icon {
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-orange));
}
.music-icon::after { content: '\1F3B5'; }

.contact-icon {
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-blue-dark));
}
.contact-icon::after { content: '\2709'; font-size: 1.5rem; }

.legal-icon {
  background: linear-gradient(135deg, var(--neon-green), var(--neon-green-dark));
}
.legal-icon::after { content: '\1F4DC'; }

.credits-icon {
  background: linear-gradient(135deg, var(--neon-yellow), var(--neon-orange));
}
.credits-icon::after { content: '\2B50'; }

.achievements-icon {
  background: linear-gradient(135deg, var(--neon-pink), var(--neon-purple));
}
.achievements-icon::after { content: '\1F3C6'; }

/* ---- Phone navbar ---- */
#phone-navbar {
  padding: 0.5rem;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#phone-home-btn {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  cursor: pointer;
  transition: background 0.2s, width 0.2s;
}

#phone-home-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  width: 50px;
}

/* ---- Phone app title ---- */
.phone-app-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--neon-blue);
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 207, 255, 0.15);
}

/* ---- Music app (inside phone) ---- */
#phone-music #music-album-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-pink));
  margin-bottom: 0.75rem;
  overflow: hidden;
}

#phone-music #music-info {
  margin-bottom: 0.5rem;
  text-align: center;
}

#phone-music #music-track-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.15rem;
}

#phone-music #music-track-artist {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.4);
}

#phone-music #music-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  cursor: pointer;
}

#phone-music #music-progress-bar:hover {
  height: 6px;
}

#phone-music #music-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-green));
  border-radius: 2px;
  transition: width 0.1s linear;
}

#phone-music #music-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}

#phone-music #music-controls button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.4rem;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
}

#phone-music #music-controls button:hover {
  color: var(--neon-blue);
  transform: scale(1.15);
}

#phone-music #music-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

#phone-music #music-play:hover {
  border-color: var(--neon-blue) !important;
}

#phone-music #music-volume {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#phone-music #music-volume button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.2s;
}

#phone-music #music-volume button:hover {
  color: var(--neon-blue);
}

#phone-music #music-volume-bar {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

#phone-music #music-volume-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--neon-green), var(--neon-blue));
  border-radius: 2px;
  transition: width 0.15s;
}

/* ---- Contact form (inside phone) ---- */
#contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#contact-form input,
#contact-form textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 207, 255, 0.15);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}

#contact-form input:focus,
#contact-form textarea:focus {
  border-color: var(--neon-blue);
}

#contact-form input::placeholder,
#contact-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

#contact-submit {
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-blue-dark));
  border: none;
  border-radius: 8px;
  padding: 0.65rem;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  letter-spacing: 0.1em;
}

#contact-submit:hover {
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(0, 207, 255, 0.3);
}

#contact-submit:active {
  transform: scale(0.98);
}

#contact-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1.2rem;
}

/* ---- Legal links (inside phone) ---- */
.legal-links {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.legal-link {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(127, 255, 178, 0.1);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.legal-link:hover {
  background: rgba(127, 255, 178, 0.05);
  border-color: var(--neon-green);
  color: var(--neon-green);
}

/* ---- Legal text content ---- */
.legal-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.65);
}

.legal-text p {
  margin-bottom: 0.5rem;
}

.legal-text strong {
  color: var(--neon-blue);
}

/* ---- Credits screen (inside phone) ---- */
.credits-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.65);
}

.credit-section {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.credit-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.credit-category {
  color: var(--neon-blue);
  font-weight: 700;
  font-size: 0.65rem;
  margin-bottom: 0.25rem;
}

.credit-item {
  color: rgba(255, 255, 255, 0.75);
  padding-left: 0.5rem;
}

.credit-source {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.55rem;
  padding-left: 0.5rem;
  margin-top: 0.1rem;
}

/* ---- Boot animation for terminal ---- */
@keyframes terminalBoot {
  0%   { opacity: 0; filter: brightness(3); }
  30%  { opacity: 1; filter: brightness(1.5); }
  50%  { opacity: 0.8; filter: brightness(0.8); }
  70%  { opacity: 1; filter: brightness(1.2); }
  100% { opacity: 1; filter: brightness(1); }
}

#terminal-overlay.booting {
  animation: terminalBoot 0.6s ease-out;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  /* Show the terminal close button on mobile */
  #terminal-mobile-close {
    display: inline-block;
  }

  #terminal-overlay {
    /* Ancrage en haut : évite le centrage vertical qui passe sous le clavier */
    top: env(safe-area-inset-top, 0px);
    transform: translateX(-50%);
    width: 95vw;
    height: 60vh;
    height: 60dvh;
    border-radius: 0 0 12px 12px;
  }

  /* Override de l'état hidden pour correspondre au nouvel ancrage */
  #terminal-overlay.hidden {
    transform: translateX(-50%) scale(0.97);
  }

  #terminal-output {
    font-size: 0.95rem;
    -webkit-overflow-scrolling: touch;
  }

  #terminal-input {
    font-size: 16px; /* prevent iOS auto-zoom on focus (must be ≥ 16px) */
  }

  /* Scrollable phone screens on mobile */
  .phone-screen {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }

  /* Scrollable mini terminal output on mobile */
  #mini-terminal-output {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }

  #phone-btn {
    bottom: max(1.5rem, env(safe-area-inset-bottom, 0px) + 0.75rem);
    right:  max(1rem,   env(safe-area-inset-right,  0px) + 0.5rem);
    width: 44px;
    height: 44px;
  }

  #phone-overlay {
    bottom: 4rem;
    right: 1rem;
  }

  #phone-frame {
    width: 240px;
    height: 420px;
  }

  #scroll-indicator span {
    font-size: 0.65rem;
  }
}

@media (max-width: 480px) {
  .loader-title {
    font-size: 1.4rem;
    letter-spacing: 0.15em;
  }

  .loader-bar-container {
    width: 200px;
  }

  #terminal-overlay {
    height: 55vh;
  }

  #phone-frame {
    width: 220px;
    height: 400px;
  }
}

/* ---- Rotate overlay — mobile landscape bloqué ---- */
#rotate-overlay {
  display: none; /* caché par défaut */
}

@media (orientation: landscape) and (max-width: 1024px) {
  /* Bloquer le paysage : couvrir tout l'écran */
  #rotate-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000510;
    color: var(--terminal-green);
    font-family: 'VT323', monospace;
    text-align: center;
    padding: 2rem;
  }
  .ro-icon {
    font-size: 3.5rem;
    animation: ro-spin 2s ease-in-out infinite;
  }
  .ro-title {
    font-size: 1.8rem;
    letter-spacing: 0.05em;
  }
  .ro-body {
    font-size: 1.1rem;
    opacity: 0.6;
    font-family: 'JetBrains Mono', monospace;
  }
}

@keyframes ro-spin {
  0%, 100% { transform: rotate(0deg);   }
  40%       { transform: rotate(90deg);  }
  60%       { transform: rotate(90deg);  }
}

/* ---- Achievements app ---- */
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0.5rem;
  overflow-y: auto;
  max-height: 280px;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
}

.achievement-item.unlocked {
  background: rgba(0, 207, 255, 0.1);
  border: 1px solid rgba(0, 207, 255, 0.3);
}

.achievement-item.locked {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0.5;
}

.achievement-icon {
  font-size: 1.2rem;
  min-width: 24px;
  text-align: center;
}

.achievement-info {
  flex: 1;
  min-width: 0;
}

.achievement-name {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 0.65rem;
  color: var(--neon-blue);
}

.achievement-item.locked .achievement-name {
  color: rgba(255, 255, 255, 0.3);
}

.achievement-desc {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 1px;
}

.achievements-counter {
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  color: var(--neon-green);
  padding: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---- Achievement notification toast ---- */
#achievement-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 5, 16, 0.95);
  border: 1px solid var(--neon-blue);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 20px rgba(0, 207, 255, 0.3);
  pointer-events: none;
}

#achievement-toast.show {
  transform: translateX(0);
}

#achievement-toast .toast-icon {
  font-size: 1.5rem;
}

#achievement-toast .toast-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  color: var(--neon-blue);
}

#achievement-toast .toast-label {
  font-size: 0.55rem;
  color: var(--neon-green);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---- Phone notification badge ---- */
.phone-app {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--notif-red);
  border-radius: 50%;
  font-size: 0.5rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ---- Mini terminal ---- */
#mini-terminal-btn {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 0px) + 0.75rem);
  left:   max(1.5rem, env(safe-area-inset-left,   0px) + 0.75rem);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--neon-green);
  background: rgba(0, 5, 16, 0.85);
  color: var(--neon-green);
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 500;
  transition: all 0.2s, opacity 0.25s ease;
  backdrop-filter: blur(8px);
}

#mini-terminal-btn:hover {
  background: rgba(127, 255, 178, 0.15);
  box-shadow: 0 0 15px rgba(127, 255, 178, 0.3);
}

#mini-terminal {
  position: fixed;
  bottom: 5rem;
  left: 1.5rem;
  width: 380px;
  max-width: calc(100vw - 3rem);
  background: rgba(0, 5, 16, 0.95);
  border: 1px solid var(--neon-green);
  border-radius: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0, 5, 16, 0.8), 0 0 20px rgba(127, 255, 178, 0.1);
  backdrop-filter: blur(12px);
}

#mini-terminal.hidden {
  display: none;
}

#mini-terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(127, 255, 178, 0.08);
  border-bottom: 1px solid rgba(127, 255, 178, 0.15);
  font-family: 'VT323', monospace;
  font-size: 0.8rem;
  color: var(--neon-green);
}

#mini-terminal-close {
  background: none;
  border: none;
  color: var(--color-error);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#mini-terminal-output {
  padding: 8px 12px;
  font-family: 'VT323', monospace;
  font-size: 0.8rem;
  color: var(--neon-green);
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.4;
}

#mini-terminal-output .highlight { color: var(--neon-blue); }
#mini-terminal-output .success { color: var(--neon-green); }
#mini-terminal-output .warning { color: var(--neon-yellow); }
#mini-terminal-output .error { color: var(--color-error); }
#mini-terminal-output .cmd-line { color: var(--neon-blue); opacity: 0.7; }

#mini-terminal-input-line {
  display: flex;
  align-items: center;
  padding: 6px 12px 8px;
  border-top: 1px solid rgba(127, 255, 178, 0.1);
  font-family: 'VT323', monospace;
  font-size: 0.8rem;
  color: var(--neon-green);
  gap: 6px;
}

#mini-terminal-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--neon-green);
  font-family: 'VT323', monospace;
  font-size: 0.8rem;
  outline: none;
  caret-color: var(--neon-green);
}

#mini-terminal-input::placeholder {
  color: rgba(127, 255, 178, 0.3);
}

@media (max-width: 768px) {
  #mini-terminal-btn {
    bottom: max(1.5rem, env(safe-area-inset-bottom, 0px) + 0.75rem);
    left:   max(1rem,   env(safe-area-inset-left,   0px) + 0.5rem);
    width: 44px;
    height: 44px;
    font-size: 0.9rem;
    /* Prevent iOS double-tap zoom on button */
    touch-action: manipulation;
  }

  #mini-terminal {
    bottom: 4.5rem;
    left: 1rem;
    width: calc(100vw - 2rem);
    /* La transition facilite le repositionnement JS au-dessus du clavier */
    transition: top 0.15s ease, bottom 0.15s ease;
  }

  /* iOS: font-size >= 16px prevents auto-zoom when input is focused */
  #mini-terminal-input,
  #mini-terminal-input-line {
    font-size: 16px;
  }
}

/* ---- Matrix rain overlay (easter egg) ---- */
#matrix-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#matrix-overlay.active {
  opacity: 1;
}

/* ============================================
   GAME-ACTIVE STATE — masquer les boutons flottants pendant un jeu
   ============================================ */

/* Masquer le switch LIGHTS quand le terminal principal est ouvert (mobile) */
@media (max-width: 1024px) {
  body.terminal-open #theme-switch {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  /* Masquer également téléphone et mini terminal button quand terminal serveur ouvert */
  body.terminal-open #phone-btn,
  body.terminal-open #mini-terminal-btn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  /* Masquer LIGHTS quand le mini terminal est ouvert */
  body.mini-open #theme-switch {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
}

/* Masquer mini-terminal et switch quand un jeu est actif */
body.game-active #mini-terminal-btn,
body.game-active #theme-switch {
  opacity: 0;
  pointer-events: none;
}

/* Masquer le bouton du téléphone aussi */
body.game-active #phone-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* Bouton quitter le jeu (garde le terminal ouvert) */
#game-quit-btn {
  display: none; /* affiché via setGameMode(true) uniquement */
  margin-left: auto;
  background: color-mix(in srgb, var(--color-warning) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-warning) 60%, transparent);
  border-radius: 6px;
  color: var(--color-warning);
  font-size: 0.82rem;
  font-weight: bold;
  padding: 3px 10px;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.2s;
  white-space: nowrap;
}
#game-quit-btn:hover  { background: color-mix(in srgb, var(--color-warning) 22%, transparent); }
#game-quit-btn:active { background: color-mix(in srgb, var(--color-warning) 32%, transparent); }

/* Sur mobile, cacher la ligne de commande pendant le jeu (plus d'espace) */
@media (max-width: 768px) {
  body.game-active #terminal-input-line {
    display: none;
  }

  /* Le terminal output prend toute la hauteur disponible */
  body.game-active #terminal-overlay #terminal-output {
    flex: 1;
    min-height: 0;
  }

  /* Jeu Hangman : ASCII art plus petit pour laisser de la place au clavier */
  .hangman-keyboard {
    margin-top: 0.4rem;
  }
  .hangman-key {
    width: 1.85rem;
    height: 1.85rem;
    font-size: 0.62rem;
  }
}

/* ============================================
   MOBILE GAME CONTROLS
   ============================================ */

/* --- Language chooser --- */
.game-lang-btns {
  display: flex;
  gap: 0.6rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}

/* --- Generic tap button (shared by all games) --- */
.game-touch-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--neon-green);
  background: rgba(127, 255, 178, 0.08);
  color: var(--neon-green);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.1s;
}
.game-touch-btn:active { transform: scale(0.95); background: rgba(127, 255, 178, 0.18); }
.game-touch-btn--danger {
  border-color: var(--color-error);
  color: var(--color-error);
  background: rgba(255, 95, 86, 0.07);
}
.game-touch-btn--danger:active { background: rgba(255, 95, 86, 0.18); }

/* --- Hangman keyboard --- */
.hangman-keyboard {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: center;
}
.hangman-key-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: center;
}
.hangman-key {
  width: 2.1rem;
  height: 2.1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid rgba(127, 255, 178, 0.35);
  border-radius: 5px;
  background: rgba(127, 255, 178, 0.06);
  color: var(--neon-green);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.hangman-key:disabled { opacity: 0.35; cursor: default; }
.hangman-key.hk-correct { background: #1e4d2b; border-color: #538d4e; color: #7fffb2; }
.hangman-key.hk-wrong   { background: #3a1020; border-color: #883344; color: #ff4488; opacity: 0.6; }
.hangman-key-actions { gap: 0.5rem; margin-top: 0.2rem; }

/* --- Wordle keyboard --- */
.wordle-keyboard {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: center;
}
.wordle-key-row {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
}
.wordle-key {
  min-width: 1.9rem;
  height: 2.2rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  border: 1px solid rgba(127, 255, 178, 0.3);
  border-radius: 4px;
  background: rgba(127, 255, 178, 0.06);
  color: var(--neon-green);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0 0.25rem;
}
.wordle-key--wide { min-width: 2.6rem; font-size: 0.75rem; }
.wordle-key:disabled { opacity: 0.4; cursor: default; }
.wordle-key.wk-green  { background: #1e4d2b; border-color: #538d4e; color: #fff; }
.wordle-key.wk-yellow { background: #3d3010; border-color: #b59f3b; color: #fff; }
.wordle-key.wk-grey   { background: #222;    border-color: #555;    color: #aaa; }
.wordle-key-actions { gap: 0.5rem; margin-top: 0.3rem; }

/* --- Quiz answer buttons --- */
.quiz-answer-btns {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.quiz-answer-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  border: 1px solid rgba(0, 207, 255, 0.3);
  border-radius: 6px;
  background: rgba(0, 207, 255, 0.05);
  color: #ccc;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.quiz-answer-btn:active { background: rgba(0, 207, 255, 0.15); border-color: var(--neon-blue); }
.quiz-answer-num {
  font-weight: 700;
  color: var(--neon-blue);
  min-width: 1rem;
}

/* --- Type-race mobile input --- */
.typerace-mobile-input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; /* >= 16px prevents iOS auto-zoom */
  background: rgba(0, 207, 255, 0.06);
  border: 1px solid rgba(0, 207, 255, 0.35);
  border-radius: 6px;
  color: var(--neon-blue);
  outline: none;
  caret-color: var(--neon-blue);
  box-sizing: border-box;
}
.typerace-mobile-input:focus { border-color: var(--neon-blue); }
.typerace-mobile-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* ---- Mobile custom scroll indicator ---- */
/* Hidden on desktop (native scrollbar handles it) */
#terminal-scroll-track,
#terminal-scroll-thumb {
  display: none;
  position: absolute;
  right: 3px;
  width: 3px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}
@media (max-width: 768px) {
  #terminal-scroll-track {
    display: block;
    background: rgba(127, 255, 178, 0.07);
  }
  #terminal-scroll-thumb {
    display: block;
    background: rgba(127, 255, 178, 0.45);
    box-shadow: 0 0 4px rgba(127, 255, 178, 0.3);
    transition: top 0.08s linear, height 0.08s linear;
  }
}

/* ---- Selection ---- */
::selection {
  background: rgba(0, 207, 255, 0.3);
  color: #fff;
}
