/* ============================================================
   TWILIGHT TREE — Shared Stylesheet
   Dark neon theme · Mobile-first · Android-optimized
   ============================================================ */

:root {
  --bg-1: #0a0a1a;
  --bg-2: #1a0a2e;
  --bg-3: #0d0d2b;
  --surface: #12122a;
  --surface-2: #1a1a3a;
  --border: rgba(0, 240, 255, 0.15);
  --border-strong: rgba(0, 240, 255, 0.4);
  --neon-cyan: #00f0ff;
  --neon-pink: #ff00aa;
  --neon-purple: #b400ff;
  --neon-yellow: #ffe600;
  --neon-green: #00ff88;
  --text-primary: #e8e8ff;
  --text-dim: #8888aa;
  --text-dimmer: #5a5a7a;
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --header-h: 60px;
}

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

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text-primary);
  background:
    radial-gradient(circle at 15% 20%, rgba(0, 240, 255, 0.06), transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(180, 0, 255, 0.06), transparent 55%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2), var(--bg-3));
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.arcade-body { padding-bottom: 0; }
body.game-body { overflow: hidden; height: 100dvh; }

a { color: var(--neon-cyan); text-decoration: none; transition: color .2s; }
a:hover { color: #a8e8ff; }

button { font-family: inherit; cursor: pointer; }

::selection { background: var(--neon-pink); color: #fff; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: rgba(10, 6, 24, 0.85);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 8px var(--neon-cyan)) drop-shadow(0 0 16px var(--neon-purple));
}
.logo-text {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@media (max-width: 420px) {
  .logo-text { display: none; }
  .logo-icon { font-size: 1.6rem; }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  border-radius: 50px;
  transition: all 0.2s;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--neon-cyan); background: rgba(0, 240, 255, 0.06); }
.site-nav a.active {
  color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.1);
  text-shadow: 0 0 8px var(--neon-cyan);
}

.sound-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: rgba(0, 240, 255, 0.06);
  color: var(--neon-cyan);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 0.25rem;
  transition: all 0.2s;
}
.sound-toggle:hover { background: rgba(0, 240, 255, 0.15); box-shadow: 0 0 12px rgba(0, 240, 255, 0.4); }
.sound-toggle:active { transform: scale(0.9); }

@media (max-width: 500px) {
  .site-nav a { padding: 0.45rem 0.55rem; font-size: 0.62rem; letter-spacing: 1px; }
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.arcade-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

@media (min-width: 768px) {
  .arcade-main { padding: 2rem 1.5rem 4rem; }
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  text-align: center;
  padding: 1.5rem 0 1.5rem;
}
@media (min-width: 768px) {
  .hero { padding: 2.5rem 0 2rem; }
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.7rem, 6vw, 3rem);
  letter-spacing: 3px;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink), var(--neon-yellow));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 25px rgba(0, 240, 255, 0.35));
  margin-bottom: 0.5rem;
  animation: titleGlow 3s ease-in-out infinite alternate;
}
@keyframes titleGlow {
  from { filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.3)); }
  to   { filter: drop-shadow(0 0 35px rgba(255, 0, 170, 0.5)); }
}

.hero p {
  color: var(--text-dim);
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

/* Search */
.search-wrapper {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}
.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.55;
  pointer-events: none;
}
#search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.8rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: rgba(15, 10, 30, 0.75);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  outline: none;
  transition: all 0.25s;
  -webkit-appearance: none;
  appearance: none;
}
#search-input::placeholder { color: var(--text-dimmer); }
#search-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 4px rgba(0, 240, 255, 0.12), 0 0 24px rgba(0, 240, 255, 0.25);
  background: rgba(15, 10, 30, 0.95);
}

/* ============================================================
   CATEGORIES
   ============================================================ */
.categories-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0 1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}
.categories-bar::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 0.55rem 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(20, 10, 40, 0.6);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.cat-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.cat-btn.active {
  color: #000;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  border-color: transparent;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
  text-shadow: none;
}

/* ============================================================
   SECTION TITLES
   ============================================================ */
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 1.5rem 0 1rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--neon-cyan);
  box-shadow: -3px 0 12px rgba(0, 240, 255, 0.4);
}
@media (min-width: 768px) {
  .section-title { font-size: 1.15rem; }
}

/* ============================================================
   GAMES GRID & CARDS
   ============================================================ */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) { .games-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; } }
@media (min-width: 1024px) { .games-grid { grid-template-columns: repeat(4, 1fr); gap: 1.1rem; } }

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, rgba(20, 15, 40, 0.95), rgba(10, 8, 22, 0.95));
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease,
              box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}
