@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
  src: url("../fonts/cinzel.woff2") format("woff2");
}

@font-face {
  font-family: "Outfit";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/outfit.woff2") format("woff2");
}

:root {
  --bg: #0a070b;
  --bg-2: #140f16;
  --surface: #1b141e;
  --surface-2: #261c2b;
  --bone: #f3ead8;
  --bone-dim: #c9bba8;
  --muted: #9a8b97;
  --crimson: #ff3b55;
  --crimson-dim: #c01d38;
  --violet: #b388ff;
  --violet-dim: #7a4ed0;
  --gold: #e8c36a;
  --gold-dim: #b8943f;
  --poison: #7dff9a;
  --line: rgba(243, 234, 216, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-display: "Cinzel", "Palatino Linotype", Palatino, serif;
  --font-body: "Outfit", "Segoe UI", sans-serif;
  --header-h: 4.25rem;
  --radius: 1.15rem;
  --max: 1080px;
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--bone);
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(192, 29, 56, 0.22), transparent 60%),
    radial-gradient(700px 480px at 100% 100%, rgba(122, 78, 208, 0.16), transparent 55%),
    radial-gradient(640px 420px at 0% 90%, rgba(232, 195, 106, 0.07), transparent 50%),
    var(--bg);
  letter-spacing: 0.01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(243, 234, 216, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 234, 216, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 35%, transparent 80%);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  background: var(--gold);
  color: #1a0c12;
  padding: 0.5rem 0.9rem;
  border-radius: 0.4rem;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.7rem;
}

a {
  color: var(--gold);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.site-header,
.site-footer,
main {
  position: relative;
  z-index: 1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(10, 7, 11, 0.78);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--bone);
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  filter: drop-shadow(0 0 10px rgba(232, 195, 106, 0.35));
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 1.15rem;
  font-size: 0.95rem;
}

.nav a {
  color: var(--bone-dim);
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--gold);
}

.hero {
  padding: 3.2rem 0 2.4rem;
  text-align: center;
}

.hero-mark {
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1.1rem;
  filter: drop-shadow(0 0 18px rgba(255, 59, 85, 0.28));
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(255, 59, 85, 0.28);
}

.hero .tagline {
  margin: 1rem auto 0;
  max-width: 34rem;
  color: var(--bone-dim);
  font-size: 1.15rem;
}

.hero-actions {
  margin-top: 1.6rem;
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  text-decoration: none;
  color: #1a0c12;
  background: var(--gold);
  box-shadow: 0 0 0 1px rgba(232, 195, 106, 0.2), 0 0 22px rgba(232, 195, 106, 0.18);
}

.btn:hover {
  color: #1a0c12;
  background: #f3d58a;
}

.btn-ghost {
  color: var(--bone);
  background: transparent;
  border-color: var(--line);
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(232, 195, 106, 0.08);
}

.btn-danger {
  background: var(--crimson);
  color: #fff8f8;
  box-shadow: 0 0 22px rgba(255, 59, 85, 0.22);
}

.btn-danger:hover {
  color: #fff;
  background: #ff5c71;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.section {
  padding: 0.5rem 0 3.5rem;
}

.section h2 {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: var(--gold);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.25rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #221826, #160f18);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: rgba(232, 195, 106, 0.45);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 28px rgba(255, 59, 85, 0.12);
}

.game-card .thumb {
  aspect-ratio: 16 / 10;
  background: #120c14;
  border-bottom: 1px solid var(--line);
}

.game-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-card .body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem 1.15rem 1.2rem;
  flex: 1;
}

.game-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  flex: 1;
}

.game-card .btn {
  align-self: flex-start;
  margin-top: 0.35rem;
}

.page {
  padding: 2.4rem 0 3.5rem;
}

.page h1 {
  margin: 0 0 0.8rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.prose {
  max-width: 40rem;
}

.prose p,
.prose li {
  color: var(--bone-dim);
}

.prose h2 {
  margin: 2rem 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.4rem 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  justify-content: space-between;
  align-items: center;
}

.site-footer nav {
  display: flex;
  gap: 1rem;
}

.site-footer a {
  color: var(--bone-dim);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--gold);
}

