:root {
  --paper: #faf8f2;
  --ink: #2c2a30;
  --ink-soft: #5b5862;
  --blue: #2f6fa3;
  --blue-soft: #54a0d6;
  --ice: #cfe6f5;
  --section-spacing: clamp(40px, 6vw, 60px);
  --section-edge-spacing: clamp(44px, 5vw, 56px);
  --content-section-gap: clamp(48px, 5vw, 60px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0e1014;
  --ink: #fff;
  --ink-soft: #e0ddd6;
  --blue: #74b3e6;
  --blue-soft: #4d8dbd;
  --ice: #1f3a4f;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

::selection {
  color: var(--ink);
  background: var(--ice);
}

a:focus-visible,
button:focus-visible {
  outline: 2.5px dashed var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
}

body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Patrick Hand", system-ui, "Comic Sans MS", cursive;
  font-size: 1.18rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition:
    color 0.35s,
    background-color 0.35s;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.04;
}

[data-theme="dark"] body::before {
  filter: invert(1);
  opacity: 0.07;
}

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

a:hover {
  text-decoration: underline;
}

img {
  user-select: none;
  -webkit-user-drag: none;
}

.topbar {
  --navbar-spacing: clamp(14px, 4.5vw, 34px);

  position: sticky;
  z-index: 100;
  top: 12px;
  display: flex;
  align-items: center;
  width: fit-content;
  max-width: calc(100% - 8px);
  padding: 8px var(--navbar-spacing);
  margin: 14px auto 0;
  background: color-mix(in srgb, var(--paper) 76%, transparent);
  border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(30, 50, 80, 0.05);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  transition:
    box-shadow 0.3s,
    background-color 0.35s,
    border-color 0.35s;
}

.topbar.is-scrolled {
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  box-shadow: 0 10px 28px rgba(30, 50, 80, 0.13);
}

.topbar nav {
  display: flex;
  flex: 1;
  gap: var(--navbar-spacing);
  align-items: center;
}

.nav-links {
  display: flex;
  gap: var(--navbar-spacing);
  align-items: center;
}

.nav-links a {
  position: relative;
  color: var(--ink-soft);
  font-family: "Patrick Hand SC", cursive;
  font-size: 1.12rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.nav-links a::after {
  position: absolute;
  right: 0;
  bottom: -3px;
  left: 0;
  height: 3px;
  content: "";
  background: var(--blue-soft);
  border-radius: 3px;
  transform: scaleX(0) rotate(-0.6deg);
  transform-origin: left;
  transition: transform 0.25s cubic-bezier(0.3, 1.2, 0.4, 1);
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--blue);
  text-decoration: none;
}

.nav-links a:hover::after,
.nav-links a.is-active::after {
  transform: scaleX(1) rotate(-0.6deg);
}

/* Theme toggle */

#theme-toggle {
  position: relative;
  flex: none;
  width: 4em;
  height: 2em;
  padding: 0;
  overflow: hidden;
  font-size: 16px;
  cursor: pointer;
  background: linear-gradient(180deg, #0e1730 0, #2c3f6e 100%);
  border: 2px solid var(--ink);
  border-radius: 2em;
  box-shadow: inset 0 0.12em 0.3em rgba(0, 10, 40, 0.35);
  transition: border-color 0.35s;
}

#theme-toggle::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, #8ec9f2 0, #c3e4f9 100%);
  border-radius: inherit;
  opacity: 1;
  transition: opacity 0.5s;
}

[data-theme="dark"] #theme-toggle::before {
  opacity: 0;
}

.theme-knob {
  position: absolute;
  z-index: 2;
  top: calc(50% - 0.72em);
  left: 0.22em;
  width: 1.44em;
  height: 1.44em;
  background: #ffd85e;
  border-radius: 50%;
  box-shadow:
    0 0 0.5em rgba(255, 200, 60, 0.9),
    inset -0.18em -0.18em 0 rgba(235, 160, 25, 0.5);
  transition:
    transform 0.55s cubic-bezier(0.68, -0.25, 0.32, 1.35),
    background 0.45s,
    box-shadow 0.45s;
}

