/* Apple-inspired Design System */
:root {
  --primary-bg: #ffffff;
  --secondary-bg: #f5f5f7;
  --tertiary-bg: #fbfbfd;
  --card-bg: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6d6d70; /* Improved contrast: was #86868b, now darker for better accessibility */
  --accent-blue: #007aff;
  --accent-blue-hover: #0056cc;
  --border-light: #d2d2d7;
  --shadow-light: 0 2px 16px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 24px rgba(0, 0, 0, 0.15);
  --border-radius: 12px;
  --border-radius-large: 20px;
  --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--secondary-bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide the main content initially */
#mainContent {
  display: none;
}

/* Modern Consent Box */
#consentBox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#consentContent {
  background: var(--card-bg);
  padding: 32px;
  border-radius: var(--border-radius-large);
  text-align: center;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--border-light);
}

#consentHeader {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

#consentContent p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 16px;
}

.buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.consentButton, .rejectButton {
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  min-width: 120px;
}

.consentButton {
  background: var(--accent-blue);
  color: white;
}

.consentButton:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
}

.rejectButton {
  background: var(--secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.rejectButton:hover {
  background: var(--border-light);
  transform: translateY(-1px);
}

/* Header Styles */
.header {
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 20px 0;
  margin: 0;
}

.header a {
  text-decoration: none;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  text-align: center;
  letter-spacing: -0.5px;
  margin: 0;
  padding: 0;
}

.header a:hover {
  color: var(--accent-blue);
  transition: var(--transition);
}

/* Navigation */
.nav-container {
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 20px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 80px;
  z-index: 99;
  backdrop-filter: blur(20px);
  margin: 0;
}

.squaresNew {
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 10px 18px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  margin: 4px;
}

.squaresNew:hover {
  background: var(--accent-blue);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

/* Search Container */
#searchcontainer {
  position: fixed;
  top: 20px;
  right: 20px;
  left: calc(var(--sidebar-width) + 20px);
  width: auto;
  display: flex;
  gap: 0;
  z-index: 101;
  box-shadow: var(--shadow-light);
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  height: 44px;
  transition: var(--transition);
}

#search {
  padding: 0 16px;
  border: none;
  background: var(--primary-bg);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  width: 200px;
  border-radius: 0;
  height: 44px;
  line-height: 44px;
}

#search:focus {
  background: var(--tertiary-bg);
}

#search::placeholder {
  color: var(--text-secondary);
  opacity: 1; /* Ensure full opacity for better contrast */
}

#searchcontainer button {
  padding: 0 16px;
  background: var(--accent-blue);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  border-radius: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#searchcontainer button:hover {
  background: var(--accent-blue-hover);
}

/* Main Content */
.main {
  background: transparent;
  margin-left: var(--sidebar-width);
  padding: 40px 20px;
  /* Stretch content to fill remaining space next to sidebar on larger screens */
  width: calc(100% - var(--sidebar-width) - 40px);
  max-width: none;
  min-height: 100vh;
  transition: var(--transition);
}

.main_text {
  padding: 0;
  margin: 0;
  width: 100%;
}

/* Typography */
.main h1 {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 40px 0 24px 0;
  letter-spacing: -1px;
  line-height: 1.1;
}

.main h2 {
  font-size: 36px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 36px 0 20px 0;
  letter-spacing: -0.5px;
}

.main h3 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 16px 0;
}

.main h4, .main h5, .main h6 {
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 16px 0;
}

.main p {
  font-size: 17px;
  color: var(--text-primary);
  margin: 20px 0;
  line-height: 1.6;
}

.main a {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  margin: 0 2px;
}

.main a:hover {
  color: var(--accent-blue-hover);
  text-decoration: underline;
}

/* Card Components */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius-large);
  padding: 40px;
  margin: 40px 0;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-light);
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.card:first-child {
  margin-top: 40px;
}

.card:last-child {
  margin-bottom: 40px;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-medium);
}

.card > * {
  margin: 20px 0;
}

.card > *:first-child {
  margin-top: 0;
}

.card > *:last-child {
  margin-bottom: 0;
}

/* Info Cards */
.info-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 24px;
  margin: 20px 0;
  border-left: 4px solid var(--accent-blue);
  box-shadow: var(--shadow-light);
}

.purple {
  border-left-color: #af52de;
}

.green {
  border-left-color: #30d158;
}

.red {
  border-left-color: #ff3b30;
}

.blue {
  border-left-color: var(--accent-blue);
}

