:root {
  --bg: #061117;
  --bg-deep: #03090d;
  --panel: #0d1c24;
  --panel-raised: #112630;
  --panel-soft: rgba(13, 28, 36, 0.88);
  --text: #f5fafb;
  --muted: #9fb2ba;
  --line: rgba(145, 190, 202, 0.18);
  --line-strong: rgba(148, 211, 222, 0.34);
  --cyan: #68d0df;
  --cyan-strong: #45b8cd;
  --mint: #8bcf9b;
  --gold: #f2c75c;
  --orange: #ed8b45;
  --danger: #ef6d68;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.3);
  --soft-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  --spot-x: 50%;
  --spot-y: 50%;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 6%, rgba(104, 208, 223, 0.12), transparent 29%),
    radial-gradient(circle at 90% 42%, rgba(139, 207, 155, 0.07), transparent 27%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.018), transparent 24%),
    radial-gradient(circle at center, transparent 55%, rgba(0,0,0,.27));
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(104,208,223,.55); outline-offset: 3px; }

.hub-header {
  position: sticky;
  top: 12px;
  z-index: 50;
  width: min(1120px, calc(100% - 28px));
  margin: 12px auto 0;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(5, 15, 21, .9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(17px) saturate(1.05);
  transition: top .22s ease, width .22s ease, background .22s ease;
}
.hub-header.is-scrolled {
  top: 7px;
  width: min(1080px, calc(100% - 28px));
  background: rgba(4, 12, 17, .97);
}
.hub-brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; }
.hub-brand img { width: 40px; height: 40px; object-fit: contain; }
.hub-brand span { display: flex; flex-direction: column; gap: 2px; }
.hub-brand strong { font-size: .96rem; line-height: 1; }
.hub-brand small { color: var(--muted); font-size: .73rem; }
.hub-nav { display: flex; align-items: center; justify-content: center; gap: 24px; color: var(--muted); font-size: .9rem; font-weight: 700; }
.hub-nav a { position: relative; padding: 8px 0; transition: color .18s ease; }
.hub-nav a::after { content: ""; position: absolute; left: 50%; bottom: 1px; width: 0; height: 2px; border-radius: 99px; background: var(--cyan); transform: translateX(-50%); transition: width .2s ease; }
.hub-nav a:hover, .hub-nav a.active { color: var(--text); }
.hub-nav a:hover::after, .hub-nav a.active::after { width: 18px; }
.header-action, .primary-action, .secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 13px;
  font-weight: 800;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.header-action { justify-self: end; color: #102019; background: var(--gold); border: 1px solid rgba(242,199,92,.52); box-shadow: 0 10px 24px rgba(242,199,92,.16); }
.primary-action { color: #061117; background: var(--cyan); border: 1px solid rgba(104,208,223,.55); box-shadow: 0 12px 28px rgba(72,186,208,.2); }
.secondary-action { border: 1px solid var(--line-strong); background: rgba(255,255,255,.025); }
.header-action:hover, .primary-action:hover, .secondary-action:hover { transform: translateY(-2px); }
.primary-action:hover { background: #7ad9e6; }
.secondary-action:hover { background: rgba(104,208,223,.055); border-color: rgba(104,208,223,.48); }

.page-shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; }
.page-hero { padding: 105px 0 64px; }
.eyebrow { margin: 0 0 14px; color: var(--cyan); font-size: .71rem; font-weight: 800; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 790px; margin-bottom: 18px; font-size: clamp(3.2rem, 7vw, 6rem); line-height: .98; letter-spacing: -.065em; }
h2 { font-size: clamp(2rem, 4vw, 3.55rem); line-height: 1.04; letter-spacing: -.05em; }
h3 { letter-spacing: -.025em; }
.lead { max-width: 720px; color: var(--muted); font-size: clamp(1.02rem, 1.5vw, 1.18rem); line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 28px; }

.section-block { padding: 36px 0 84px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-heading h2 { margin-bottom: 8px; }
.section-heading p { max-width: 610px; margin-bottom: 0; color: var(--muted); line-height: 1.7; }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; }
.game-card, .journal-card, .info-panel, .post-panel, .game-panel {
  --spot-x: 50%;
  --spot-y: 50%;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(circle 210px at var(--spot-x) var(--spot-y), rgba(104,208,223,.07), transparent 72%), var(--panel-soft);
  box-shadow: var(--shadow);
}
.game-card, .journal-card { border-radius: 22px; transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.game-card::before, .journal-card::before, .info-panel::before, .post-panel::before, .game-panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,.035), transparent 28%); }
.game-card:hover, .journal-card:hover { transform: translateY(-5px); border-color: var(--line-strong); }
.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--panel-raised); border-bottom: 1px solid var(--line); }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; transition: transform .38s ease, filter .28s ease; }
.game-card:hover .card-media img, .journal-card:hover .card-media img, .journal-card:hover .card-media video { transform: scale(1.035); }
.card-body { position: relative; z-index: 1; padding: 20px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--cyan); background: rgba(104,208,223,.045); font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.card-body h3 { margin-bottom: 9px; font-size: 1.45rem; }
.card-body p { margin-bottom: 0; color: var(--muted); line-height: 1.65; }
.card-link { display: inline-flex; align-items: center; gap: 7px; margin-top: 18px; color: var(--cyan); font-weight: 800; }
.card-link span { transition: transform .18s ease; }
.game-card:hover .card-link span, .journal-card:hover .card-link span { transform: translateX(4px); }
.coming-soon { opacity: .62; cursor: default; }
.coming-soon:hover { transform: none; border-color: var(--line); }