[data-theme="dark"] .theme-knob {
  background: #edeadf;
  box-shadow:
    0 0 0.45em rgba(190, 215, 255, 0.55),
    inset -0.18em -0.18em 0 rgba(150, 155, 180, 0.45);
  transform: translateX(1.87em);
}

.theme-knob::before,
.theme-knob::after {
  position: absolute;
  content: "";
  background: rgba(140, 148, 175, 0.55);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.35s 0.12s;
}

.theme-knob::before {
  top: 0.5em;
  left: 0.26em;
  width: 0.4em;
  height: 0.4em;
}

.theme-knob::after {
  top: 0.22em;
  left: 0.78em;
  width: 0.26em;
  height: 0.26em;
}

[data-theme="dark"] .theme-knob::before,
[data-theme="dark"] .theme-knob::after {
  opacity: 1;
}

.theme-star {
  position: absolute;
  z-index: 1;
  width: 0.36em;
  height: 0.36em;
  background: #fff;
  clip-path: polygon(
    50% 0,
    63% 38%,
    100% 50%,
    63% 62%,
    50% 100%,
    37% 62%,
    0 50%,
    37% 38%
  );
  opacity: 0;
  transform: scale(0) rotate(-60deg);
  transition:
    opacity 0.25s,
    transform 0.25s;
}

.star-one {
  top: 0.42em;
  left: 0.55em;
}

.star-two {
  top: 1.15em;
  left: 1.15em;
  width: 0.28em;
  height: 0.28em;
}

.star-three {
  top: 0.5em;
  left: 1.62em;
  width: 0.24em;
  height: 0.24em;
}

[data-theme="dark"] .theme-star {
  opacity: 1;
  transform: scale(1) rotate(0);
}

[data-theme="dark"] .star-one {
  transition-delay: 0.18s;
}

[data-theme="dark"] .star-two {
  transition-delay: 0.3s;
}

[data-theme="dark"] .star-three {
  transition-delay: 0.42s;
}

.theme-cloud {
  position: absolute;
  z-index: 1;
  background: #fff;
  border-radius: 1em;
  opacity: 0.95;
  transition:
    transform 0.45s,
    opacity 0.35s;
}

.cloud-one {
  top: 0.4em;
  right: 0.5em;
  width: 1em;
  height: 0.34em;
}

.cloud-one::before {
  position: absolute;
  top: -0.18em;
  left: 0.28em;
  width: 0.42em;
  height: 0.42em;
  content: "";
  background: #fff;
  border-radius: 50%;
}

.cloud-two {
  right: 0.32em;
  bottom: 0.32em;
  width: 0.72em;
  height: 0.26em;
  opacity: 0.8;
}

[data-theme="dark"] .theme-cloud {
  opacity: 0;
  transform: translateX(1.4em);
}

main {
  position: relative;
  z-index: 1;
  max-width: 680px;
  padding: 0 clamp(20px, 5vw, 32px);
  margin: 0 auto;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: auto;
  padding: var(--section-spacing) 0;
  text-align: center;
}

.cube-wrap {
  position: relative;
  display: inline-block;
  animation: cube-in 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.25) backwards;
}

@keyframes cube-in {
  from {
    opacity: 0;
    scale: 0.55;
    translate: 0 34px;
  }
}

#cube-button {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: none;
  border: 0;
}

.cube-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 42%,
    rgba(255, 255, 255, 0.85) 50%,
    transparent 58%
  );
  background-size: 320% 100%;
  background-position: 130% 0;
  -webkit-mask-image: var(--cube-mask);
  mask-image: var(--cube-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  animation: shine-sweep 5.5s ease-in-out 1.6s infinite;
}

[data-theme="dark"] .cube-shine {
  opacity: 0.45;
}

@keyframes shine-sweep {
  0%,
  60% {
    background-position: 130% 0;
  }

  90%,
  100% {
    background-position: -40% 0;
  }
}

