:root {
  --bg-start: #FFE5D9;
  --bg-end: #D4E4F7;
  --ink: #2D2D2D;
  --ink-soft: #5a5a5a;
  --ink-faint: #8a8a8a;
  --paper: #FFFCF6;
  --paper-warm: #FFF6E8;
  --cyan: #00B4D8;
  --shadow-soft: 0 14px 32px rgba(45, 45, 45, 0.08);
  --shadow-lift: 0 28px 60px rgba(45, 45, 45, 0.18);
  --shadow-modal: 0 40px 100px rgba(45, 45, 45, 0.32);
  --sidebar-width: 240px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: 'Fredoka', sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: 'Lilita One', cursive;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.05;
  letter-spacing: 0.005em;
}

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

button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ====== Background ====== */
.bg-shapes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  will-change: transform;
}

.shape-1 { width: 460px; height: 460px; background: #FFB39A; top: -8%;  left: -10%; animation: drift 22s -2s infinite ease-in-out; }
.shape-2 { width: 340px; height: 340px; background: #B8D4F4; top: 28%;  right: -8%; animation: drift 26s -8s infinite ease-in-out; }
.shape-3 { width: 380px; height: 380px; background: #FFD9C8; bottom: -12%; left: 18%; animation: drift 28s -14s infinite ease-in-out; }
.shape-4 { width: 280px; height: 280px; background: #C9E4FF; top: 58%;  left: 36%; animation: drift 24s -18s infinite ease-in-out; }
.shape-5 { width: 220px; height: 220px; background: #FFE5D9; top: 8%;   right: 28%; animation: drift 20s -10s infinite ease-in-out; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(36px, -42px); }
  50% { transform: translate(-22px, 28px); }
  75% { transform: translate(44px, 18px); }
}

/* ====== Hero ====== */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 5rem 1.5rem 2rem;
  max-width: 920px;
  margin: 0 auto;
}

.hero.hero-project {
  text-align: left;
  padding: 4.5rem 1.5rem 1.5rem;
  max-width: 1200px;
}

.hero-decoration {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  font-size: 2rem;
  color: var(--cyan);
  animation: sparkle 4s infinite ease-in-out;
  opacity: 0.85;
}

.sparkle-1 { top: 18%; left: 10%; animation-delay: 0s; }
.sparkle-2 { top: 60%; right: 14%; animation-delay: -1.2s; font-size: 1.5rem; color: #FF6B6B; }
.sparkle-3 { bottom: 8%; left: 22%; animation-delay: -2.4s; color: #FFB347; font-size: 1.6rem; }
.sparkle-4 { top: 30%; right: 30%; animation-delay: -3.6s; color: #7B2CBF; font-size: 1.2rem; }

@keyframes sparkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.5; }
  50% { transform: scale(1.4) rotate(180deg); opacity: 1; }
}

.hero-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 1rem;
  display: inline-block;
  padding: 0.4rem 1rem;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.hero-title {
  font-size: clamp(2.6rem, 9vw, 6.8rem);
  letter-spacing: -0.015em;
  margin-bottom: 1.25rem;
  display: inline-block;
  position: relative;
  line-height: 0.95;
}

.hero-title-accent {
  color: var(--cyan);
  display: inline-block;
  transform: rotate(-3deg);
  background: linear-gradient(180deg, transparent 62%, rgba(0, 180, 216, 0.22) 62%, rgba(0, 180, 216, 0.22) 92%, transparent 92%);
  padding: 0 0.08em;
  margin-left: -0.05em;
}

.hero-subtitle {
  font-size: clamp(1rem, 1.85vw, 1.25rem);
  font-weight: 400;
  max-width: 640px;
  margin: 0 auto 0.75rem;
  line-height: 1.55;
  color: var(--ink);
}

.hero.hero-project .hero-subtitle {
  margin: 0 0 0.85rem;
  max-width: 720px;
}

.hero-subtitle strong {
  font-weight: 600;
  color: var(--cyan);
}

.hero-caption {
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-weight: 300;
  font-style: italic;
}

.hero-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
  padding: 0.45rem 0.95rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  font-weight: 500;
  transition: transform 0.2s ease, background 0.2s ease;
}

.hero-back:hover {
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(-3px);
}

/* ====== Layout: sidebar + content ====== */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  gap: 2rem;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 3rem;
  }
}

.sidebar {
  position: relative;
}

@media (min-width: 900px) {
  .sidebar {
    position: sticky;
    top: 1.5rem;
    align-self: start;
  }
}

.sidebar-label {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  padding: 0 0.85rem;
  margin-bottom: 0.65rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

@media (min-width: 900px) {
  .sidebar-nav {
    flex-direction: column;
    overflow-x: visible;
  }
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(3px);
  box-shadow: 0 6px 16px rgba(45, 45, 45, 0.08);
}

@media (max-width: 899px) {
  .sidebar-link:hover {
    transform: translateY(-2px);
  }
}

.sidebar-link.is-active {
  background: var(--cyan);
  color: white;
  border-color: var(--cyan);
  box-shadow: 0 8px 22px rgba(0, 180, 216, 0.35);
}

.sidebar-link-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-link-meta {
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-weight: 400;
  margin-left: auto;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-link.is-active .sidebar-link-meta {
  color: rgba(255, 255, 255, 0.85);
}

/* ====== Games section ====== */
.content {
  min-width: 0;
}

.games-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3rem 2rem;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 1rem 0;
}

@media (max-width: 700px) {
  .games-grid {
    justify-content: center;
    gap: 2.5rem 1.5rem;
  }
}

.loading-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 1rem;
  width: 100%;
  font-style: italic;
}

/* ====== Game card ====== */
.game-card {
  --card-color: #00B4D8;
  --card-accent: #FFD93D;
  position: relative;
  background: var(--paper);
  border-radius: 22px;
  padding: 0;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 320px;
  flex: 1 1 280px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  animation: cardEnter 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(40px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.game-card:nth-child(5n+1) { transform: rotate(-1.2deg); animation-delay: 0.05s; }
.game-card:nth-child(5n+2) { transform: rotate(0.9deg);  animation-delay: 0.12s; }
.game-card:nth-child(5n+3) { transform: rotate(-0.6deg); animation-delay: 0.19s; }
.game-card:nth-child(5n+4) { transform: rotate(1.4deg);  animation-delay: 0.26s; }
.game-card:nth-child(5n+5) { transform: rotate(-1.0deg); animation-delay: 0.33s; }

.game-card:hover,
.game-card:focus-visible {
  transform: rotate(0deg) translateY(-12px) scale(1.025);
  box-shadow: var(--shadow-lift), 0 0 0 4px rgba(255, 255, 255, 0.6);
  z-index: 2;
}

.game-card:focus-visible {
  outline: 3px solid var(--card-color);
  outline-offset: 5px;
}

.card-image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--card-color);
}

.card-image-frame::before {
  /* color strip on top to tie image to card theme */
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--card-color);
  z-index: 2;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-card:hover .card-image {
  transform: scale(1.06);
}

.card-image-frame::after {
  /* subtle gradient at bottom for legibility if needed */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.18) 100%);
  pointer-events: none;
  z-index: 1;
}