.purple p, .green p, .red p, .blue p {
  color: var(--text-primary) !important;
  font-size: 16px !important;
  margin: 0 !important;
  font-family: inherit !important;
}

/* Special Text Styles */
.p_big p {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 40px 0 24px 0;
  letter-spacing: -0.5px;
}

.p_arial p {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 16px 0;
}

.credits {
  background: var(--tertiary-bg);
  border-radius: var(--border-radius);
  padding: 32px;
  margin: 40px 0;
}

.credits p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 12px 0;
  font-style: italic;
}

/* Image Styling */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  margin: 24px 0;
  display: block;
}

/* Saved Games UI - Mac-style Window */
#savedgames-window {
  position: fixed;
  top: 120px;
  right: 20px;
  width: 420px;
  height: 450px;
  background: var(--card-bg);
  border-radius: var(--border-radius-large);
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--border-light);
  z-index: 1000;
  overflow: hidden;
  resize: both;
  min-width: 300px;
  min-height: 200px;
  max-width: 600px;
  max-height: 80vh;
}

#savedgames-window.hidden {
  display: none;
}

.window-header {
  background: var(--secondary-bg);
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.window-controls {
  display: flex;
  gap: 8px;
}

.window-control {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
}

.window-control.close {
  background: #ff5f57;
}

.window-control.minimize {
  background: #ffbd2e;
}

.window-control.maximize {
  background: #28ca42;
}

.window-control:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.window-control:active {
  transform: scale(0.95);
}

.window-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  flex: 1;
  margin: 0 20px;
}

.window-content {
  height: calc(100% - 40px);
  overflow: hidden;
}

#savedgames {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

/* Window dragging states */
#savedgames-window.dragging {
  opacity: 0.9;
  transform: rotate(1deg);
  transition: none;
}

/* Show/hide toggle button */
.savedgames-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  left: calc(var(--sidebar-width) + 290px);
  width: auto;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  z-index: 1001;
  box-shadow: var(--shadow-light);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.savedgames-toggle:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
}

.savedgames-toggle.hidden {
  display: none;
}

/* Game Links */
.gamelink {
  display: inline-block;
  background: var(--accent-blue);
  color: white;
  padding: 14px 28px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  margin: 12px 8px;
}

.gamelink:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

/* Remove Button */
.removebutton {
  color: #ff3b30;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  float: right;
}

.removebutton:hover {
  color: #d70015;
  text-decoration: underline;
}

/* Bookmark UI */
.bookmarkui {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--accent-blue);
  color: white;
  padding: 12px 20px;
  border-radius: var(--border-radius-large);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-medium);
  transition: var(--transition);
  z-index: 100;
}

.bookmarkui:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-2px);
}

/* Page Views */
.pageviews {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 60px auto;
  padding: 20px;
  width: 100%;
  max-width: 100%;
}

/* Responsive Design */
@media (max-width: 768px) {
  .main h1 {
    font-size: 36px;
  }
  
  .main h2 {
    font-size: 28px;
  }
  
  .main_text {
    padding: 20px 16px;
  }
  
  .card {
    padding: 20px;
    margin: 16px 0;
  }
  
  #savedgames {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    margin: 20px 0;
  }
  
  #searchcontainer {
    position: relative;
    top: auto;
    right: auto;
    justify-content: center;
    margin: 16px 0;
  }
  
  #search {
    width: 150px;
  }
}

@media (max-width: 480px) {
  .main h1 {
    font-size: 28px;
  }
  
  .p_big p {
    font-size: 24px;
  }
  
  .buttons {
    flex-direction: column;
  }
  
  .consentButton, .rejectButton {
    width: 100%;
  }
}

/* Sidebar (keeping minimal for compatibility) */
.sidebar {
  display: none; /* Hide traditional sidebar for cleaner Apple-like design */
}

/* Legacy compatibility */
.fancy p {
  color: var(--accent-blue);
  font-size: 18px;
  font-weight: 500;
}

#title {
  display: none; /* Hide redundant title */
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus styles for accessibility */
*:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Selection styles */
::selection {
  background: rgba(0, 122, 255, 0.2);
}

/* Search highlighting */
.search-highlight {
  background: #ffeb3b;
  color: #000;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  animation: searchPulse 0.5s ease-in-out;
}