#cube {
  display: block;
  width: clamp(220px, 38vw, 330px);
  height: auto;
  filter: drop-shadow(4px 8px 9px rgba(40, 60, 80, 0.2));
  animation: bob 3.8s ease-in-out infinite;
  transition: filter 0.25s;
}

.cube-wrap:hover #cube {
  filter: drop-shadow(4px 11px 14px rgba(40, 60, 80, 0.3))
    brightness(1.05) saturate(1.06);
}

[data-theme="dark"] #cube {
  filter: drop-shadow(4px 8px 12px rgba(0, 0, 0, 0.5));
}

[data-theme="dark"] .cube-wrap:hover #cube {
  filter: drop-shadow(4px 11px 16px rgba(0, 0, 0, 0.6)) brightness(1.06);
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-9px) rotate(1.5deg);
  }
}

@keyframes cube-jolt {
  0%,
  100% {
    transform: translate(0, 0);
  }

  22% {
    transform: translate(var(--jolt-x), var(--jolt-y));
  }

  48% {
    transform: translate(
      calc(var(--jolt-x) * -0.5),
      calc(var(--jolt-y) * -0.5)
    );
  }

  70% {
    transform: translate(
      calc(var(--jolt-x) * 0.24),
      calc(var(--jolt-y) * 0.24)
    );
  }
}

.crack-hint {
  margin-top: -10px;
  color: var(--blue);
  font-family: "Patrick Hand", cursive;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
  animation: hint-in 0.6s ease 1.05s both;
}

.crack-hint::before {
  content: "↑ ";
}

@keyframes hint-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

.hero h1 {
  width: min(880px, calc(100vw - 40px));
  margin: 26px 0 14px;
  font-family: "Patrick Hand SC", cursive;
  font-size: clamp(2.6rem, 8.5vw, 4.6rem);
  line-height: 1.08;
  letter-spacing: 0.02em;
  text-wrap: balance;
}

.hero .tag {
  max-width: 480px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
}

section.block {
  padding: 0;
}

#about {
  padding-top: var(--section-edge-spacing);
}

section.block + section.block {
  margin-top: var(--content-section-gap);
}

section.block h2 {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--ink);
  font-family: "Patrick Hand SC", cursive;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-icon {
  width: 1.15em;
  color: var(--blue);
  font-size: 0.72em;
  text-align: center;
}

.gamepad-icon path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 40px;
}

section.block p {
  max-width: 600px;
  color: var(--ink-soft);
}

section.block p + p {
  margin-top: 12px;
}

.games-grid {
  display: grid;
  gap: 16px;
}

.game-card {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 22px;
  background: color-mix(in srgb, var(--paper) 55%, var(--ice));
  border: 2.5px solid var(--ink-soft);
  border-radius: 19px 21px 18px 22px / 21px 18px 22px 19px;
  box-shadow: 5px 7px 0 color-mix(in srgb, var(--ink) 9%, transparent);
  transition:
    transform 0.16s,
    box-shadow 0.16s;
}

.game-card:hover {
  box-shadow: 8px 12px 0 color-mix(in srgb, var(--ink) 12%, transparent);
  transform: translateY(-4px);
}

.game-thumb {
  display: grid;
  flex: none;
  place-items: center;
  width: 92px;
  height: 92px;
  background: linear-gradient(150deg, var(--blue-soft), var(--blue));
  border-radius: 15px 17px 14px 18px / 17px 14px 18px 15px;
  box-shadow: inset 0 -6px 12px rgba(10, 40, 80, 0.25);
}

.game-question {
  color: #fff;
  font-size: 2.8rem;
  filter: drop-shadow(2px 3px 0 rgba(10, 40, 80, 0.3));
}

.game-info h3 {
  margin-bottom: 2px;
  font-family: "Patrick Hand", cursive;
  font-size: 1.32rem;
  letter-spacing: 0.03em;
}

.game-info p {
  font-size: 1.02rem;
}