.snake-preview { position: relative; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(145deg, #0b222b, #08161d); }
.snake-preview::before { content: ""; position: absolute; inset: 0; opacity: .24; background-image: linear-gradient(rgba(104,208,223,.15) 1px, transparent 1px), linear-gradient(90deg, rgba(104,208,223,.15) 1px, transparent 1px); background-size: 28px 28px; }
.snake-preview span { position: absolute; width: 27px; height: 27px; border-radius: 9px; background: var(--cyan); box-shadow: inset 0 2px rgba(255,255,255,.35), 0 8px 18px rgba(72,186,208,.22); }
.snake-preview .s1 { left: 18%; top: 55%; }
.snake-preview .s2 { left: 25%; top: 55%; }
.snake-preview .s3 { left: 32%; top: 55%; }
.snake-preview .s4 { left: 39%; top: 48%; }
.snake-preview .s5 { left: 39%; top: 41%; }
.snake-preview .food { right: 23%; top: 31%; width: 25px; height: 25px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 25px rgba(242,199,92,.45), inset 0 2px rgba(255,255,255,.55); }
.placeholder-art { display: grid; place-items: center; width: 100%; height: 100%; color: rgba(255,255,255,.22); font-size: 4.5rem; font-weight: 800; background: radial-gradient(circle, rgba(104,208,223,.09), transparent 60%); }

.filters { display: flex; flex-wrap: wrap; gap: 9px; margin: 0 0 28px; }
.filter-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.02); cursor: pointer; font-weight: 750; transition: color .18s ease, background .18s ease, border-color .18s ease; }
.filter-button:hover, .filter-button.active { color: var(--text); border-color: var(--line-strong); background: rgba(104,208,223,.065); }
.search-box { width: min(420px, 100%); min-height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--panel); }
.search-box::placeholder { color: #718890; }
.journal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.journal-card .card-media { aspect-ratio: 16 / 9; }
.journal-card .contain-media { object-fit: contain; padding: 24px; background: radial-gradient(circle, rgba(104,208,223,.13), transparent 62%), #0b1b23; }
.empty-state { grid-column: 1 / -1; padding: 38px; border: 1px dashed var(--line-strong); border-radius: 18px; color: var(--muted); text-align: center; }

.post-shell { width: min(850px, calc(100% - 32px)); margin: 0 auto; }
.post-header { padding: 90px 0 38px; }
.post-header h1 { max-width: 850px; font-size: clamp(3rem, 7vw, 5.5rem); }
.post-description { max-width: 720px; color: var(--muted); font-size: 1.12rem; line-height: 1.75; }
.post-date { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--muted); font-size: .86rem; font-weight: 750; }
.post-date::before { content: ""; width: 26px; height: 2px; background: var(--cyan); }
.post-hero { overflow: hidden; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); }
.post-hero img, .post-hero video { width: 100%; max-height: 590px; object-fit: cover; }
.post-panel { margin-bottom: 22px; padding: 30px; border-radius: 22px; }
.post-panel > * { position: relative; z-index: 1; }
.post-panel p, .post-panel li { color: var(--muted); line-height: 1.8; }
.post-panel p:last-child { margin-bottom: 0; }
.post-panel h2 { margin-bottom: 15px; font-size: clamp(1.75rem, 4vw, 2.65rem); }
.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 20px; }
.media-item { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--panel-raised); cursor: zoom-in; }
.media-item img, .media-item video { width: 100%; height: 100%; min-height: 220px; object-fit: cover; transition: transform .28s ease; }
.media-item:hover img, .media-item:hover video { transform: scale(1.025); }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--cyan); font-weight: 800; }