/* Game pages */
.game-page .wrap {
  width: min(100% - 1.5rem, 720px);
}

.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 1.3rem 0 1rem;
}

.back {
  color: var(--bone-dim);
  text-decoration: none;
  font-size: 0.92rem;
}

.back:hover {
  color: var(--gold);
}

.game-top h1 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 1.6rem;
}

.how {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.cabinet {
  background: linear-gradient(180deg, #221826 0%, #160f18 100%);
  border: 1px solid rgba(232, 195, 106, 0.32);
  box-shadow:
    0 0 0 1px #1a1014,
    0 0 40px rgba(255, 59, 85, 0.08),
    inset 0 1px 0 rgba(243, 234, 216, 0.08);
  border-radius: 1.25rem;
  padding: 0.9rem 0.9rem 1rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hud-item {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.45rem 0.65rem 0.5rem;
  text-align: center;
}

.hud-item span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-item strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
}

.stage {
  position: relative;
  background: #0c090e;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  text-align: center;
  background: rgba(8, 5, 10, 0.78);
  backdrop-filter: blur(6px);
}

.overlay[hidden] {
  display: none;
}

.overlay h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1.45rem;
  color: var(--gold);
}

.overlay p {
  margin: 0;
  color: var(--bone-dim);
  max-width: 22rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.dpad {
  display: none;
  width: min(100%, 220px);
  margin: 1rem auto 0.2rem;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 3.15rem);
  gap: 0.45rem;
}

.dpad button {
  appearance: none;
  border: 1px solid rgba(232, 195, 106, 0.3);
  background: #201821;
  color: var(--bone);
  border-radius: 0.7rem;
  font-size: 1.15rem;
  cursor: pointer;
}

.dpad button:active {
  background: #3a2430;
  color: var(--gold);
}

.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }

@media (max-width: 800px), (pointer: coarse) {
  .dpad {
    display: grid;
  }
}

/* 2048 board */
.board-2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  padding: 0.7rem;
  background: #100c12;
}

.cell-2048 {
  aspect-ratio: 1;
  border-radius: 0.45rem;
  background: #231a26;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 6vw, 1.85rem);
  color: var(--bone);
}