.mail-button {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  padding: 10px 22px 12px;
  margin-top: 24px;
  color: var(--ink);
  font-size: 1.16rem;
  background: color-mix(in srgb, var(--paper) 45%, var(--ice));
  border: 2.5px solid var(--ink-soft);
  border-radius: 16px 18px 15px 19px / 18px 15px 19px 16px;
  box-shadow: 5px 7px 0 color-mix(in srgb, var(--ink) 9%, transparent);
  transition:
    transform 0.16s,
    box-shadow 0.16s,
    background-color 0.2s;
}

.mail-button svg {
  flex: none;
  width: 22px;
  height: 22px;
}

.mail-button:hover {
  text-decoration: none;
  background: var(--ice);
  transform: translateY(-2px);
  box-shadow: 8px 12px 0 color-mix(in srgb, var(--ink) 12%, transparent);
}

.mail-button:active {
  transform: translateY(4px);
  box-shadow: 1px 1px 0 color-mix(in srgb, var(--ink) 12%, transparent);
}

footer {
  position: relative;
  z-index: 1;
  padding: calc(var(--section-spacing) + var(--section-edge-spacing)) 20px 48px;
  color: var(--ink-soft);
  font-size: 1.02rem;
  text-align: center;
}

.studio-name {
  color: var(--ink-soft);
  font-family: "Patrick Hand", cursive;
  font-size: 1.05rem;
  font-style: normal;
  font-weight: 400;
}

/* 404 page */

.error-page {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  grid-template-rows: auto 1fr auto;
}

.error-main {
  display: grid;
  width: 100%;
  max-width: 760px;
  padding: clamp(42px, 7vw, 72px) clamp(20px, 5vw, 32px);
  place-items: center;
}

.error-content {
  text-align: center;
}

.error-cube {
  display: block;
  width: clamp(150px, 28vw, 220px);
  height: auto;
  margin: 0 auto -18px;
  filter: drop-shadow(4px 8px 9px rgba(40, 60, 80, 0.2));
  animation:
    cube-in 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards,
    error-float 4s ease-in-out 0.7s infinite;
}

[data-theme="dark"] .error-cube {
  filter: drop-shadow(4px 8px 12px rgba(0, 0, 0, 0.5));
}

@keyframes error-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1.5deg);
  }

  50% {
    transform: translateY(-7px) rotate(1deg);
  }
}

.error-code {
  color: var(--blue);
  font-family: "Patrick Hand SC", cursive;
  font-size: clamp(4.8rem, 15vw, 8rem);
  line-height: 0.9;
  letter-spacing: 0.04em;
}

.error-content h1 {
  margin-top: 16px;
  font-family: "Patrick Hand SC", cursive;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0.02em;
  text-wrap: balance;
}

.error-message {
  max-width: 460px;
  margin: 14px auto 0;
  color: var(--ink-soft);
  font-size: clamp(1.1rem, 2.5vw, 1.3rem);
  text-wrap: balance;
}

.error-home {
  margin-top: 28px;
}

.error-page footer {
  padding-top: 20px;
}

/* Turkey window */

#turkey-window {
  position: fixed;
  z-index: 150;
  top: 0;
  left: 0;
  display: none;
  touch-action: none;
  pointer-events: auto;
  will-change: transform;
}

#turkey {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 5px 4px rgba(40, 60, 80, 0.16));
  will-change: transform;
}

[data-theme="dark"] #turkey {
  filter: drop-shadow(2px 5px 6px rgba(0, 0, 0, 0.45));
}

#turkey-window.is-window {
  cursor: move;
  background: linear-gradient(180deg, #fff 0, #f3f2ec 100%);
  border-radius: 8px 8px 4px 4px;
  box-shadow:
    0 0 0 3px #1a56e4,
    0 0 0 4px #0a2fa8,
    6px 13px 26px rgba(8, 28, 90, 0.42);
}