.card-number {
  position: absolute;
  top: 14px;
  left: 14px;
  font-family: 'Lilita One', cursive;
  font-size: 0.85rem;
  color: white;
  letter-spacing: 0.05em;
  z-index: 3;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.card-stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--card-accent);
  color: var(--ink);
  font-family: 'Lilita One', cursive;
  font-size: 0.7rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transform: rotate(7deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  z-index: 3;
}

.card-emoji-badge {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 3;
}

.card-body {
  padding: 1.4rem 1.5rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  background: var(--paper);
}

.card-title {
  font-size: 1.5rem;
  color: var(--card-color);
  line-height: 1;
}

.card-subtitle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  font-style: italic;
  line-height: 1.3;
  margin-top: 0.15rem;
}

.card-tagline {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.22rem 0.65rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 999px;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.card-credit {
  font-size: 0.78rem;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card-credit::before {
  content: '◆';
  color: var(--card-color);
  font-size: 0.7rem;
}

/* ====== Modal ====== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 45, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  --modal-color: #00B4D8;
  --modal-accent: #FFD93D;
  position: relative;
  background: var(--paper);
  border-radius: 28px;
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  animation: modalRise 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalRise {
  from { opacity: 0; transform: translateY(50px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--ink);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease, background 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  line-height: 1;
}

.modal-close:hover {
  transform: scale(1.1) rotate(90deg);
  background: white;
}

.modal-banner {
  background: var(--modal-color);
  color: white;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  aspect-ratio: 16 / 7.5;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.modal-banner-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.modal-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.65) 100%);
  z-index: 1;
}

.modal-banner-text {
  position: relative;
  z-index: 2;
  padding: 1.5rem 2rem 1.6rem;
}

.modal-credit {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.92;
  margin-bottom: 0.3rem;
  font-weight: 500;
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--modal-accent);
  color: var(--ink);
  border-radius: 999px;
}

.modal-title {
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  color: white;
  margin: 0.55rem 0 0.3rem;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.modal-subtitle {
  font-size: 1rem;
  font-style: italic;
  opacity: 0.95;
  font-weight: 400;
  text-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

.modal-body {
  padding: 1.7rem 2rem 1.9rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--paper);
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.5rem;
}

.modal-tags .tag {
  background: var(--modal-accent);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.74rem;
  padding: 0.28rem 0.75rem;
}

.modal-section {
  margin-bottom: 1.4rem;
}

.modal-section h3 {
  font-size: 1.3rem;
  color: var(--modal-color);
  margin-bottom: 0.5rem;
  position: relative;
  padding-left: 1.3rem;
}

.modal-section h3::before {
  content: '◆';
  position: absolute;
  left: 0;
  color: var(--modal-accent);
  font-size: 0.85rem;
  top: 0.5rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.modal-section p {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--ink);
  font-weight: 400;
}

.modal-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: var(--modal-color);
  color: white;
  font-family: 'Lilita One', cursive;
  font-size: 1.3rem;
  padding: 1.05rem 2rem;
  border-radius: 16px;
  margin-top: 1.4rem;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
  position: relative;
  overflow: hidden;
}

.modal-play::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, transparent 50%);
  pointer-events: none;
}

.modal-play:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  filter: brightness(1.05);
}

.modal-play:active {
  transform: translateY(0);
}

.modal-play-icon {
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 50%;
}

/* ====== Footer ====== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1.5rem 2.5rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.footer p {
  margin-bottom: 0.3rem;
}

.footer-sub {
  font-style: italic;
  font-weight: 300;
  opacity: 0.8;
  font-size: 0.82rem;
}

/* ====== Responsive tuning ====== */
@media (max-width: 600px) {
  .hero {
    padding: 3.5rem 1.25rem 1rem;
  }
  .layout {
    padding: 0 1.25rem 3rem;
  }
  .games-grid {
    gap: 2.5rem 1.25rem;
  }
  .modal-banner-text {
    padding: 1.2rem 1.5rem 1.3rem;
  }
  .modal-body {
    padding: 1.4rem 1.5rem 1.5rem;
  }
  .game-card:nth-child(n) {
    transform: none;
  }
}

/* ====== Reduced motion ====== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .game-card:nth-child(n) {
    transform: none;
  }
}