.game-page { padding: 80px 0; }
.game-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.game-heading h1 { margin-bottom: 8px; font-size: clamp(2.8rem, 6vw, 4.8rem); }
.game-heading p { margin-bottom: 0; color: var(--muted); }
.score-row { display: flex; flex-wrap: wrap; gap: 10px; }
.score-chip { min-width: 105px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.score-chip small { display: block; margin-bottom: 3px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.score-chip strong { font-size: 1.15rem; }
.game-panel { padding: 18px; border-radius: 24px; }
.game-stage { position: relative; width: min(680px, 100%); margin: 0 auto; }
#snakeCanvas { width: 100%; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 19px; background: #07161c; box-shadow: inset 0 0 80px rgba(0,0,0,.2); touch-action: none; }
.game-message { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.game-message > div { max-width: 310px; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: 17px; background: rgba(5,16,22,.9); box-shadow: var(--shadow); text-align: center; backdrop-filter: blur(12px); }
.game-message h2 { margin-bottom: 7px; font-size: 1.65rem; }
.game-message p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.game-message.hidden { display: none; }
.game-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.game-button, .difficulty-select { min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 13px; color: var(--text); background: rgba(255,255,255,.025); cursor: pointer; font-weight: 800; }
.game-button.primary { color: #061117; background: var(--cyan); border-color: rgba(104,208,223,.55); }
.game-button:hover { transform: translateY(-1px); }
.difficulty-select { cursor: pointer; }
.touch-controls { display: none; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 58px); justify-content: center; gap: 7px; margin-top: 18px; }
.touch-button { border: 1px solid var(--line-strong); border-radius: 16px; color: var(--text); background: var(--panel-raised); font-size: 1.3rem; font-weight: 900; }
.touch-button[data-direction="up"] { grid-column: 2; }
.touch-button[data-direction="left"] { grid-column: 1; grid-row: 2; }
.touch-button[data-direction="down"] { grid-column: 2; grid-row: 2; }
.touch-button[data-direction="right"] { grid-column: 3; grid-row: 2; }
.control-note { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: .86rem; }

.media-dialog { width: min(980px, calc(100% - 28px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 20px; background: #061117; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.media-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(5px); }
.media-dialog img { width: 100%; max-height: 82vh; object-fit: contain; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 50%; color: white; background: rgba(5,15,21,.85); cursor: pointer; font-size: 1.25rem; }

.site-footer { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 42px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.footer-brand img { width: 36px; height: 36px; object-fit: contain; }
.footer-brand span { display: flex; flex-direction: column; gap: 2px; }
.footer-brand small { color: var(--muted); }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity .58s ease var(--delay, 0ms), transform .58s ease var(--delay, 0ms); }
.reveal.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .hub-header { grid-template-columns: 1fr auto; }
  .hub-nav { display: none; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .journal-grid { grid-template-columns: 1fr; }
  .game-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .hub-header, .page-shell, .post-shell, .site-footer { width: calc(100% - 22px); }
  .hub-header { top: 7px; margin-top: 7px; padding: 9px 10px; }
  .hub-brand small { display: none; }
  .header-action { padding: 10px 12px; font-size: .79rem; }
  .page-hero { padding: 86px 0 48px; }
  h1 { font-size: clamp(3rem, 15vw, 4.8rem); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .card-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
  .post-panel { padding: 22px; }
  .game-page { padding: 62px 0; }
  .game-panel { padding: 10px; }
  .touch-controls { display: grid; }
  .control-note .desktop-only { display: none; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