.cell-2048[data-v="2"] { background: #3a2a32; }
.cell-2048[data-v="4"] { background: #4a3340; }
.cell-2048[data-v="8"] { background: #6b2b3a; color: #fff6e8; }
.cell-2048[data-v="16"] { background: #8e1f38; color: #fff6e8; }
.cell-2048[data-v="32"] { background: #b41c3c; color: #fff6e8; }
.cell-2048[data-v="64"] { background: #e02545; color: #fff6e8; }
.cell-2048[data-v="128"] { background: #7a4ed0; color: #fff6e8; font-size: clamp(0.95rem, 5vw, 1.45rem); }
.cell-2048[data-v="256"] { background: #9b5cff; color: #fff6e8; font-size: clamp(0.95rem, 5vw, 1.45rem); }
.cell-2048[data-v="512"] { background: #c9a44a; color: #1a0c12; font-size: clamp(0.95rem, 5vw, 1.45rem); }
.cell-2048[data-v="1024"] { background: #e8c36a; color: #1a0c12; font-size: clamp(0.8rem, 4.4vw, 1.2rem); }
.cell-2048[data-v="2048"] {
  background: #ffe08a;
  color: #1a0c12;
  font-size: clamp(0.8rem, 4.4vw, 1.2rem);
  box-shadow: 0 0 18px rgba(232, 195, 106, 0.55);
}
.cell-2048[data-v="4096"],
.cell-2048[data-v="8192"] {
  background: #7dff9a;
  color: #0b1a10;
  font-size: clamp(0.8rem, 4.4vw, 1.15rem);
}

/* Memory */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  padding: 0.7rem;
  background: #100c12;
}

.mem-card {
  appearance: none;
  aspect-ratio: 1;
  border: 1px solid rgba(179, 136, 255, 0.28);
  border-radius: 0.6rem;
  background: linear-gradient(160deg, #2a1c32, #1a1220);
  color: var(--bone);
  cursor: pointer;
  padding: 0.35rem;
  position: relative;
}

.mem-card .face,
.mem-card .back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.mem-card .face {
  display: none;
}

.mem-card .back svg {
  width: 42%;
  height: 42%;
  opacity: 0.85;
}

.mem-card .face svg {
  width: 64%;
  height: 64%;
}

.mem-card.is-flipped,
.mem-card.is-matched {
  background: #f3ead8;
  border-color: var(--gold);
  color: #1a0c12;
}

.mem-card.is-flipped .face,
.mem-card.is-matched .face {
  display: flex;
}

.mem-card.is-flipped .back,
.mem-card.is-matched .back {
  display: none;
}

.mem-card.is-matched {
  background: #7dff9a;
  border-color: #4ad673;
  cursor: default;
}

.mem-card:disabled {
  cursor: default;
}

.not-found {
  text-align: center;
  padding: 4rem 0 5rem;
}

.not-found h1 {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
}

.not-found p {
  color: var(--bone-dim);
}

.not-found img {
  width: 6rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 16px rgba(255, 59, 85, 0.25));
}

@media (max-width: 600px) {
  .brand-name {
    letter-spacing: 0.1em;
    font-size: 1rem;
  }

  .hero {
    padding-top: 2.2rem;
  }

  .cabinet {
    padding: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .game-card { transition: none; }
  .game-card:hover { transform: none; }
}

/* Grave Stack */
.stack-play {
  display: grid;
  grid-template-columns: 1fr 5.6rem;
  gap: 0.65rem;
  align-items: start;
  padding: 0.55rem;
}

.stack-play #board {
  width: 100%;
  height: auto;
  display: block;
  background: #0c090e;
  border-radius: 0.5rem;
}

.next-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  background: #100c12;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.45rem 0.35rem 0.55rem;
}

.next-box span {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.next-box canvas {
  width: 100%;
  height: auto;
  display: block;
}

.stack-pad {
  display: none;
  width: min(100%, 280px);
  margin: 1rem auto 0.2rem;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.stack-pad button {
  appearance: none;
  border: 1px solid rgba(232, 195, 106, 0.3);
  background: #201821;
  color: var(--bone);
  border-radius: 0.7rem;
  min-height: 3.1rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.stack-pad button:active {
  background: #3a2430;
  color: var(--gold);
}

.stack-pad .rot { grid-column: 2; }
.stack-pad .left { grid-column: 1; }
.stack-pad .down { grid-column: 2; }
.stack-pad .right { grid-column: 3; }
.stack-pad .hard { grid-column: 1 / 4; }

@media (max-width: 800px), (pointer: coarse) {
  .stack-pad {
    display: grid;
  }
}

/* Skull Siege */
.health-bar {
  height: 0.7rem;
  margin-top: 0.3rem;
  border-radius: 999px;
  background: #2a1620;
  overflow: hidden;
  border: 1px solid rgba(243, 234, 216, 0.12);
}

.health-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff3b55, #e8c36a);
}

.health-fill.is-low {
  background: #ff3b55;
}

.siege-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
  background: #0c090e;
}

.touch-controls {
  display: none;
  position: relative;
  height: 8.2rem;
  margin-top: 0.7rem;
}

.joystick {
  position: absolute;
  left: 0.2rem;
  bottom: 0.2rem;
  width: 7.2rem;
  height: 7.2rem;
  border-radius: 50%;
  background: rgba(32, 24, 33, 0.9);
  border: 1px solid rgba(232, 195, 106, 0.3);
  touch-action: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2.6rem;
  height: 2.6rem;
  margin: -1.3rem 0 0 -1.3rem;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px rgba(232, 195, 106, 0.35);
  pointer-events: none;
}

.fire-btn {
  position: absolute;
  right: 0.2rem;
  bottom: 0.7rem;
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50%;
  appearance: none;
  border: 2px solid rgba(255, 59, 85, 0.7);
  background: #c01d38;
  color: #fff8f8;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 0 18px rgba(255, 59, 85, 0.28);
}

.fire-btn:active {
  background: #ff3b55;
}

@media (max-width: 800px), (pointer: coarse) {
  .touch-controls {
    display: block;
  }
}
