/* ==========================================================================
   SEGA Genesis Retro Arcade - Complete Production CSS
   ========================================================================== */

/* --- CSS Variables / Color Tokens --- */
:root {
  --font-heading: 'Press Start 2P', cursive, monospace;
  --font-subheading: 'Rajdhani', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  /* Accent Colors */
  --sega-blue: #0051ba;
  --sega-blue-glow: rgba(0, 81, 186, 0.5);
  --sega-red: #e60012;
  --sega-red-hover: #ff1a2a;
  --sega-gold: #ff8c00;
  --sega-gold-glow: rgba(255, 140, 0, 0.4);
  --sega-cyan: #00f0ff;

  /* Theme Defaults (Dark Theme) */
  --bg-color: #0b0d14;
  --bg-pattern: radial-gradient(circle at 50% 0%, #171b2a 0%, #0b0d14 75%);
  --surface-bg: #141724;
  --surface-card: #1a1e30;
  --surface-hover: #222840;
  --border-color: #2e3654;
  --border-glow: #0051ba;
  
  --text-main: #f0f3fe;
  --text-muted: #8e99b7;
  --text-inverse: #0b0d14;

  --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --hover-shadow: 0 15px 35px rgba(0, 81, 186, 0.3);
  --header-bg: rgba(14, 17, 26, 0.95);
  --input-bg: #0f121d;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

/* Light Mode Overrides */
[data-theme=light] {
  --bg-color: #f2f4f8;
  --bg-pattern: radial-gradient(circle at 50% 0%, #e2e8f0 0%, #f2f4f8 75%);
  --surface-bg: #ffffff;
  --surface-card: #ffffff;
  --surface-hover: #f8fafc;
  --border-color: #cbd5e1;
  --border-glow: #0051ba;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --hover-shadow: 0 10px 25px rgba(0, 81, 186, 0.2);
  --header-bg: rgba(255, 255, 255, 0.95);
  --input-bg: #f1f5f9;
}

/* --- Base Resets & Global Anti-Overflow Constraints --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img, video, iframe, canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

body {
  background-color: var(--bg-color);
  background-image: var(--bg-pattern);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* --- Top Navigation Bar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border-color);
  padding: 0.8rem 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.nav-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand { display: flex; align-items: center; gap: 0.8rem; flex-shrink: 0; }
.logo-icon { font-family: var(--font-heading); font-size: 0.8rem; background: linear-gradient(135deg, var(--sega-red), var(--sega-blue)); color: #fff; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); box-shadow: 0 0 10px var(--sega-blue-glow); letter-spacing: 1px; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-family: var(--font-heading); font-size: 1.1rem; color: var(--text-main); letter-spacing: -0.5px; }
.brand-sub { font-family: var(--font-subheading); font-size: 0.85rem; font-weight: 700; color: var(--sega-red); letter-spacing: 2px; }

.search-bar-wrapper { flex: 1; max-width: 500px; position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 1rem; font-size: 1.1rem; color: var(--text-muted); pointer-events: none; }
.search-bar-wrapper input { width: 100%; padding: 0.7rem 2.8rem 0.7rem 2.8rem; background-color: var(--input-bg); border: 2px solid var(--border-color); border-radius: var(--radius-pill); color: var(--text-main); font-size: 0.95rem; font-weight: 500; outline: none; transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.search-bar-wrapper input:focus { border-color: var(--sega-blue); box-shadow: 0 0 12px var(--sega-blue-glow); }
.clear-search-btn { position: absolute; right: 1rem; color: var(--text-muted); font-weight: bold; display: none; padding: 0.2rem; }
.clear-search-btn.active { display: block; }

.nav-actions { display: flex; align-items: center; gap: 0.8rem; flex-shrink: 0; }

.theme-toggle-btn { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; background-color: var(--surface-card); border: 2px solid var(--border-color); border-radius: var(--radius-pill); color: var(--text-main); font-weight: 600; font-size: 0.9rem; transition: all var(--transition-fast); }
.theme-toggle-btn:hover { border-color: var(--sega-blue); transform: translateY(-2px); }

[data-theme=dark] .sun-icon { display: inline-block; }
[data-theme=dark] .moon-icon { display: none; }
[data-theme=light] .sun-icon { display: none; }
[data-theme=light] .moon-icon { display: inline-block; }

/* --- Language Switcher --- */
.lang-switcher { display: flex; align-items: center; flex-shrink: 0; }
.lang-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-color: var(--surface-card); color: var(--text-main);
  border: 2px solid var(--border-color); border-radius: var(--radius-pill);
  padding: 0.5rem 1.9rem 0.5rem 1rem; font-size: 0.9rem; font-weight: 600;
  font-family: var(--font-body); cursor: pointer; transition: all var(--transition-fast);
}
.lang-select:hover { border-color: var(--sega-blue); transform: translateY(-2px); }
.lang-select:focus { outline: 2px solid var(--sega-blue); outline-offset: 2px; }

/* Mirrored inward chevron caret (arrow preserved visually in RTL) */
.lang-switcher { position: relative; }
.lang-switcher::after {
  content: "▾"; position: absolute; right: 0.8rem; top: 50%;
  transform: translateY(-50%); color: var(--sega-gold); pointer-events: none;
  font-size: 0.8rem;
}

/* Right-to-left (Arabic) layout overrides */
[dir=rtl] .category-chip { text-align: right; }
[dir=rtl] .search-icon { left: auto; right: 1rem; }
[dir=rtl] .lang-switcher::after { right: auto; left: 0.8rem; }
[dir=rtl] .lang-select { padding: 0.5rem 1rem 0.5rem 1.9rem; }
[dir=rtl] .game-header-card { text-align: right; }
[dir=rtl] .sort-wrapper, [dir=rtl] .controls-wrapper { justify-content: flex-start; }
[dir=rtl] .tm-controls, [dir=rtl] .system-bar, [dir=rtl] .nav-actions,
[dir=rtl] .category-menu, [dir=rtl] .pagination-wrapper, [dir=rtl] .section-header { direction: rtl; }

.user-profile-bar { display: flex; align-items: center; gap: 0.8rem; }
.user-name { font-family: var(--font-subheading); font-weight: 700; color: var(--sega-gold); font-size: 0.95rem; }

/* --- Auth Modal --- */
.auth-modal-backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(5, 7, 12, 0.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-modal-box { background: var(--surface-bg); border: 2px solid var(--sega-blue); box-shadow: 0 0 30px var(--sega-blue-glow); border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 400px; position: relative; text-align: center; }
.close-modal-btn { position: absolute; top: 1rem; right: 1rem; color: var(--text-muted); font-size: 1.2rem; transition: color var(--transition-fast); }
.close-modal-btn:hover { color: var(--sega-red); }
.auth-title { font-family: var(--font-heading); font-size: 1rem; color: var(--sega-gold); margin-bottom: 1.5rem; }
.auth-input-group { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; margin-bottom: 1rem; }
.auth-input-group label { font-family: var(--font-subheading); font-weight: 700; font-size: 0.8rem; color: var(--text-muted); }
.auth-input-group input { width: 100%; padding: 0.7rem 1rem; background-color: var(--input-bg); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-main); outline: none; font-size: 0.9rem; }
.auth-input-group input:focus { border-color: var(--sega-cyan); }
.auth-submit-btn { width: 100%; margin-top: 0.5rem; }
.google-btn { width: 100%; }
.auth-divider { margin: 1rem 0; font-size: 0.8rem; color: var(--text-muted); font-weight: bold; }
.auth-error { color: var(--sega-red); font-size: 0.8rem; margin-bottom: 0.8rem; font-weight: 600; }
.auth-toggle-text { margin-top: 1.2rem; font-size: 0.82rem; color: var(--text-muted); }
.auth-toggle-text a { color: var(--sega-cyan); font-weight: bold; margin-left: 0.3rem; }

/* --- Hero Banner Section --- */
.hero-banner { width: 100%; max-width: 100%; background: linear-gradient(135deg, rgba(0, 81, 186, 0.2), rgba(230, 0, 18, 0.15)), var(--surface-bg); border-bottom: 2px solid var(--border-color); padding: 3rem 1.5rem; text-align: center; position: relative; overflow: hidden; }
.hero-banner::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02) 2px, transparent 2px, transparent 4px); pointer-events: none; }
.hero-content { max-width: 900px; margin: 0 auto; position: relative; z-index: 1; }
.hero-badge { display: inline-block; font-family: var(--font-subheading); font-size: 0.9rem; font-weight: 700; color: var(--sega-gold); background: rgba(255, 140, 0, 0.1); border: 1px solid var(--sega-gold); padding: 0.3rem 1rem; border-radius: var(--radius-pill); margin-bottom: 1rem; letter-spacing: 1px; }
.hero-title { font-family: var(--font-heading); font-size: clamp(1.4rem, 3vw, 2.2rem); color: var(--text-main); margin-bottom: 1rem; text-shadow: 2px 2px 0px var(--sega-red); line-height: 1.3; }
/* Key Features Highlight Bar (hero pills) */
.hero-features { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 0.6rem 0.75rem; margin: 0 auto 1.5rem; max-width: 100%; }
.feature-pill { display: inline-flex; align-items: center; gap: 0.45rem; font-family: var(--font-subheading); font-size: 0.88rem; font-weight: 600; letter-spacing: 0.2px; color: var(--text-main); background: linear-gradient(135deg, rgba(0, 81, 186, 0.22), rgba(230, 0, 18, 0.16)); border: 1px solid var(--border-color); border-radius: var(--radius-pill); padding: 0.45rem 0.95rem; transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast); white-space: nowrap; }
.feature-pill:hover { border-color: var(--sega-gold); transform: translateY(-1px); box-shadow: 0 4px 14px var(--sega-gold-glow); }
.hero-subtitle { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 2rem; }
.hero-stats { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; }
.stat-card { background-color: var(--surface-card); border: 1px solid var(--border-color); padding: 0.8rem 1.8rem; border-radius: var(--radius-md); display: flex; flex-direction: column; align-items: center; min-width: 130px; }
.stat-number { font-family: var(--font-subheading); font-size: 1.6rem; font-weight: 700; color: var(--sega-cyan); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Main Layout --- */
.main-layout { max-width: 1400px; width: 100%; min-width: 0; margin: 2rem auto; padding: 0 1.5rem; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 2rem; flex: 1; }

.category-sidebar { background-color: var(--surface-bg); border: 2px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.5rem; height: fit-content; position: sticky; top: 90px; min-width: 0; max-width: 100%; overflow: hidden; }
.sidebar-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.2rem; padding-bottom: 0.8rem; border-bottom: 2px solid var(--border-color); }
.sidebar-header h2 { font-family: var(--font-heading); font-size: 0.9rem; color: var(--text-main); }
.category-menu { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; max-width: 100%; }
.category-chip { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 1rem; border-radius: var(--radius-md); background-color: var(--surface-card); border: 1px solid var(--border-color); color: var(--text-main); font-weight: 600; font-size: 0.95rem; transition: all var(--transition-fast); text-align: left; }
.category-chip:hover { background-color: var(--surface-hover); border-color: var(--sega-blue); transform: translateX(4px); }
.category-chip.active { background: linear-gradient(135deg, var(--sega-blue), #003680); color: #ffffff; border-color: var(--sega-cyan); box-shadow: 0 4px 12px var(--sega-blue-glow); }
.chip-count { font-size: 0.8rem; opacity: 0.85; background: rgba(255,255,255,0.15); padding: 0.1rem 0.5rem; border-radius: var(--radius-pill); }

.games-section { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; max-width: 100%; }
.section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; background-color: var(--surface-bg); border: 1px solid var(--border-color); padding: 1rem 1.5rem; border-radius: var(--radius-md); }
.section-title-wrap { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.5rem; }
.section-title { font-family: var(--font-heading); font-size: 1.1rem; color: var(--text-main); }
.results-count { font-size: 0.85rem; color: var(--text-muted); }
.controls-wrapper { display: flex; align-items: center; gap: 1rem; }
.sort-wrapper { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }
.sort-select { background-color: var(--input-bg); color: var(--text-main); border: 1px solid var(--border-color); padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); outline: none; font-weight: 600; }