@keyframes searchPulse {
  0% { background: #ffeb3b; }
  50% { background: #ffc107; }
  100% { background: #ffeb3b; }
}

/* Additional Apple-style enhancements */
.countdown-timer {
  display: block !important;
  text-align: center;
  border-radius: var(--border-radius) !important;
  overflow: hidden;
  box-shadow: var(--shadow-light);
}

/* Enhanced button styles */
button {
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

/* Improved iframe styling */
iframe {
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
}

/* Enhanced link hover effects */
a:not(.squaresNew):not(.consentButton):not(.rejectButton):not(.gamelink):not(.bookmarkui) {
  position: relative;
  transition: var(--transition);
}

a:not(.squaresNew):not(.consentButton):not(.rejectButton):not(.gamelink):not(.bookmarkui):hover {
  transform: translateY(-1px);
}

/* Subtle animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.6s ease-out;
}

.card:nth-child(even) {
  animation-delay: 0.1s;
}

.card:nth-child(odd) {
  animation-delay: 0.2s;
}

/* Improved text readability */
p, li {
  max-width: 65ch;
  line-height: 1.7;
}

/* Better spacing for lists */
ul, ol {
  padding-left: 20px;
}

li {
  margin: 8px 0;
}

/* Enhanced form elements */
input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
  padding: 12px 16px;
  background: var(--primary-bg);
  color: var(--text-primary);
  transition: var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Improved table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-light);
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  background: var(--secondary-bg);
  font-weight: 600;
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-light: #000000;
    --text-secondary: #000000;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* Comprehensive Spacing Rules - No Element Collisions */
* + * {
  margin-top: 20px;
}

/* Override for specific elements that need tighter spacing */
.window-controls * + *,
.buttons * + *,
.nav-container * + *,
.window-header * + * {
  margin-top: 0;
}

/* Ensure proper alignment for flex containers */
.nav-container,
.buttons,
.window-controls {
  align-items: center;
}

/* Ensure all interactive elements have proper spacing */
button {
  margin: 8px 4px;
}

input, textarea, select {
  margin: 12px 0;
}

/* List spacing */
ul, ol {
  margin: 20px 0;
  padding-left: 24px;
}

li {
  margin: 12px 0;
}

li + li {
  margin-top: 8px;
}

/* Table spacing */
table {
  margin: 32px 0;
}

th, td {
  padding: 16px 20px;
}

/* Form element spacing */
form {
  margin: 24px 0;
}

form > * {
  margin: 16px 0;
}

/* Iframe spacing */
iframe {
  margin: 20px 0;
}

/* Div spacing */
div {
  margin: 8px 0;
}

/* Override for specific layout divs */
.nav-container div,
.window-header div,
.buttons div,
.window-controls div {
  margin: 0;
}

/* Section spacing */
section {
  margin: 40px 0;
  padding: 20px 0;
}

/* Article spacing */
article {
  margin: 32px 0;
  padding: 16px 0;
}

/* Blockquote spacing */
blockquote {
  margin: 24px 0;
  padding: 20px;
  border-left: 4px solid var(--accent-blue);
  background: var(--tertiary-bg);
  border-radius: var(--border-radius);
}

/* Code block spacing */
pre, code {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--tertiary-bg);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-light);
}

/* Horizontal rule spacing */
hr {
  margin: 40px 0;
  border: none;
  height: 1px;
  background: var(--border-light);
}

/* Small text spacing */
small {
  margin: 8px 0;
  display: inline-block;
}

/* Strong/bold text spacing */
strong, b {
  margin: 0 2px;
}

/* Emphasis spacing */
em, i {
  margin: 0 1px;
}

/* Span spacing for inline elements */
span {
  margin: 0 1px;
}

/* Ensure no negative margins cause overlaps */
* {
  margin-bottom: 0;
}

/* Special spacing for nested elements */
.card .card {
  margin: 24px 0;
}

.info-card + .info-card {
  margin-top: 16px;
}

/* Responsive spacing adjustments */
@media (max-width: 768px) {
  .main {
    margin-left: 0;
    width: 100%;
  }
  
  .card {
    padding: 24px;
    margin: 24px 0;
  }
  
  .card:first-child {
    margin-top: 24px;
  }
  
  .card:last-child {
    margin-bottom: 24px;
  }
  
  .nav-container {
    padding: 12px 16px;
    gap: 8px;
    justify-content: center;
  }
  
  .squaresNew {
    padding: 8px 14px;
    margin: 2px;
  }
  
  /* Responsive button positioning */
  .savedgames-toggle {
    top: 80px;
    right: 20px;
    left: 20px;
    width: auto;
    text-align: center;
  }
  
  #searchcontainer {
    top: 20px;
    right: 20px;
    left: auto;
  }
}

