/* Base Styles */
:root {
  --bg: #0b0f14;
  --fg: #ff7a1a;
  --fg2: #e6f4ff;
  --ice: #a8d8ff;
  --ring: #a8d8ff;
  --card: #0f141b;
  --card-hover: #141c26;
  --transition: all 0.3s ease;
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg2);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

a {
  color: var(--fg);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--ice);
}

/* Layout */
.site-header {
  text-align: center;
  padding: 3rem 1rem 2rem;
  background: linear-gradient(180deg, rgba(11, 15, 20, 0.9) 0%, rgba(15, 20, 27, 0.7) 100%);
  position: relative;
  z-index: 10;
}

.tagline {
  color: var(--fg);
  font-size: 1.2rem;
  margin-top: 0.5rem;
  opacity: 0.9;
}

.games {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  flex: 1;
  width: 100%;
}

/* Game Cards */
.game-card {
  background: transparent;
  border: none;
  border-radius: 12px;
  height: 100%;
  min-height: 180px;
  position: relative;
  perspective: 1000px;
  -webkit-perspective: 1000px;
  /* Performance optimizations */
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
  contain: content;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(168, 216, 255, 0.2);
  border-color: var(--fg);
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  border-radius: 12px;
  background: transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  overflow: visible;
  /* Performance optimizations */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  -webkit-transform-style: preserve-3d;
  -webkit-transform: translate3d(0, 0, 0);
}

.game-card:hover .flip-inner {
  transform: rotateY(180deg);
}

.flip-front, .flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--ice);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  /* Performance optimizations */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform, opacity;
}

.flip-back {
  transform: rotateY(180deg);
  color: var(--ice);
  background: var(--card);
  pointer-events: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
}

/* Add subtle depth to the back of the card */
.flip-back::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

/* Card hover effect */
.game-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: linear-gradient(45deg, var(--fg), var(--ice));
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 1;
}

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

/* Make the entire card clickable */
.game-card a {
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.game-card h2 {
  margin: 0 0 1rem;
  font-size: 1.4rem;
}

.game-card h2 a {
  color: var(--fg);
  transition: var(--transition);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.game-card h2 a:hover {
  background: rgba(255, 122, 26, 0.1);
  color: var(--ice);
}

.hint {
  font-size: 0.8rem;
  color: rgba(230, 244, 255, 0.6);
  margin-top: 1rem;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(11, 15, 20, 0.9);
  border-top: 1px solid rgba(168, 216, 255, 0.1);
  margin-top: 2rem;
}

.site-footer nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.site-footer a {
  color: var(--fg2);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: var(--transition);
}

.site-footer a:hover {
  color: var(--fg);
  background: rgba(255, 122, 26, 0.1);
}

.back-to-top-container {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(168, 216, 255, 0.1);
}

.back-to-top {
  display: inline-block;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
  background: rgba(255, 122, 26, 0.1);
  transition: all 0.3s ease;
}

.back-to-top:hover {
  background: rgba(255, 122, 26, 0.2);
  transform: translateY(-2px);
}

#imprint {
  max-width: 800px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(168, 216, 255, 0.2);
}

#imprint h2 {
  margin-bottom: 1rem;
  color: var(--fg);
}

/* Accessibility & Focus States */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .games {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  
  .site-header {
    padding: 2rem 1rem 1.5rem;
  }
  
  .tagline {
    font-size: 1.1rem;
  }
  
  .site-footer nav {
    flex-direction: column;
    align-items: center;
  }
  
  .game-card {
    min-height: 160px;
  }
}

/* Print Styles */
@media print {
  .game-card {
    break-inside: avoid;
    border: 1px solid #ddd;
    box-shadow: none;
  }
  
  .flip-back {
    display: none;
  }
  
  .site-footer {
    border-top: 1px solid #ddd;
  }
  
  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