.status-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; background-color: var(--surface-bg); border: 2px dashed var(--border-color); border-radius: var(--radius-lg); text-align: center; }
.status-text { font-family: var(--font-heading); font-size: 0.9rem; color: var(--sega-gold); margin-top: 1.5rem; letter-spacing: 1px; }
.retro-spinner { width: 50px; height: 50px; border: 5px solid var(--border-color); border-top-color: var(--sega-red); border-bottom-color: var(--sega-blue); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Games Grid */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.5rem; min-width: 0; max-width: 100%; }
.game-card { background-color: var(--surface-card); border: 2px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal); position: relative; min-width: 0; max-width: 100%; }
.game-card:hover { transform: translateY(-6px); border-color: var(--sega-blue); box-shadow: var(--hover-shadow); }
.card-media-wrapper { position: relative; width: 100%; max-width: 100%; height: 180px; background-color: #000; overflow: hidden !important; }
.card-media-wrapper img, .card-cover-img, .card-screenshot-img, .card-preview-video { position: absolute !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; max-width: 100% !important; max-height: 100% !important; object-fit: cover !important; display: block !important; transition: opacity 0.4s ease; }
.card-screenshot-img { z-index: 2; object-fit: contain !important; background: #000; opacity: 0; }
.card-preview-video { z-index: 4; object-fit: contain !important; opacity: 0; pointer-events: none; }
.game-card:hover .card-cover-img { opacity: 0; }
.game-card:hover .card-screenshot-img { opacity: 1; }
.game-card.video-active .card-preview-video { opacity: 1; }
.card-badge { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 5; background: rgba(11, 13, 20, 0.85); backdrop-filter: blur(4px); border: 1px solid var(--border-color); color: var(--sega-gold); font-family: var(--font-subheading); font-weight: 700; font-size: 0.75rem; padding: 0.2rem 0.6rem; border-radius: var(--radius-pill); }

.card-body { padding: 1.2rem; display: flex; flex-direction: column; flex: 1; justify-content: space-between; min-width: 0; }
.card-title { font-family: var(--font-subheading); font-size: 1.2rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.3rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-filename { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popularity-bar-wrap { margin: 0.4rem 0 0.8rem; }
.popularity-bar-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem; }
.popularity-label { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; color: var(--text-muted); font-family: var(--font-subheading); }
.popularity-value { font-size: 0.72rem; font-weight: 700; color: var(--sega-gold); font-family: var(--font-subheading); }
.popularity-bar-track { width: 100%; height: 8px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-color); border-radius: var(--radius-pill); overflow: hidden; }
.popularity-bar-fill { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--sega-cyan), var(--sega-blue), var(--sega-red)); transition: width 0.6s ease; }
.card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.8rem; border-top: 1px solid var(--border-color); }
.category-tag { font-size: 0.8rem; font-weight: 600; color: var(--sega-cyan); }
.play-link-btn { font-family: var(--font-heading); font-size: 0.65rem; color: #fff; background: var(--sega-red); padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); transition: background-color var(--transition-fast); }
.game-card:hover .play-link-btn { background: var(--sega-red-hover); box-shadow: 0 0 10px rgba(230, 0, 18, 0.6); }

/* Pagination Controls */
.pagination-wrapper { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-top: 2rem; padding: 1rem; background-color: var(--surface-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.pagination-btn { font-family: var(--font-heading); font-size: 0.75rem; color: var(--text-main); background-color: var(--surface-card); border: 2px solid var(--border-color); padding: 0.6rem 1.2rem; border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.pagination-btn:hover:not(:disabled) { border-color: var(--sega-blue); background-color: var(--sega-blue); color: #ffffff; }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Disabled Buttons Generic */
button:disabled, .retro-btn:disabled, .pagination-btn:disabled, .sys-btn:disabled, .btn-tm:disabled, .category-chip:disabled, .theme-toggle-btn:disabled { cursor: not-allowed !important; pointer-events: none; transform: none !important; box-shadow: none !important; text-shadow: none !important; animation: none !important; filter: none !important; }
[data-theme=dark] button:disabled, [data-theme=dark] .retro-btn:disabled, [data-theme=dark] .pagination-btn:disabled, [data-theme=dark] .sys-btn:disabled, [data-theme=dark] .btn-tm:disabled, [data-theme=dark] .category-chip:disabled, [data-theme=dark] .theme-toggle-btn:disabled { background-color: #232838; color: #6b7690; border: 2px solid #39415c; opacity: 0.55; }
[data-theme=light] button:disabled, [data-theme=light] .retro-btn:disabled, [data-theme=light] .pagination-btn:disabled, [data-theme=light] .sys-btn:disabled, [data-theme=light] .btn-tm:disabled, [data-theme=light] .category-chip:disabled, [data-theme=light] .theme-toggle-btn:disabled { background-color: #e2e8f0; color: #64748b; border: 2px solid #cbd5e1; opacity: 0.7; }
.pagination-info { font-family: var(--font-subheading); font-weight: 700; font-size: 1rem; color: var(--text-muted); }

/* --- Game Detail Page Layout --- */
.game-detail-layout { max-width: 1200px; width: 100%; margin: 2rem auto; padding: 0 1.5rem; display: flex; flex-direction: column; gap: 2.5rem; flex: 1; }
.game-header-card { background-color: var(--surface-bg); border: 2px solid var(--border-color); border-radius: var(--radius-lg); padding: 2rem; display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: center; }
.game-cover-thumbnail { width: 100%; max-width: 220px; height: 260px; border-radius: var(--radius-md); overflow: hidden !important; border: 2px solid var(--border-color); background-color: #000; position: relative; }
.game-detail-cover { width: 100% !important; height: 100% !important; max-width: 100% !important; max-height: 100% !important; object-fit: cover !important; }
.game-header-info { display: flex; flex-direction: column; gap: 0.8rem; }
.game-meta-pills { display: flex; gap: 0.8rem; }
.badge { font-family: var(--font-subheading); font-weight: 700; font-size: 0.85rem; padding: 0.2rem 0.8rem; border-radius: var(--radius-pill); text-transform: uppercase; }
.category-badge { background-color: rgba(0, 240, 255, 0.15); color: var(--sega-cyan); border: 1px solid var(--sega-cyan); }
.system-badge { background-color: rgba(255, 140, 0, 0.15); color: var(--sega-gold); border: 1px solid var(--sega-gold); }
.game-detail-title { font-family: var(--font-heading); font-size: clamp(1.4rem, 2.5vw, 2rem); color: var(--text-main); line-height: 1.3; }
.game-filename-text { font-size: 0.9rem; color: var(--text-muted); }
.game-actions-bar { display: flex; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }
.retro-btn { font-family: var(--font-heading); font-size: 0.8rem; padding: 0.8rem 1.5rem; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem; transition: all var(--transition-fast); }
.play-btn { background: var(--sega-red); color: #ffffff; box-shadow: 0 4px 15px rgba(230, 0, 18, 0.4); }
.play-btn:hover { background: var(--sega-red-hover); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(230, 0, 18, 0.6); }
.secondary-btn { background-color: var(--surface-card); color: var(--text-main); border: 2px solid var(--border-color); }
.secondary-btn:hover { border-color: var(--sega-blue); background-color: var(--surface-hover); }

.game-plot-section { width: 100%; }
.plot-card { background-color: var(--surface-bg); border: 2px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.5rem 2rem; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); }
.plot-card-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.plot-card-header h2 { font-family: var(--font-heading); font-size: 1rem; letter-spacing: 0.05em; color: var(--text-main); }
.plot-badge { font-family: var(--font-subheading); font-weight: 700; font-size: 0.7rem; padding: 0.2rem 0.7rem; border-radius: var(--radius-pill); background-color: rgba(230, 0, 18, 0.15); color: var(--sega-red); border: 1px solid var(--sega-red); text-transform: uppercase; letter-spacing: 0.05em; }
.game-plot-text { font-size: 1rem; line-height: 1.7; color: var(--text-muted); white-space: pre-line; max-width: 900px; }

.recommended-section { width: 100%; padding: 1.5rem 2rem; background-color: var(--surface-bg); border: 2px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); }
.recommended-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 0.5rem; }
.recommended-header h2 { font-family: var(--font-heading); font-size: 1rem; letter-spacing: 0.05em; color: var(--text-main); }
.recommended-badge { font-family: var(--font-subheading); font-weight: 700; font-size: 0.7rem; padding: 0.2rem 0.7rem; border-radius: var(--radius-pill); background-color: rgba(108, 92, 231, 0.15); color: #a29bfe; border: 1px solid rgba(108, 92, 231, 0.6); text-transform: uppercase; letter-spacing: 0.05em; }
.recommended-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.recommended-grid { margin-top: 0.5rem; }

/* Emulator Section */
.emulator-section { width: 100%; }
.emulator-wrapper { background-color: #000000; border: 4px solid var(--sega-blue); border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 0 30px var(--sega-blue-glow); position: relative; }
.emulator-header-bar { background-color: #121520; padding: 0.8rem 1.2rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--border-color); flex-wrap: wrap; gap: 0.8rem; }
.emulator-status-dot { width: 10px; height: 10px; background-color: #00ff66; border-radius: 50%; box-shadow: 0 0 8px #00ff66; }
.emulator-status-text { font-family: var(--font-subheading); font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.emulator-controls-hint { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.emulator-container { position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 600px; background-color: #05060a; display: flex; align-items: center; justify-content: center; }
.emulator-splash { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle, #1a2035 0%, #05060a 100%); z-index: 10; }
.splash-content { text-align: center; padding: 2rem; }
.sega-logo-text { font-family: var(--font-heading); font-size: 3rem; color: var(--sega-blue); text-shadow: 0 0 20px var(--sega-blue-glow), 3px 3px 0 #fff; margin-bottom: 1rem; }
.splash-prompt { font-family: var(--font-subheading); font-weight: 700; font-size: 1.2rem; color: var(--sega-gold); margin-bottom: 2rem; }
.splash-play-btn { font-size: 1rem; padding: 1rem 2.5rem; background: var(--sega-red); color: #fff; box-shadow: 0 0 25px rgba(230, 0, 18, 0.8); }
.emulator-screen { width: 100%; height: 100%; }

/* Footer */
.footer { background-color: var(--surface-bg); border-top: 2px solid var(--border-color); padding: 2rem 1.5rem; margin-top: auto; }
.footer-container { max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.footer-brand { display: flex; align-items: center; gap: 0.8rem; font-weight: 600; color: var(--text-main); }

/* ==========================================================================
   ADVANCED MOBILE & TABLET RESPONSIVE FIXES
   ========================================================================== */

/* Tablet (max-width: 992px) */
@media (max-width: 992px) {
  .main-layout { grid-template-columns: minmax(0, 1fr); margin: 1rem auto; padding: 0 0.8rem; gap: 1rem; }
  .category-sidebar { position: sticky; top: 65px; z-index: 90; width: 100%; max-width: 100%; min-width: 0; padding: 0.5rem 0.6rem; border-radius: var(--radius-md); background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border-color); overflow: hidden !important; }
  .sidebar-header { display: none; }
  .category-menu { display: flex; flex-direction: row; overflow-x: auto !important; white-space: nowrap; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; gap: 0.4rem; padding: 0.2rem 0; width: 100%; max-width: 100%; min-width: 0; -ms-overflow-style: none; scrollbar-width: none; }
  .category-menu::-webkit-scrollbar { display: none; }
  .category-chip { white-space: nowrap; font-size: 0.82rem; padding: 0.45rem 0.85rem; flex-shrink: 0; border-radius: var(--radius-pill); }
  .game-header-card { grid-template-columns: 1fr; text-align: center; padding: 1.2rem; }
  .game-cover-thumbnail { max-width: 200px; height: 240px; margin: 0 auto; }
  .game-meta-pills, .game-actions-bar { justify-content: center; }
}

/* Mobile Phone (max-width: 650px) */
@media (max-width: 650px) {
  .navbar { padding: 0.5rem 0.8rem; }
  .nav-container { flex-wrap: wrap; gap: 0.6rem; }
  .brand { order: 1; }
  .nav-actions { order: 2; }
  .search-bar-wrapper { order: 3; width: 100%; max-width: 100%; }
  
  .brand-title { font-size: 0.9rem; }
  .brand-sub { font-size: 0.68rem; letter-spacing: 1px; }
  .logo-icon { font-size: 0.65rem; padding: 0.35rem 0.5rem; }

  .search-bar-wrapper input { font-size: 0.82rem; padding: 0.55rem 2.2rem 0.55rem 2.4rem; }
  .theme-toggle-btn { padding: 0.4rem 0.7rem; font-size: 0.75rem; }
  .theme-text { display: none; }

  .hero-banner { padding: 1.8rem 0.8rem 1.2rem 0.8rem; }
  .hero-badge { font-size: 0.68rem; padding: 0.2rem 0.6rem; }
  .hero-title { font-size: 1.15rem; text-shadow: 1px 1px 0px var(--sega-red); margin-bottom: 0.5rem; }
  .hero-subtitle { font-size: 0.85rem; margin-bottom: 1rem; }
  .hero-features { gap: 0.45rem; margin-bottom: 1rem; }
  .feature-pill { font-size: 0.74rem; padding: 0.35rem 0.7rem; white-space: normal; text-align: center; }
  .hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .stat-card { min-width: unset; padding: 0.4rem 0.2rem; }
  .stat-number { font-size: 1rem; }
  .stat-label { font-size: 0.6rem; }

  .section-header { padding: 0.75rem 0.8rem; flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .section-title-wrap { justify-content: space-between; width: 100%; }
  .section-title { font-size: 0.9rem; }
  .controls-wrapper, .sort-wrapper { width: 100%; justify-content: space-between; font-size: 0.82rem; }
  .sort-select { flex: 1; margin-left: 0.4rem; font-size: 0.82rem; }

  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.6rem; }
  .game-card { border-radius: var(--radius-md); min-width: 0; }
  .card-media-wrapper { height: 130px !important; }
  .card-body { padding: 0.6rem; }
  .card-title { font-size: 0.88rem; }
  .card-filename { font-size: 0.65rem; margin-bottom: 0.5rem; }
  .card-footer { flex-direction: column; align-items: stretch; gap: 0.4rem; padding-top: 0.5rem; }
  .category-tag { font-size: 0.7rem; }
  .play-link-btn { text-align: center; width: 100%; padding: 0.4rem 0.4rem; font-size: 0.58rem; }
  .card-badge { font-size: 0.6rem; padding: 0.15rem 0.4rem; top: 0.3rem; right: 0.3rem; }

  .game-actions-bar { flex-direction: column; width: 100%; }
  .game-actions-bar .retro-btn { width: 100%; }
  
  .sega-logo-text { font-size: 1.8rem; }
  .splash-prompt { font-size: 0.95rem; }

  .pagination-wrapper { padding: 0.6rem; gap: 0.5rem; }
  .pagination-btn { padding: 0.45rem 0.75rem; font-size: 0.62rem; }
  .pagination-info { font-size: 0.8rem; }
}

@media (max-width: 340px) {
  .games-grid { grid-template-columns: minmax(0, 1fr) !important; }
}


/* ==========================================================================
   TRUE NATIVE HTML5 FULLSCREEN & MOBILE TIME MACHINE OVERLAY
   ========================================================================== */

/* 🖥️ فول اسکرین واقعی HTML5 روی کانتینر اصلی خود بازی */
#emulatorContainer:fullscreen,
#emulatorContainer:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  background-color: #000000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

#emulatorContainer:fullscreen #emulatorScreen,
#emulatorContainer:-webkit-full-screen #emulatorScreen {
  width: 100% !important;
  height: 100% !important;
}

#emulatorContainer:fullscreen iframe,
#emulatorContainer:-webkit-full-screen iframe,
#emulatorContainer:fullscreen canvas,
#emulatorContainer:-webkit-full-screen canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ⏳ دکمه‌های تایم ماشین شناور روی کنترلرهای EmulatorJS */
.mobile-time-machine {
  display: none; /* مخفی در حالت دسکتاپ */
}

/* 📱 شرط جدید: پشتیبانی کامل هم از Portrait و هم Landscape در گوشی‌ها */
@media (max-width: 1024px), (orientation: landscape) and (max-height: 600px) {
  .mobile-time-machine {
    display: flex !important;
    position: absolute !important;
    top: 12px !important; 
    left: 50% !important;
    transform: translateX(-50%) !important;
    gap: 10px !important;
    pointer-events: auto !important;
    z-index: 2147483647 !important; /* بالاترین Z-Index ممکن در مرورگر */
  }
}

/* دکمه‌های تایم ماشین در حالت فول‌اسکرین واقعی */
#emulatorContainer:fullscreen .mobile-time-machine,
#emulatorContainer:-webkit-full-screen .mobile-time-machine {
  position: absolute !important;
  top: 10px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  z-index: 2147483647 !important;
}

/* استایل عمومی دکمه‌های تایم‌ماشین لمسی */
.btn-mobile-tm {
  background: rgba(20, 20, 35, 0.85) !important;
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
  color: white !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
  font-size: 15px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  backdrop-filter: blur(8px) !important;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8) !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  z-index: 2147483647 !important;
}

/* 🌟 بهینه‌سازی سایز دکمه‌ها در حالت افقی (Landscape) تا جلوی تصویر بازی را نگیرند */
@media (orientation: landscape) and (max-height: 500px) {
  .btn-mobile-tm {
    width: 36px !important;
    height: 36px !important;
    font-size: 12px !important;
  }
}

.btn-mobile-tm.play-tm {
  background: rgba(0, 184, 148, 0.85) !important;
  border-color: rgba(0, 184, 148, 1) !important;
}

.btn-mobile-tm:active {
  transform: scale(0.85) !important;
  background: #6c5ce7 !important;
  border-color: #a29bfe !important;
}


/* ==========================================================================
   LIGHT-THEME BUTTON CONTRAST & VISIBILITY OVERRIDES
   ========================================================================== */
[data-theme=light] .emulator-header-bar { background-color: #ffffff; border-bottom-color: #cbd5e1; }
[data-theme=light] .emulator-header-bar .emulator-status-text { color: #0f172a; }
[data-theme=light] .emulator-header-bar .emulator-controls-hint { color: #475569; }
[data-theme=light] .timemachine-bar { background: #ffffff; border-color: #cbd5e1; box-shadow: 0 8px 25px rgba(15, 23, 42, 0.1); }
[data-theme=light] .status-badge { background: #eef2ff; border: 1px solid #0051ba; color: #003680; }

[data-theme=light] .sys-btn, [data-theme=light] .btn-tm { background: #ffffff; color: #0f172a; border: 2px solid #0051ba; }
[data-theme=light] .sys-btn:hover, [data-theme=light] .btn-tm:hover { background: #0051ba; border-color: #0051ba; color: #ffffff; box-shadow: 0 0 12px rgba(0, 81, 186, 0.35); }
[data-theme=light] .sys-btn:active, [data-theme=light] .btn-tm:active { background: #003680; border-color: #003680; color: #ffffff; transform: scale(0.96); }
[data-theme=light] .sys-btn:disabled { opacity: 0.4; border-color: #cbd5e1; background: #e2e8f0; color: #64748b; }

[data-theme=light] .btn-cheat { background: #e84393; border-color: #c2185b; color: #ffffff; }
[data-theme=light] .btn-tm-play { background: linear-gradient(135deg, #00b894, #00cec9) !important; color: #0f172a !important; border: 2px solid #0f766e !important; }

[data-theme=light] .retro-btn, [data-theme=light] .back-btn { color: #0f172a; }
[data-theme=light] .retro-btn.play-btn, [data-theme=light] .splash-play-btn, [data-theme=light] .play-link-btn, [data-theme=light] .category-chip.active, [data-theme=light] .logo-icon { color: #ffffff; }
[data-theme=light] .retro-btn.secondary-btn { background-color: #ffffff; color: #0f172a; border: 2px solid #0051ba; }
[data-theme=light] .retro-btn.secondary-btn:hover { background-color: #eef2ff; border-color: #003680; color: #003680; }
[data-theme=light] .pagination-btn { background-color: #ffffff; color: #0f172a; border: 2px solid #0051ba; }
[data-theme=light] .pagination-btn:hover:not(:disabled) { background-color: #0051ba; border-color: #0051ba; color: #ffffff; }
[data-theme=light] .pagination-btn:disabled { background-color: #e2e8f0; border-color: #cbd5e1; color: #64748b; }
[data-theme=light] .theme-toggle-btn { background-color: #ffffff; color: #0f172a; border: 2px solid #0051ba; }
[data-theme=light] .theme-toggle-btn:hover { border-color: #003680; background-color: #eef2ff; }
[data-theme=light] .footer { background-color: #ffffff; }