@media (max-width: 480px) {
  .main {
    margin-left: 0;
    width: 100%;
  }
  
  .card {
    padding: 20px;
    margin: 20px 0;
  }
  
  .card:first-child {
    margin-top: 20px;
  }
  
  .card:last-child {
    margin-bottom: 20px;
  }
  
  .main h1 {
    margin: 24px 0 16px 0;
    font-size: 32px;
  }
  
  .main h2 {
    margin: 20px 0 12px 0;
    font-size: 28px;
  }
  
  .p_big p {
    margin: 24px 0 16px 0;
    font-size: 24px;
  }
  
  /* Stack buttons vertically on small screens */
  .savedgames-toggle {
    top: 120px;
    right: 16px;
    left: 16px;
    width: auto;
    text-align: center;
  }
  
  #searchcontainer {
    top: 20px;
    right: 16px;
    left: auto;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
  }
  
  #search {
    width: 140px;
  }
  
  .nav-container {
    padding: 8px 12px;
    gap: 6px;
  }
  
  .squaresNew {
    padding: 6px 12px;
    font-size: 12px;
    margin: 1px;
  }
}

/* Game Sidebar */
.game-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--primary-bg);
  border-right: 1px solid var(--border-light);
  z-index: 1000;
  overflow-y: auto;
  transition: var(--transition);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-light);
}

.game-sidebar.hidden {
  transform: translateX(-100%);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--secondary-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.5px;
}

.sidebar-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}

.game-categories {
  padding: 20px 0;
}

.game-category {
  margin-bottom: 32px;
}

.category-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 20px;
  letter-spacing: -0.3px;
}

.game-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.game-item {
  margin: 0;
}

.game-link {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.game-link:hover {
  background: var(--tertiary-bg);
  border-left-color: var(--accent-blue);
  color: var(--accent-blue);
  transform: translateX(4px);
}

.game-link.active {
  background: rgba(0, 122, 255, 0.1);
  border-left-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 600;
}

.game-icon {
  margin-right: 12px;
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  z-index: 1001;
  box-shadow: var(--shadow-light);
  display: none; /* Hidden by default, shown on mobile */
}

.sidebar-toggle:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
}

.main.sidebar-hidden {
  margin-left: 0;
  width: 100%;
}

/* Adjust other fixed elements */
#searchcontainer {
  right: 20px;
  left: calc(var(--sidebar-width) + 20px);
  width: auto;
  transition: var(--transition);
}

#searchcontainer.sidebar-hidden {
  left: 20px;
}

.savedgames-toggle {
  right: 20px;
  left: calc(var(--sidebar-width) + 290px);
  width: auto;
  transition: var(--transition);
}

.savedgames-toggle.sidebar-hidden {
  left: 290px;
}

/* Header adjustment */
.header {
  margin-left: var(--sidebar-width);
  transition: var(--transition);
}

.header.sidebar-hidden {
  margin-left: 0;
}

/* Navigation adjustment */
.nav-container {
  margin-left: var(--sidebar-width);
  transition: var(--transition);
}

.nav-container.sidebar-hidden {
  margin-left: 0;
}

/* Responsive Design for Sidebar */
@media (max-width: 1024px) {
  .game-sidebar {
    transform: translateX(-100%);
  }
  
  .game-sidebar.show {
    transform: translateX(0);
  }
  
  .sidebar-toggle {
    display: block;
  }
  
  .main {
    margin-left: 0;
    width: 100%;
  }
  
  #searchcontainer {
    left: 80px;
  }
  
  .savedgames-toggle {
    left: 370px;
  }
  
  .header {
    margin-left: 0;
  }
  
  .nav-container {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  .game-sidebar {
    width: 100%;
    max-width: 320px;
  }
  
  #searchcontainer {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    justify-content: center;
    margin: 16px 0;
  }
  
  .savedgames-toggle {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    margin: 16px auto;
    display: block;
    width: fit-content;
  }
}