[data-theme="dark"] #turkey-window.is-window {
  background: linear-gradient(180deg, #252831 0, #191c22 100%);
  box-shadow:
    0 0 0 3px #1a56e4,
    0 0 0 4px #0a2fa8,
    6px 13px 26px rgba(0, 0, 0, 0.55);
}

.window-bar {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: none;
  align-items: center;
  height: 28px;
  padding: 0 5px 0 7px;
  gap: 7px;
  cursor: default;
  background: linear-gradient(
    180deg,
    #63a6f8 0,
    #3f8ef5 6%,
    #2168e8 16%,
    #1c5cd8 56%,
    #1a53c8 84%,
    #2b66d8 94%,
    #1747b8 100%
  );
  border-radius: 8px 8px 0 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 10, 60, 0.25);
}

#turkey-window.is-window .window-bar {
  display: flex;
  animation: window-in 0.18s ease-out;
}

@keyframes window-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.window-icon {
  flex: none;
  width: 17px;
  height: 17px;
  background: url("ice/ice0001.webp") center / contain no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 20, 80, 0.5));
}

.window-title {
  flex: 1;
  overflow: hidden;
  color: #fff;
  font-family: Tahoma, Geneva, sans-serif;
  font-size: 12px;
  font-weight: bold;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.window-buttons {
  display: flex;
  flex: none;
  gap: 3px;
}

.window-button {
  position: relative;
  width: 22px;
  height: 20px;
  padding: 0;
  cursor: pointer;
  background: linear-gradient(180deg, #7da9f5 0, #3c74e8 45%, #2258cf 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 3px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.window-button:hover {
  filter: brightness(1.13);
}

.window-button:active {
  filter: brightness(0.9);
}

.minimize-button::after {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 10px;
  height: 3px;
  content: "";
  background: #fff;
  border-radius: 1px;
  transform: translateX(-50%);
}

.maximize-button::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 9px;
  content: "";
  border: 2px solid #fff;
  border-top-width: 3px;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}

#turkey-window.is-maximized .maximize-button::before {
  position: absolute;
  top: 3px;
  left: 8px;
  width: 7px;
  height: 6px;
  content: "";
  border: 1.5px solid #fff;
  border-top-width: 2.5px;
  border-radius: 1px;
}

#turkey-window.is-maximized .maximize-button::after {
  top: 7px;
  left: 3px;
  width: 7px;
  height: 6px;
  background: #2f63dd;
  border-width: 1.5px;
  border-top-width: 2.5px;
  transform: none;
}

.close-button {
  color: #fff;
  font-family: Tahoma, sans-serif;
  font-size: 12px;
  font-weight: bold;
  line-height: 17px;
  text-align: center;
  background: linear-gradient(180deg, #f3938b 0, #e74b3a 46%, #d22a16 100%);
}

.close-button:hover {
  background: linear-gradient(180deg, #f7aaa2 0, #ee5f4e 46%, #e03a25 100%);
  filter: none;
}

.close-button:active {
  background: linear-gradient(180deg, #c8260f 0, #e74b3a 60%, #f3938b 100%);
  filter: none;
}

/* Ice shatter */

#shatter {
  position: fixed;
  z-index: 200;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#shatter img {
  position: absolute;
  top: 0;
  left: 0;
  filter: drop-shadow(1px 2px 1px rgba(30, 45, 60, 0.18));
  will-change: transform, opacity;
}

@media (min-width: 800px) {
  .crack-hint {
    position: absolute;
    top: 50%;
    left: 100%;
    width: 7em;
    margin: 0 0 0 -22px;
    text-align: left;
    text-wrap: balance;
    transform: translateY(-50%);
  }

  .crack-hint::before {
    content: "← ";
  }

  .hero h1 {
    margin-top: -14px;
  }
}

@media (max-width: 560px) {
  #theme-toggle {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  #cube {
    animation: none;
  }

  .cube-wrap,
  .cube-shine,
  .crack-hint,
  .error-cube,
  .game-card {
    animation: none;
  }

  .game-card:hover {
    transform: none;
  }
}