.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--accent, var(--neon-cyan));
  box-shadow:
    0 12px 30px -8px rgba(0, 0, 0, 0.7),
    0 0 30px -5px var(--accent, var(--neon-cyan));
  outline: none;
}
.game-card:active { transform: translateY(-1px) scale(0.985); }

.card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, transparent 30%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}
.card-emoji {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.6));
  transform: translateZ(0);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.game-card:hover .card-emoji { transform: scale(1.15) rotate(-4deg); }

.card-new {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.25rem 0.55rem;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #000;
  background: linear-gradient(135deg, var(--neon-yellow), var(--neon-pink));
  border-radius: 4px;
  z-index: 2;
  box-shadow: 0 0 12px rgba(255, 230, 0, 0.5);
}

.card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 3;
  pointer-events: none;
}
.game-card:hover .card-play { opacity: 1; }

.card-play-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #000;
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.6);
  animation: playPulse 1.4s ease-in-out infinite;
}
@keyframes playPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.card-info {
  padding: 0.7rem 0.8rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  align-self: flex-start;
  padding: 0.15rem 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent, var(--neon-cyan));
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid currentColor;
  border-radius: 50px;
  opacity: 0.85;
}

@media (min-width: 768px) {
  .card-info { padding: 0.8rem 0.95rem 1rem; }
  .card-title { font-size: 0.95rem; }
}

/* ============================================================
   NO RESULTS
   ============================================================ */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  letter-spacing: 1px;
}

/* ============================================================
   AD CONTAINERS (subtle, non-intrusive)
   ============================================================ */
.ad-container {
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
}
.ad-container.inset { margin: 0.75rem 0; grid-column: 1 / -1; }

.ad-placeholder {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: rgba(12, 8, 24, 0.5);
  border: 1.5px dashed rgba(136, 136, 170, 0.25);
  border-radius: 12px;
  color: var(--text-dimmer);
  text-align: center;
}
.ad-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.ad-hint { font-size: 0.65rem; opacity: 0.7; letter-spacing: 1px; }

@media (max-width: 500px) {
  .ad-placeholder { min-height: 60px; padding: 0.8rem; }
  .ad-label { font-size: 0.55rem; }
  .ad-hint { display: none; }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 1.2rem 1.2rem;
  background: rgba(5, 3, 12, 0.7);
  border-top: 1px solid var(--border);
  padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 640px) {
  .footer-inner { grid-template-columns: 2fr 1fr 1fr; }
}
.footer-col h4 {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--neon-cyan);
  margin-bottom: 0.7rem;
}
.footer-col p { color: var(--text-dim); font-size: 0.82rem; line-height: 1.6; }
.footer-col a {
  display: block;
  padding: 0.3rem 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  transition: color 0.2s;
}
.footer-col a:hover { color: var(--neon-cyan); }
.footer-bottom {
  max-width: 1200px;
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(136, 136, 170, 0.1);
  text-align: center;
  color: var(--text-dimmer);
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}

/* ============================================================
   PLAY PAGE (game wrapper)
   ============================================================ */
.play-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  padding-top: max(0.55rem, env(safe-area-inset-top));
  background: rgba(10, 6, 24, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.play-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.5rem;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: rgba(0, 240, 255, 0.05);
  color: var(--neon-cyan);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: rgba(0, 240, 255, 0.15); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.9); }

.play-frame-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #05030c;
}
#game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
body.play-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  padding: 0;
}

.play-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05030c;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  z-index: 5;
}
.play-loading.hidden { display: none; }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(0, 240, 255, 0.15);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CONTENT PAGES (About / Privacy / Contact)
   ============================================================ */
.page-content {
  max-width: 780px;
  margin: 2rem auto 4rem;
  padding: 0 1.2rem;
}
.page-content h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--neon-cyan);
  text-shadow: 0 0 25px rgba(0, 240, 255, 0.4);
  margin-bottom: 1rem;
}
.page-content h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--neon-pink);
  margin-top: 1.8rem;
  margin-bottom: 0.6rem;
}
.page-content p {
  color: #b0c4dd;
  font-size: 0.9rem;
  line-height: 1.75;
  margin-bottom: 0.9rem;
}
.page-content ul {
  margin: 0.5rem 0 1rem 1.4rem;
  color: #b0c4dd;
  font-size: 0.9rem;
}
.page-content li { margin-bottom: 0.35rem; line-height: 1.6; }
.page-content a { color: var(--neon-cyan); border-bottom: 1px dashed rgba(0,240,255,0.5); }
.page-content a:hover { color: #a8e8ff; border-bottom-style: solid; }
.page-content code {
  background: rgba(0, 240, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  color: var(--neon-yellow);
}
.page-content .muted { color: var(--text-dimmer); font-size: 0.8rem; }

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }