:root {
  color-scheme: dark;

  --bg-deep: #0c0d0f;
  --glass: rgba(13, 14, 17, 0.78);
  --glass-line: rgba(230, 234, 238, 0.16);
  --glass-line-strong: rgba(230, 234, 238, 0.3);
  --ink: #f2f4f6;
  --ink-soft: #b6bec6;
  --muted: #80878f;
  --accent: #cfd4d9;
  --accent-strong: #9aa2ab;
  --accent-ink: #14161a;
  --accent-soft: rgba(207, 212, 217, 0.14);
  --focus: #dfe3e7;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', 'Segoe UI', system-ui, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.18;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0 0 1.1rem;
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

svg {
  display: block;
}

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body.lang-en-active .text-tr,
body.lang-tr-active .text-en {
  display: none;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transform: translateY(-300%);
  transition: transform 0.15s ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.noscript-note {
  width: min(100% - 2rem, 720px);
  margin: 1rem auto;
  padding: 0.75rem 1rem;
  background: var(--accent-soft);
  border: 1px solid var(--glass-line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* Atmospheric background */
.scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.scene-bg {
  position: absolute;
  inset: 0;
  background-color: var(--bg-deep);
  background-image: url("wallpaper.svg");
  background-size: cover;
  background-position: center;
  transform: scale(1.06);
  will-change: transform;
  animation: scene-drift 45s ease-in-out infinite;
}

@keyframes scene-drift {
  0%,
  100% {
    transform: scale(1.06) translate(0, 0);
  }
  50% {
    transform: scale(1.12) translate(-1.2%, 1.2%);
  }
}

.scene-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(12, 13, 15, 0.14) 0%,
    rgba(12, 13, 15, 0.22) 55%,
    rgba(10, 11, 13, 0.42) 100%
  );
}

.scene-noise {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.scene-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    130% 100% at 50% 35%,
    transparent 55%,
    rgba(0, 0, 0, 0.6) 100%
  );
}

/* Dossier panel */
.panel-wrap {
  --pad: clamp(1rem, 3vw, 2.5rem);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}

.panel {
  position: relative;
  width: min(100%, 1120px);
  height: calc(100vh - 2 * var(--pad));
  height: calc(100dvh - 2 * var(--pad));
  max-height: calc(100vh - 2 * var(--pad));
  max-height: calc(100dvh - 2 * var(--pad));
  display: grid;
  grid-template-columns: clamp(280px, 32%, 370px) 1fr;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow:
    0 40px 90px -24px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  animation: panel-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.rail,
.content {
  min-width: 0;
  min-height: 0;
}

/* Identity rail */
.rail {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  padding: clamp(1.6rem, 3vw, 2.4rem);
  border-right: 1px solid var(--glass-line);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.01)
  );
  overflow: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.rail::-webkit-scrollbar {
  width: 10px;
}

.rail::-webkit-scrollbar-track {
  background: transparent;
}

.rail::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.rail-head {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.monogram {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--glass-line-strong);
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--accent-soft), rgba(255, 255, 255, 0.02));
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.15rem;
  transition: transform 0.28s ease, border-color 0.28s ease;
}

.monogram:hover {
  transform: translateY(-2px) rotate(-3deg);
  border-color: var(--accent);
}

.rail-name {
  font-size: clamp(1.6rem, 2.6vw, 1.95rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.rail-role {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.rail-intro {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.rail-meta {
  margin: 0;
  border-block: 1px solid var(--glass-line);
}

.rail-meta-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.7rem;
}

.rail-meta-item + .rail-meta-item {
  border-top: 1px solid var(--glass-line);
}

.rail-meta-item dt {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.rail-meta-item dd {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.rail-contact {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-top: auto;
}

.email-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: break-word;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  padding-bottom: 0.2rem;
  border-bottom: 2px solid var(--accent-soft);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.email-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.social-link svg {
  width: 1rem;
  height: 1rem;
}

.social-link:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.lang-toggle svg {
  width: 1rem;
  height: 1rem;
  color: var(--accent);
  transition: transform 0.35s ease;
}

.lang-toggle:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.lang-toggle:hover svg {
  transform: rotate(180deg);
}

/* Content column */
.content {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.6rem, 3vw, 2.4rem);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.content::-webkit-scrollbar {
  width: 10px;
}

.content::-webkit-scrollbar-track {
  background: transparent;
}

.content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.panel-nav {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin-bottom: 2.4rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--glass-line);
}

.panel-nav-pill {
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
  z-index: 0;
  will-change: transform, width, height;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel-nav.pill-instant .panel-nav-pill {
  transition: none;
}

.panel-nav [role="tab"] {
  position: relative;
  z-index: 1;
  white-space: nowrap;
  padding: 0.4rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s ease, font-weight 0.15s ease;
}

.panel-nav [role="tab"]:hover {
  color: var(--ink);
}

.panel-nav [role="tab"][aria-selected="true"] {
  color: var(--ink);
  font-weight: 600;
}

.section {
  outline: none;
}

.section[hidden] {
  display: none;
}

.section + .section {
  margin-top: 3rem;
}

@keyframes section-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section--enter {
  animation: section-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section--enter .expertise-group,
.section--enter .project-card,
.section--enter .game-card {
  animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.section--enter .expertise-group:nth-child(1),
.section--enter .project-card:nth-child(1),
.section--enter .game-card:nth-child(1) {
  animation-delay: 0.08s;
}

.section--enter .expertise-group:nth-child(2),
.section--enter .project-card:nth-child(2),
.section--enter .game-card:nth-child(2) {
  animation-delay: 0.14s;
}

.section--enter .expertise-group:nth-child(3),
.section--enter .project-card:nth-child(3),
.section--enter .game-card:nth-child(3) {
  animation-delay: 0.2s;
}

.section--enter .expertise-group:nth-child(4),
.section--enter .game-card:nth-child(4) {
  animation-delay: 0.26s;
}

.section--enter .chips li {
  animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.section--enter .chips li:nth-child(1) {
  animation-delay: 0.06s;
}

.section--enter .chips li:nth-child(2) {
  animation-delay: 0.1s;
}

.section--enter .chips li:nth-child(3) {
  animation-delay: 0.14s;
}

.section--enter .chips li:nth-child(4) {
  animation-delay: 0.18s;
}

.section--enter .chips li:nth-child(5) {
  animation-delay: 0.22s;
}

.section--enter .chips li:nth-child(6) {
  animation-delay: 0.26s;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.8rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow::before {
  content: '';
  width: 1.6rem;
  height: 2px;
  background: var(--accent);
  opacity: 0.9;
}

.section-title {
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  font-weight: 600;
  margin-bottom: 1.1rem;
}

.section .lead,
.section p:not(.section-note) {
  color: var(--ink-soft);
  max-width: 46rem;
  text-wrap: pretty;
}

.sub-heading {
  margin: 2rem 0 1.1rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.expertise-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem 2rem;
}

.expertise-title {
  margin: 0 0 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chips li {
  padding: 0.32rem 0.75rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.chips li:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.section-note {
  margin: 0 0 1.6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.045);
}

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-index {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.project-top::after {
  content: '…';
  color: var(--muted);
  opacity: 0.6;
  letter-spacing: 0.15em;
}

.project-title {
  font-size: 1.12rem;
  font-weight: 600;
}

.project-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--glass-line);
}

.project-meta span {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-card--wide {
  grid-column: 1 / -1;
}

/* Minigames */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.game-card:hover {
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-2px);
}

.game-visual {
  display: grid;
  place-items: center;
  height: 140px;
  padding: 0.75rem;
  border: 1px solid var(--glass-line);
  border-radius: calc(var(--radius-md) - 4px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01));
  overflow: hidden;
}

.game-board {
  width: 100%;
  max-width: 150px;
  height: auto;
  color: var(--accent);
}

.game-board .gb-grid {
  stroke: var(--glass-line-strong);
}

.game-board .gb-snake-body {
  fill: var(--accent-strong);
}

.game-board .gb-snake-head {
  fill: var(--accent);
}

.game-board .gb-food {
  fill: var(--ink-soft);
}

.game-board .gb-chess-frame {
  fill: rgba(255, 255, 255, 0.02);
  stroke: var(--glass-line-strong);
  stroke-width: 1.5;
}

.game-board .gb-chess-sq {
  fill: rgba(255, 255, 255, 0.09);
}

.game-board .gb-chess-sq--alt {
  fill: rgba(0, 0, 0, 0.34);
}

.game-board .gb-chess-glyph {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', 'DejaVu Sans', 'Arial Unicode MS', Georgia, 'Times New Roman', serif;
  font-weight: 400;
  paint-order: stroke fill;
}

.game-board .gb-chess-glyph--knight {
  fill: #0d0f12;
  font-size: 50px;
  stroke: rgba(244, 247, 250, 0.3);
  stroke-width: 1;
}

.game-board .gb-chess-glyph--king {
  fill: #f2f4f6;
  font-size: 32px;
  stroke: rgba(10, 12, 14, 0.4);
  stroke-width: 1;
}

.game-board .gb-cell {
  fill: rgba(255, 255, 255, 0.03);
  stroke: var(--glass-line);
}

.game-board .gb-cell-pos {
  fill: rgba(207, 212, 217, 0.22);
  stroke: var(--accent-strong);
}

.game-board .gb-cell-hit {
  fill: rgba(207, 212, 217, 0.45);
  stroke: var(--accent-strong);
}

.game-board .gb-x {
  stroke: var(--accent);
}

.game-board .gb-o {
  stroke: var(--accent-strong);
}

.game-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.game-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.game-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.game-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.65rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* Responsive */
@media (max-width: 900px) {
  .panel-wrap {
    --pad: clamp(0.75rem, 2vw, 1.5rem);
    display: block;
  }

  .panel {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    overflow: visible;
    border-radius: var(--radius-md);
  }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--glass-line);
    overflow: visible;
  }

  .content {
    overflow: visible;
    overscroll-behavior: auto;
  }

  .rail-contact {
    margin-top: 0;
  }
}

@media (max-width: 620px) {
  .expertise-grid,
  .projects-grid,
  .games-grid {
    grid-template-columns: 1fr;
  }

  .project-card--wide {
    grid-column: auto;
  }

  .panel-nav {
    gap: 0.3rem;
  }

  .panel-nav [role="tab"] {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Bilingual minigame cards are now <button>s */
.game-card {
  width: 100%;
  appearance: none;
  text-align: left;
}

.game-title,
.game-desc {
  display: block;
}

/* ============================ Minigame modal ============================ */
.game-dialog {
  display: none;
  width: min(92vw, 480px);
  max-width: none;
  max-height: min(90vh, 720px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  background: var(--glass);
  color: var(--ink);
  box-shadow:
    0 40px 90px -24px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

.game-dialog[open] {
  display: flex;
  flex-direction: column;
}

.game-dialog::backdrop {
  background: rgba(8, 9, 11, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.game-dialog[open] {
  animation: dialog-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-dialog[open]::backdrop {
  animation: dialog-fade 0.24s ease both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes dialog-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.game-dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 720px);
}

.game-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--glass-line);
}

.game-dialog-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.game-dialog-close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--glass-line);
  border-radius: 50%;
  color: var(--ink-soft);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.game-dialog-close svg {
  width: 1rem;
  height: 1rem;
}

.game-dialog-close:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.05);
  transform: rotate(90deg);
}

.game-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding: 1.25rem;
  overflow-y: auto;
}

/* Fallback when <dialog>.showModal() is unavailable */
.dialog-fallback {
  overflow: hidden;
}

.dialog-fallback .game-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  z-index: 1000;
}

/* ============================ shared game UI ============================ */
.game-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.game-btn {
  min-height: 2.6rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.85rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.game-btn:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}

.game-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.game-btn--primary:hover {
  color: var(--accent-ink);
  background: #e3e7ea;
  border-color: #e3e7ea;
}

.game-status-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.game-status-text--final {
  color: var(--accent);
}

.game-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ============================ Tic-Tac-Toe ============================ */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  width: min(100%, 260px);
  margin: 0 auto;
}

.ttt-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 3.2rem;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.ttt-cell:hover {
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.ttt-cell--fill {
  color: var(--ink);
}

.ttt-cell--win {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================ Snake ============================ */
.snake-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  image-rendering: crisp-edges;
}

.snake-score {
  padding: 0 0.2rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 3.2rem);
  grid-template-rows: repeat(3, 3.2rem);
  gap: 0.4rem;
  margin: 0 auto;
}

.dpad-slot {
  display: grid;
  place-items: center;
}

.dpad-btn {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 2.9rem;
  min-height: 2.9rem;
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  font-size: 1.3rem;
  font-weight: 600;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.dpad-btn:hover {
  color: var(--ink);
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.dpad-btn:active {
  transform: scale(0.94);
}

/* ============================ Wordle ============================ */
.wordle-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(100%, 300px);
  margin: 0 auto;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.wordle-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.wordle-cell--correct {
  background: rgba(207, 212, 217, 0.9);
  border-color: var(--accent);
  color: #14161a;
}

.wordle-cell--present {
  background: rgba(207, 212, 217, 0.45);
  border-color: var(--accent-strong);
  color: var(--ink);
}

.wordle-cell--absent {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--glass-line);
  color: var(--muted);
}

.wordle-kbd {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(100%, 460px);
  margin: 0 auto;
}

.wordle-kbd-row {
  display: flex;
  justify-content: center;
  gap: 0.32rem;
}

.wordle-key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0.3rem 0.2rem;
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wordle-key--wide {
  flex: 1.4 1 0;
  max-width: none;
}

.wordle-key:hover {
  border-color: var(--glass-line-strong);
  background: rgba(255, 255, 255, 0.08);
}

.wordle-key--absent {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.wordle-key--present {
  background: rgba(207, 212, 217, 0.45);
  border-color: var(--accent-strong);
  color: var(--ink);
}

.wordle-key--correct {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ============================ Chess ============================ */
.chess-board {
  display: grid;
  grid-template-columns: 1.4rem repeat(8, minmax(0, 1fr));
  grid-template-rows: 1.4rem repeat(8, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 420px);
  margin: 0 auto;
}

.chess-corner,
.chess-file,
.chess-rank {
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.chess-square {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-size: clamp(1.5rem, 6vw, 2rem);
  line-height: 1;
}

.chess-square--light {
  background-color: #c9cdd3;
}

.chess-square--dark {
  background-color: #2b2f35;
}

.chess-square:hover {
  filter: brightness(1.12);
}

.chess-piece-w {
  color: #fbfdff;
  text-shadow:
    0 0 2px rgba(10, 12, 14, 0.95),
    0 0 6px rgba(10, 12, 14, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.75);
}

.chess-piece-b {
  color: #0b0d10;
  text-shadow:
    0 0 2px rgba(244, 247, 250, 0.95),
    0 0 6px rgba(244, 247, 250, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.45);
}

.chess-square--selected {
  box-shadow: inset 0 0 0 3px #0b0d10, inset 0 0 0 5px #fbfdff;
}

.chess-square--light.chess-square--move {
  background-image: radial-gradient(circle at center, #0b0d10 0 30%, transparent 33%);
}

.chess-square--dark.chess-square--move {
  background-image: radial-gradient(circle at center, #fbfdff 0 30%, transparent 33%);
}

.chess-square--light.chess-square--capture {
  background-image: radial-gradient(circle at center, transparent 0 45%, #0b0d10 47% 58%, transparent 60%);
}

.chess-square--dark.chess-square--capture {
  background-image: radial-gradient(circle at center, transparent 0 45%, #fbfdff 47% 58%, transparent 60%);
}

.chess-square--check {
  box-shadow:
    0 0 0 2px #0b0d10,
    0 0 0 4px #fbfdff,
    inset 0 0 0 2px #0b0d10;
}

.chess-instruction {
  max-width: 34rem;
  margin: 0 auto;
  text-align: center;
  font-weight: 500;
  color: var(--ink-soft);
}

.chess-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 auto;
}

.chess-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chess-legend-pip {
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols', 'DejaVu Sans', 'Arial Unicode MS', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1;
}

.chess-legend-item--w .chess-legend-pip {
  color: #f2f4f6;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.5);
}

.chess-legend-item--b .chess-legend-pip {
  color: #0b0d10;
  text-shadow: 0 0 2px rgba(244, 247, 250, 0.9), 0 0 6px rgba(244, 247, 250, 0.5);
}

.chess-legend-item--turn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

/* ============================ modal responsive ============================ */
@media (max-width: 480px) {
  .game-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .game-dialog-shell {
    height: 100dvh;
    max-height: 100dvh;
  }

  .game-stage {
    flex: 1 1 auto;
  }
}