@media (max-width: 480px) {
  .sidebar-toggle {
    top: 10px;
    left: 10px;
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .game-sidebar {
    width: 100vw;
    max-width: none;
  }
  
  .sidebar-header {
    padding: 20px 16px;
  }
  
  .game-link {
    padding: 16px 20px;
    font-size: 18px;
  }
  
  .category-title {
    margin-left: 16px;
    font-size: 20px;
  }
}

/* Game Page Specific Styles */
.game-card {
  max-width: none;
  margin: 0;
}

.game-container {
  margin: 24px 0;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--secondary-bg);
  border: 1px solid var(--border-light);
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-container iframe,
.game-container canvas,
.game-container object,
.game-container embed {
  border: none;
  border-radius: var(--border-radius);
  max-width: 100%;
  height: auto;
}

.game-options {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.option-group {
  background: var(--tertiary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 20px;
}

.option-group h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.option-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.option-btn {
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.option-btn:hover {
  background: var(--accent-blue);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.advanced-options {
  margin-top: 16px;
  padding: 16px;
  background: var(--secondary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  display: none;
}

.advanced-options.show {
  display: block;
}

/* Game page responsive adjustments */
@media (max-width: 768px) {
  .game-container {
    min-height: 300px;
  }
  
  .option-buttons {
    flex-direction: column;
  }
  
  .option-btn {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .game-container {
    min-height: 250px;
    margin: 16px 0;
  }
  
  .game-options {
    margin-top: 16px;
    gap: 12px;
  }
  
  .option-group {
    padding: 16px;
  }
}

/* Enhanced Game Page Styles */
.game-nav-header {
  margin-bottom: 20px;
  padding: 20px;
  position: sticky;
  top: 60px; /* below main header */
  z-index: 90;
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
}

.game-nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.game-nav-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.current-game-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

#current-game-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-btn {
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 12px 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-btn:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.home-btn {
  background: var(--secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.home-btn:hover {
  background: var(--border-light);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.game-header h3 {
  margin: 0;
  flex: 1;
}

.game-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: var(--tertiary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  background: var(--accent-blue);
  color: white;
  transform: translateY(-1px);
}

.game-info-panel {
  background: var(--tertiary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 20px;
  margin: 20px 0;
  transition: var(--transition);
}

.game-info-panel.hidden {
  display: none;
}

.game-info-panel h4 {
  margin: 0 0 16px 0;
  color: var(--text-primary);
}

#game-details p {
  margin: 8px 0;
  font-size: 14px;
}

.quick-switcher, .related-games {
  margin: 20px 0;
}

.quick-switcher h4, .related-games h4 {
  margin: 0 0 16px 0;
  color: var(--text-primary);
}

.quick-games {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
}

.quick-category-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-blue);
  width: 100%;
}

.quick-category-header:first-child {
  margin-top: 0;
}

.quick-category-games {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  width: 100%;
  justify-content: center;
}

.quick-game-btn {
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.quick-game-btn:hover {
  background: var(--accent-blue);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-light);
}

.related-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.related-game-card {
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.related-game-card:hover {
  background: var(--tertiary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

.related-game-card .game-title {
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.related-game-card .game-category {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 500;
}

.related-game-card .game-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: auto;
}

/* Responsive adjustments for game page */
@media (max-width: 768px) {
  .game-nav-controls {
    flex-direction: column;
    gap: 12px;
  }
  
  .game-nav-info {
    order: -1;
  }
  
  .game-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .game-actions {
    width: 100%;
    justify-content: center;
  }
  
  .quick-games {
    align-items: stretch;
  }
  
  .quick-category-games {
    justify-content: center;
  }
  
  .related-games-grid {
    grid-template-columns: 1fr;
  }
  
  .recent-games-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .game-nav-controls {
    gap: 8px;
  }
  
  .nav-btn {
    padding: 10px 16px;
    font-size: 12px;
  }
  
  .action-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .quick-games {
    flex-direction: column;
  }
  
  .quick-game-btn {
    justify-content: center;
  }
}

/* Recent Games Styles */
.recent-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.recent-game-card {
  background: var(--primary-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.recent-game-card:hover {
  background: var(--tertiary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-light);
}

.recent-game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-blue);
  opacity: 0;
  transition: var(--transition);
}

.recent-game-card:hover::before {
  opacity: 1;
}

.recent-game-title {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.recent-game-badge {
  background: var(--accent-blue);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ------ Game Layout Flex ------ */
.game-layout {
  display: flex;
  gap: 24px;
}

.game-play-area {
  flex: 2 1 0;
  min-width: 0;
}

.game-sidepanel {
  flex: 1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: calc(100vh - 160px); /* viewport minus header & nav */
  overflow-y: auto;
  padding-right: 4px; /* room for scrollbar */
}

/* Mobile – stack layout */
@media (max-width: 1024px) {
  .game-layout {
    flex-direction: column;
  }
  .game-sidepanel {
    max-height: none;
    overflow: visible;
  }
}
