:root {
  --ink: #352c38;
  --muted: #877b87;
  --soft-muted: #aea3ac;
  --cream: #fff7ed;
  --paper: #fffdf9;
  --board: #dac9c2;
  --empty: rgba(255, 253, 249, 0.38);
  --coral: #f36b5f;
  --coral-deep: #d95157;
  --lavender: #d9d0e8;
  --gap: clamp(8px, 1.55vw, 14px);
  font-family: "Avenir Next", Avenir, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 7%, rgba(248, 191, 164, 0.23), transparent 24rem),
    radial-gradient(circle at 91% 86%, rgba(200, 191, 227, 0.22), transparent 25rem),
    var(--cream);
}

body.game-2048-page {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
}

.page-shell {
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(36px, 8vw, 88px) 0 30px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: color 160ms ease, transform 160ms ease;
}

.back-link span {
  color: var(--coral-deep);
  font-size: 1rem;
  line-height: 0.8;
  transition: transform 160ms ease;
}

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

.back-link:hover span {
  transform: translateX(-3px);
}

.back-link:focus-visible,
.brand-link:focus-visible,
.game-card:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.35);
  outline-offset: 5px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(430px, 1.18fr);
  align-items: center;
  gap: clamp(48px, 8vw, 120px);
  flex: 1;
}

.intro-panel {
  padding-bottom: clamp(8px, 4vw, 44px);
}

.eyebrow,
.score-label,
.message-kicker,
.page-footer,
.mobile-hint {
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--coral-deep);
  font-size: 0.68rem;
  font-weight: 800;
}

.eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(243, 107, 95, 0.12);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 16px;
  color: var(--ink);
  font-size: clamp(4.5rem, 10vw, 8rem);
  font-weight: 850;
  letter-spacing: -0.09em;
  line-height: 0.85;
}

.title-period {
  color: var(--coral);
}

.tagline {
  margin-top: 27px;
  color: var(--ink);
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.42;
}

.intro-copy {
  max-width: 285px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.85;
}

.game-panel {
  width: min(100%, 520px);
  justify-self: end;
}

.game-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 19px;
}

.score-group {
  display: flex;
  gap: 9px;
}

.score-box {
  position: relative;
  min-width: 92px;
  padding: 10px 16px 9px;
  border: 1px solid rgba(53, 44, 56, 0.06);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: 0 8px 22px rgba(95, 67, 75, 0.06);
  text-align: center;
}

.score-addition {
  position: absolute;
  top: 50%;
  right: -3px;
  color: var(--coral-deep);
  font-size: 0.72rem;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
}

.score-addition.is-visible {
  animation: score-rise 720ms cubic-bezier(0.22, 1, 0.36, 1);
}

.score-box-muted {
  background: rgba(255, 253, 249, 0.53);
  box-shadow: none;
}

.score-label {
  display: block;
  color: var(--soft-muted);
  font-size: 0.55rem;
  font-weight: 800;
}

.score-box strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.27rem;
  font-weight: 800;
  line-height: 1;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 0 17px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.button:hover {
  transform: translateY(-2px);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.35);
  outline-offset: 3px;
}

.button-primary {
  color: #fff;
  background: var(--coral);
  box-shadow: 0 9px 18px rgba(217, 81, 87, 0.22);
}

.button-primary:hover {
  background: var(--coral-deep);
  box-shadow: 0 11px 24px rgba(217, 81, 87, 0.27);
}

.button-primary span {
  margin-left: 9px;
  font-size: 1rem;
  font-weight: 500;
}

.button-quiet {
  color: var(--muted);
  background: #f0e9ec;
}

.button-quiet:hover {
  background: #e8dde1;
}

.game-stage {
  position: relative;
}

.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(10px, 2.2vw, 17px);
  overflow: hidden;
  border-radius: clamp(18px, 3vw, 28px);
  background: var(--board);
  box-shadow: 0 22px 48px rgba(95, 67, 75, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transform: translate3d(0, 0, 0);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 180ms ease;
}

.board-shell.is-dragging {
  transform: translate3d(var(--drag-x, 0), var(--drag-y, 0), 0) scale(0.995);
  transition: transform 45ms linear, box-shadow 180ms ease;
  box-shadow: 0 28px 54px rgba(95, 67, 75, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.board-shell.blocked-up { animation: board-bump-up 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.board-shell.blocked-right { animation: board-bump-right 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.board-shell.blocked-down { animation: board-bump-down 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.board-shell.blocked-left { animation: board-bump-left 300ms cubic-bezier(0.22, 1, 0.36, 1); }
.board-shell.streak-shake-slow { animation: tilt-n-move-shaking 0.25s infinite; }
.board-shell.streak-shake-fast { animation: tilt-n-move-shaking 0.1s infinite; }

.board,
.tile-layer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
  height: 100%;
}

.tile-layer {
  position: absolute;
  inset: clamp(10px, 2.2vw, 17px);
  width: auto;
  height: auto;
  display: block;
}

.cell {
  border-radius: clamp(10px, 2vw, 17px);
  background: var(--empty);
}

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: clamp(10px, 2vw, 17px);
  color: #fff;
  font-size: clamp(1.55rem, 5.1vw, 3.3rem);
  font-weight: 850;
  letter-spacing: -0.07em;
  line-height: 1;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  box-shadow: inset 0 -4px 0 rgba(126, 72, 73, 0.09), 0 6px 12px rgba(95, 67, 75, 0.09);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.tile.is-moving {
  z-index: 2;
  transition: transform 210ms cubic-bezier(0.18, 0.88, 0.32, 1.08);
}

.tile.tile-new {
  animation: tile-spawn 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tile.tile-merged {
  z-index: 3;
  animation: tile-merge 330ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tile[data-value="2"] { color: #574c54; background: #f6e3cf; }
.tile[data-value="4"] { color: #574c54; background: #f4cfb5; }
.tile[data-value="8"] { background: #f3a17e; }
.tile[data-value="16"] { background: #ef806e; }
.tile[data-value="32"] { background: #e96267; }
.tile[data-value="64"] { background: #d94f5b; }
.tile[data-value="128"] { background: #bd72a1; font-size: clamp(1.25rem, 4.2vw, 2.65rem); }
.tile[data-value="256"] { background: #956eb0; font-size: clamp(1.25rem, 4.2vw, 2.65rem); }
.tile[data-value="512"] { background: #725ea6; font-size: clamp(1.25rem, 4.2vw, 2.65rem); }
.tile[data-value="1024"],
.tile[data-value="2048"] { background: #4d4c89; font-size: clamp(1.05rem, 3.8vw, 2.35rem); }

.message {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(253, 245, 239, 0.78);
  backdrop-filter: blur(5px);
  animation: fade-in 180ms ease-out;
  pointer-events: auto;
}

.message[hidden] {
  display: none;
}

.message-card {
  position: relative;
  z-index: 1;
  width: min(100%, 340px);
  padding: 29px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 20px 45px rgba(95, 67, 75, 0.16);
  text-align: center;
}

.message-kicker {
  color: var(--coral-deep);
  font-size: 0.61rem;
  font-weight: 850;
}

.message-card h2 {
  margin-top: 9px;
  color: var(--ink);
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  letter-spacing: -0.05em;
}

.message-card p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.message-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 20px;
}

.mobile-hint {
  margin-top: 13px;
  color: var(--soft-muted);
  font-size: 0.58rem;
  font-weight: 800;
  text-align: center;
}

.mobile-hint span {
  display: inline-block;
  margin-right: 5px;
  color: var(--coral);
  font-size: 0.8rem;
  letter-spacing: 0;
}

.how-to-play {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 23px;
  padding: 13px 16px;
  border-radius: 16px;
  background: rgba(255, 253, 249, 0.57);
}

.how-to-icon {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--coral-deep);
  background: #f9dfd6;
  font-size: 1.1rem;
  font-weight: 700;
}

.how-to-play strong,
.how-to-play span {
  display: block;
}

.how-to-play strong {
  color: var(--ink);
  font-size: 0.74rem;
}

.how-to-play span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.page-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: clamp(34px, 6vw, 70px);
  color: var(--soft-muted);
  font-size: 0.57rem;
  font-weight: 800;
}

.footer-rule {
  width: 44px;
  height: 1px;
  background: #dfd3d0;
}

@keyframes tile-spawn {
  from { opacity: 0; transform: scale(0.55); }
  72% { opacity: 1; transform: scale(1.08); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes tile-merge {
  from { opacity: 0.75; transform: scale(0.75); }
  58% { opacity: 1; transform: scale(1.18); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes score-rise {
  0% { opacity: 0; transform: translate3d(0, 5px, 0) scale(0.8); }
  22% { opacity: 1; transform: translate3d(0, -7px, 0) scale(1.08); }
  100% { opacity: 0; transform: translate3d(0, -25px, 0) scale(1); }
}

@keyframes board-bump-up {
  0%, 100% { transform: translate3d(0, 0, 0); }
  24% { transform: translate3d(0, -7px, 0); }
  45% { transform: translate3d(0, -2px, 0); }
  64% { transform: translate3d(0, -4px, 0); }
}

@keyframes board-bump-right {
  0%, 100% { transform: translate3d(0, 0, 0); }
  24% { transform: translate3d(7px, 0, 0); }
  45% { transform: translate3d(2px, 0, 0); }
  64% { transform: translate3d(4px, 0, 0); }
}

@keyframes board-bump-down {
  0%, 100% { transform: translate3d(0, 0, 0); }
  24% { transform: translate3d(0, 7px, 0); }
  45% { transform: translate3d(0, 2px, 0); }
  64% { transform: translate3d(0, 4px, 0); }
}

@keyframes board-bump-left {
  0%, 100% { transform: translate3d(0, 0, 0); }
  24% { transform: translate3d(-7px, 0, 0); }
  45% { transform: translate3d(-2px, 0, 0); }
  64% { transform: translate3d(-4px, 0, 0); }
}

@keyframes tilt-n-move-shaking {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(5px, 5px) rotate(5deg); }
  50% { transform: translate(0, 0) rotate(0deg); }
  75% { transform: translate(-5px, 5px) rotate(-5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@media (max-width: 800px) {
  .page-shell {
    width: min(560px, calc(100% - 34px));
    padding-top: 35px;
  }

  .game-layout {
    display: block;
  }

  .intro-panel {
    padding-bottom: 39px;
  }

  h1 {
    margin-top: 13px;
    font-size: clamp(4.3rem, 20vw, 7rem);
  }

  .tagline {
    margin-top: 20px;
  }

  .intro-copy {
    max-width: 100%;
    margin-top: 13px;
  }

  .game-panel {
    width: 100%;
  }

  .page-footer {
    margin-top: 45px;
  }
}

@media (max-width: 430px) {
  .page-shell {
    width: calc(100% - 24px);
    padding-top: 26px;
  }

  .intro-panel {
    padding-bottom: 31px;
  }

  .eyebrow {
    font-size: 0.58rem;
  }

  .game-toolbar {
    gap: 9px;
  }

  .score-group {
    gap: 6px;
  }

  .score-box {
    min-width: 74px;
    padding: 9px 10px 8px;
  }

  .button {
    min-height: 40px;
    padding: 0 13px;
    font-size: 0.72rem;
  }

  .message-actions {
    flex-direction: column;
  }

  .message-actions .button {
    width: 100%;
  }
}

@media (max-width: 800px) {
  html:has(.game-2048-page) {
    height: 100%;
    overflow: hidden;
  }

  body.game-2048-page {
    height: 100svh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .game-2048-page .page-shell {
    width: min(560px, calc(100% - 24px));
    height: 100%;
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
    overflow: hidden;
  }

  .game-2048-page .game-layout {
    display: flex;
    min-height: 0;
    flex-direction: column;
    justify-content: center;
    gap: clamp(7px, 1.8vh, 14px);
  }

  .game-2048-page .intro-panel {
    display: flex;
    width: min(100%, 520px);
    align-items: end;
    justify-content: space-between;
    padding: 0;
  }

  .game-2048-page .eyebrow,
  .game-2048-page .intro-copy {
    display: none;
  }

  .game-2048-page h1 {
    margin: 0;
    font-size: clamp(2.7rem, 12vw, 4rem);
    line-height: 0.82;
  }

  .game-2048-page .tagline {
    margin: 0 0 1px;
    font-size: clamp(0.72rem, 3.2vw, 0.94rem);
    line-height: 1.35;
    text-align: right;
  }

  .game-2048-page .game-panel {
    display: flex;
    width: min(100%, calc(100dvh - 190px), 520px);
    min-height: 0;
    flex-direction: column;
    flex: 0 1 auto;
  }

  .game-2048-page .game-toolbar {
    flex: 0 0 auto;
    margin-bottom: clamp(7px, 1.5vh, 12px);
  }

  .game-2048-page .game-stage {
    min-height: 0;
    flex: 0 1 auto;
  }

  .game-2048-page .mobile-hint {
    margin-top: clamp(5px, 1vh, 9px);
  }

  .game-2048-page .how-to-play,
  .game-2048-page .page-footer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .tile.is-moving {
    transition: none !important;
  }
}

/* Game library */
.home-page {
  overflow-x: hidden;
}

.home-shell {
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(27px, 5vw, 54px) 0 30px;
}

.home-nav,
.home-footer,
.section-heading,
.game-card {
  display: flex;
  align-items: center;
}

.home-nav {
  justify-content: space-between;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.17em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  background: var(--coral);
  box-shadow: 0 7px 14px rgba(217, 81, 87, 0.18);
  font-size: 0.9rem;
  letter-spacing: 0;
}

.home-nav-note,
.section-kicker,
.game-card-kicker,
.game-count,
.home-footer {
  color: var(--soft-muted);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-height: clamp(390px, 49vw, 570px);
  padding: clamp(42px, 8vw, 83px) 0 clamp(35px, 6vw, 65px);
}

.home-copy {
  position: relative;
  z-index: 1;
}

.home-heading {
  margin-top: 22px;
  color: var(--ink);
  font-size: clamp(2.75rem, 7.8vw, 6.6rem);
  font-weight: 850;
  letter-spacing: -0.1em;
  line-height: 0.98;
  white-space: nowrap;
}

.home-heading em {
  color: var(--coral);
  font-style: normal;
}

.home-lede {
  max-width: 340px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.9;
}

.mini-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.8vw, 13px);
  width: min(72%, 290px);
  aspect-ratio: 1;
  padding: clamp(10px, 2vw, 15px);
  transform: rotate(-7deg);
  border-radius: clamp(20px, 3vw, 29px);
  background: rgba(218, 201, 194, 0.86);
  box-shadow: 0 28px 40px rgba(95, 67, 75, 0.14);
}

.mini-tile,
.card-tile {
  display: grid;
  place-items: center;
  border-radius: clamp(7px, 1.6vw, 12px);
  color: #fff;
  font-size: clamp(0.8rem, 2.5vw, 1.35rem);
  font-weight: 850;
}

.mini-tile-2,
.card-tile-2 { color: #574c54; background: #f6e3cf; }
.mini-tile-4,
.card-tile-4 { color: #574c54; background: #f4cfb5; }
.mini-tile-8,
.card-tile-8 { background: #f3a17e; }
.mini-tile-16,
.card-tile-16 { background: #ef806e; }
.mini-tile-empty,
.card-tile-0 { background: rgba(255, 253, 249, 0.42); }

.home-art-caption {
  position: absolute;
  right: 2%;
  bottom: 6%;
  z-index: 2;
  color: var(--coral-deep);
  font-size: 0.59rem;
  font-weight: 850;
  letter-spacing: 0.18em;
  line-height: 1.7;
  text-align: right;
}

.games-section {
  padding-top: clamp(17px, 3vw, 33px);
}

.section-heading {
  justify-content: space-between;
  padding-bottom: 17px;
  border-bottom: 1px solid rgba(53, 44, 56, 0.1);
}

.section-heading h2 {
  margin-top: 7px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.game-count {
  align-self: flex-end;
  margin-bottom: 3px;
}

.game-card {
  position: relative;
  gap: clamp(22px, 4vw, 46px);
  min-height: 238px;
  margin-top: 18px;
  padding: clamp(20px, 4vw, 32px);
  overflow: hidden;
  border: 1px solid rgba(53, 44, 56, 0.05);
  border-radius: 24px;
  color: inherit;
  background: rgba(255, 253, 249, 0.76);
  box-shadow: 0 14px 35px rgba(95, 67, 75, 0.07);
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.game-card:hover {
  border-color: rgba(243, 107, 95, 0.22);
  box-shadow: 0 20px 42px rgba(95, 67, 75, 0.12);
  transform: translateY(-4px);
}

.card-tile {
  border-radius: 8px;
  font-size: clamp(0.7rem, 1.5vw, 1rem);
}

.game-card-content {
  position: relative;
  z-index: 1;
  max-width: 430px;
}

.game-card-kicker {
  color: var(--coral-deep);
  font-size: 0.58rem;
}

.game-card h3 {
  margin-top: 10px;
  color: var(--ink);
  font-size: clamp(3rem, 6vw, 4.8rem);
  font-weight: 850;
  letter-spacing: -0.1em;
  line-height: 0.9;
}

.game-card h3 span {
  color: var(--coral);
}

.game-card p {
  max-width: 310px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

.game-card-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 20px;
  color: var(--coral-deep);
  font-size: 0.73rem;
  font-weight: 850;
}

.game-card-link span {
  font-size: 1rem;
  transition: transform 180ms ease;
}

.game-card:hover .game-card-link span {
  transform: translate(3px, -3px);
}

.game-card-index {
  position: absolute;
  top: 25px;
  right: 30px;
  color: rgba(174, 163, 172, 0.62);
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.home-footer {
  gap: 12px;
  margin-top: clamp(38px, 7vw, 74px);
  padding-top: 18px;
  border-top: 1px solid rgba(53, 44, 56, 0.07);
}

@media (min-width: 801px) {
  .games-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px clamp(14px, 2vw, 24px);
  }

  .section-heading {
    grid-column: 1 / -1;
  }

  .game-card {
    align-items: flex-start;
    flex-direction: column;
    min-height: 288px;
    margin-top: 0;
    gap: 0;
    padding: clamp(22px, 2.5vw, 30px);
  }

  .game-card-content {
    max-width: none;
  }

  .game-card h3 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    white-space: nowrap;
  }

  .game-card p {
    max-width: none;
  }
}

@media (max-width: 800px) {
  .home-shell {
    width: min(560px, calc(100% - 34px));
  }

  .home-hero {
    display: block;
    min-height: 0;
    padding-top: 62px;
  }

  .home-lede {
    max-width: 430px;
  }

  .home-art {
    width: min(100%, 390px);
    margin: 30px auto 0;
  }

  .game-card {
    gap: 24px;
  }
}

@media (min-width: 521px) and (max-width: 800px) {
  .games-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .section-heading {
    grid-column: 1 / -1;
  }

  .game-card {
    align-items: flex-start;
    flex-direction: column;
    min-height: 288px;
    margin-top: 0;
    padding: 24px;
  }

  .game-card-content {
    max-width: none;
  }

  .game-card h3 {
    font-size: clamp(2rem, 5vw, 3rem);
    white-space: nowrap;
  }

  .game-card p {
    max-width: none;
  }
}

@media (max-width: 520px) {
  .home-shell {
    width: calc(100% - 24px);
  }

  .home-nav-note {
    font-size: 0.51rem;
    letter-spacing: 0.11em;
  }

  .home-heading {
    margin-top: 17px;
    font-size: clamp(2.35rem, 11.7vw, 5rem);
  }

  .home-hero {
    padding-top: 52px;
  }

  .home-art {
    width: 100%;
    margin-top: 25px;
  }

  .game-card {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    gap: 27px;
    padding: 23px 20px 26px;
  }

  .game-card-index {
    top: 24px;
    right: 22px;
  }

  .home-footer {
    font-size: 0.52rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-card,
  .game-card-link span,
  .back-link,
  .back-link span {
    transition: none !important;
  }
}

/* 1A2B game */
.one-a-two-b-shell {
  padding-top: clamp(30px, 6vw, 70px);
}

.one-a-two-b-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.86fr) minmax(430px, 1.14fr);
  align-items: center;
  gap: clamp(46px, 8vw, 112px);
  flex: 1;
  margin-top: clamp(35px, 5vw, 64px);
}

.one-a-two-b-intro {
  padding-bottom: 0;
}

.one-a-two-b-intro h1 {
  margin-top: 0;
  font-size: clamp(4.4rem, 9vw, 7.3rem);
}

.one-a-two-b-rules-button {
  margin-top: 28px;
}

.one-a-two-b-rules-button span {
  margin-left: 9px;
  color: var(--coral-deep);
  font-size: 1rem;
  font-weight: 500;
}

.one-a-two-b-rules-dialog {
  width: min(calc(100% - 32px), 470px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 24px 70px rgba(95, 67, 75, 0.25);
}

.one-a-two-b-rules-dialog::backdrop {
  background: rgba(53, 44, 56, 0.34);
  backdrop-filter: blur(5px);
}

.rules-dialog-card {
  max-height: calc(100dvh - 32px);
  padding: 28px;
  overflow-y: auto;
}

.rules-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rules-dialog-kicker {
  color: var(--coral-deep);
  font-size: 0.58rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.rules-dialog-close {
  display: grid;
  width: 32px;
  height: 32px;
  margin: -6px -6px 0 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  background: #f0e9ec;
  font-size: 1.4rem;
  line-height: 1;
}

.rules-dialog-close:hover {
  color: var(--ink);
  background: #e8dde1;
}

.rules-dialog-close:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.35);
  outline-offset: 3px;
}

.rules-dialog-card h2 {
  margin-top: 12px;
  color: var(--ink);
  font-size: clamp(1.8rem, 7vw, 2.45rem);
  letter-spacing: -0.06em;
}

.rules-dialog-content {
  display: grid;
  gap: 20px;
  margin-top: 23px;
}

.rules-dialog-content section {
  display: grid;
  gap: 7px;
}

.rules-dialog-content h3 {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.rules-dialog-content p,
.rules-dialog-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.rules-dialog-content strong {
  color: var(--ink);
  font-weight: 850;
}

.rules-dialog-definitions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.rules-dialog-definitions div {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 13px;
  background: rgba(255, 253, 249, 0.55);
}

.rules-dialog-definitions strong {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: var(--coral-deep);
  background: #f9dfd6;
  font-size: 0.76rem;
}

.rules-dialog-definitions div:nth-child(2) strong {
  color: #75649b;
  background: var(--lavender);
}

.rules-dialog-definitions span {
  color: var(--muted);
  font-size: 0.72rem;
}

.rules-dialog-example {
  padding: 13px 14px;
  border-radius: 14px;
  background: #f8eee9;
}

.rules-dialog-note {
  padding-top: 2px;
  color: var(--soft-muted);
  font-size: 0.7rem;
}

.rules-dialog-confirm {
  width: 100%;
  margin-top: 24px;
}

.one-a-two-b-panel {
  width: min(100%, 520px);
  justify-self: end;
  padding: 17px;
  border: 1px solid rgba(53, 44, 56, 0.06);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.75);
  box-shadow: 0 22px 48px rgba(95, 67, 75, 0.1);
}

.round-header,
.record-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.round-header {
  padding: 2px 4px 16px;
}

.round-number-box {
  min-width: 78px;
  padding: 8px 12px 7px;
  border-radius: 13px;
  background: #f9efeb;
  text-align: center;
}

.round-number-box strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
}

.round-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #79b89b;
  box-shadow: 0 0 0 5px rgba(121, 184, 155, 0.12);
}

.guess-area {
  padding: 18px;
  border-radius: 19px;
  background: #f8eee9;
}

.guess-label {
  display: block;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.guess-controls {
  display: flex;
  gap: 9px;
  margin-top: 10px;
}

.guess-input {
  width: 100%;
  min-width: 0;
  height: 43px;
  padding: 0 13px;
  border: 1px solid rgba(53, 44, 56, 0.12);
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.guess-input::placeholder {
  color: #c8b9b7;
  letter-spacing: 0.16em;
}

.guess-input:focus {
  border-color: rgba(243, 107, 95, 0.7);
  box-shadow: 0 0 0 4px rgba(243, 107, 95, 0.12);
}

.guess-input:disabled {
  color: var(--soft-muted);
  background: #f0e7e4;
}

.guess-controls .button {
  flex: 0 0 auto;
}

.guess-controls .button:disabled {
  cursor: default;
  opacity: 0.56;
  transform: none;
}

.guess-status {
  min-height: 19px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.5;
}

.guess-status.is-ready,
.guess-status.is-result {
  color: var(--coral-deep);
}

.guess-status.is-success {
  color: #5b9c79;
  font-weight: 800;
}

.guess-status.is-error {
  color: var(--coral-deep);
  font-weight: 700;
}

.number-pad {
  margin-top: 15px;
}

.number-pad-label {
  display: block;
  color: var(--soft-muted);
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.number-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.number-key {
  min-height: 37px;
  padding: 0;
  border: 1px solid rgba(53, 44, 56, 0.08);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  font-size: 0.88rem;
  font-weight: 850;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.number-key:hover {
  border-color: rgba(243, 107, 95, 0.42);
  background: #fffaf7;
  transform: translateY(-1px);
}

.number-key:active {
  transform: translateY(0);
}

.number-key:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.25);
  outline-offset: 2px;
}

.number-key-clear {
  color: var(--muted);
  background: #f0e9ec;
  font-size: 0.72rem;
}

.number-key:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.next-round-button {
  width: 100%;
  margin-top: 11px;
}

.next-round-button[hidden] {
  display: none;
}

.record-heading {
  margin-top: 23px;
  padding: 0 4px 13px;
  border-bottom: 1px solid rgba(53, 44, 56, 0.09);
}

.record-heading h2 {
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.record-count {
  color: var(--soft-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.record-list {
  max-height: 288px;
  margin: 0;
  padding: 0 4px;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: #d9c7c2 transparent;
  scrollbar-width: thin;
}

.record-item {
  display: grid;
  grid-template-columns: 35px 1fr auto;
  align-items: center;
  gap: 13px;
  min-height: 57px;
  border-bottom: 1px solid rgba(53, 44, 56, 0.07);
}

.record-index {
  color: var(--soft-muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.record-guess {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: 0.17em;
}

.record-result {
  display: inline-flex;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 850;
}

.result-a {
  color: var(--coral-deep);
}

.result-b {
  color: #75649b;
}

.record-empty {
  padding: 34px 8px;
  color: var(--soft-muted);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
}

.record-empty[hidden] {
  display: none;
}

@media (max-width: 800px) {
  .one-a-two-b-layout {
    display: block;
    margin-top: 45px;
  }

  .one-a-two-b-panel {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .one-a-two-b-layout {
    margin-top: 34px;
  }

  .one-a-two-b-intro h1 {
    font-size: clamp(4rem, 20vw, 6rem);
  }

  .one-a-two-b-panel {
    padding: 12px;
    border-radius: 21px;
  }

  .guess-area {
    padding: 15px;
  }

  .rules-dialog-card {
    padding: 23px 19px 19px;
  }

  .rules-dialog-definitions {
    grid-template-columns: 1fr;
  }

  .guess-controls {
    flex-direction: column;
  }

  .guess-controls .button {
    width: 100%;
  }

  .record-item {
    grid-template-columns: 29px 1fr auto;
    gap: 9px;
  }

  .record-guess {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guess-input,
  .number-key {
    transition: none !important;
  }
}

/* Gomoku game */
.gomoku-shell {
  padding-top: clamp(30px, 6vw, 70px);
}

.gomoku-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(470px, 1.22fr);
  align-items: center;
  gap: clamp(44px, 7vw, 100px);
  flex: 1;
  margin-top: clamp(35px, 5vw, 62px);
}

.gomoku-intro {
  padding-bottom: 30px;
}

.gomoku-intro h1 {
  margin-top: 17px;
  font-size: clamp(3.5rem, 7.8vw, 6.5rem);
}

.gomoku-intro .intro-copy {
  max-width: 310px;
}

.gomoku-rule-chips {
  display: grid;
  gap: 9px;
  max-width: 300px;
  margin-top: 29px;
}

.gomoku-rule-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 13px;
  color: var(--muted);
  background: rgba(255, 253, 249, 0.55);
  font-size: 0.72rem;
}

.gomoku-stone-dot {
  display: block;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.stone-dot-black {
  background: #302b34;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.18), 0 4px 8px rgba(48, 43, 52, 0.18);
}

.stone-dot-white {
  border: 1px solid rgba(53, 44, 56, 0.11);
  background: #fffdf9;
  box-shadow: inset 0 -2px 3px rgba(95, 67, 75, 0.07), 0 4px 8px rgba(95, 67, 75, 0.09);
}

.gomoku-panel {
  width: min(100%, 590px);
  justify-self: end;
  padding: 17px;
  border: 1px solid rgba(53, 44, 56, 0.06);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.75);
  box-shadow: 0 22px 48px rgba(95, 67, 75, 0.11);
}

.gomoku-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 10px;
  margin-bottom: 14px;
  padding: 11px;
  border-radius: 16px;
  background: rgba(248, 238, 233, 0.68);
}

.gomoku-computer-settings {
  display: contents;
}

.gomoku-setting {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.gomoku-setting select {
  width: 100%;
  min-height: 35px;
  padding: 0 9px;
  border: 1px solid rgba(53, 44, 56, 0.1);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255, 253, 249, 0.88);
  font: inherit;
  cursor: pointer;
}

.gomoku-toolbar,
.gomoku-toolbar-actions,
.gomoku-board-meta,
.gomoku-how-to {
  display: flex;
  align-items: center;
}

.gomoku-toolbar {
  justify-content: space-between;
  gap: 14px;
  padding: 1px 3px 15px;
}

.gomoku-toolbar-actions {
  gap: 13px;
  flex-wrap: wrap;
}

.gomoku-turn-box {
  min-width: 79px;
  padding: 8px 12px 7px;
  border-radius: 13px;
  background: #f3ece9;
  text-align: center;
}

.gomoku-turn-box strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
}

.gomoku-turn-box strong[data-player="white"] {
  color: #74629b;
}

.gomoku-move-count {
  color: var(--soft-muted);
  font-size: 0.69rem;
  font-weight: 800;
  white-space: nowrap;
}

.gomoku-toolbar-actions .button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.gomoku-status {
  min-height: 21px;
  margin: 0 3px 13px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.gomoku-status.is-black {
  color: var(--ink);
}

.gomoku-status.is-white,
.gomoku-status.is-winner-white {
  color: #74629b;
}

.gomoku-status.is-winner-black {
  color: var(--coral-deep);
}

.gomoku-status.is-draw {
  color: var(--muted);
}

.gomoku-status.is-easter-egg {
  color: #a24d35;
}

.gomoku-board-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(9px, 1.9vw, 14px);
  border-radius: 23px;
  background: #d8ad7f;
  box-shadow: 0 18px 34px rgba(95, 67, 75, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  user-select: none;
}

.gomoku-board-shell.stones-vibrate .gomoku-cell[data-player="black"]::after,
.gomoku-board-shell.stones-vibrate .gomoku-cell[data-player="white"]::after,
.gomoku-board-shell.stones-vibrate .gomoku-move-number {
  animation: gomoku-stones-shake 480ms ease-in-out;
}

.gomoku-board-shell.stones-vibrate .gomoku-cell.is-last-move::before {
  animation: gomoku-star-shake 480ms ease-in-out;
}

.gomoku-board-shell.stones-fallen .gomoku-board {
  pointer-events: none;
}

.gomoku-board-shell.stones-fallen .gomoku-cell[data-player="black"]::after,
.gomoku-board-shell.stones-fallen .gomoku-cell[data-player="white"]::after {
  animation: gomoku-stone-fall 1200ms forwards;
  animation-delay: calc(var(--stone-delay, 0) * 1ms);
}

.gomoku-board-shell.stones-fallen .gomoku-move-number,
.gomoku-board-shell.stones-fallen .gomoku-cell.is-last-move::before {
  animation: gomoku-marker-hide 220ms ease-out forwards;
}

.gomoku-board-shell.stones-restore .gomoku-cell[data-player="black"]::after,
.gomoku-board-shell.stones-restore .gomoku-cell[data-player="white"]::after {
  animation: gomoku-stone-return 720ms backwards;
  animation-delay: calc(var(--stone-delay, 0) * 1ms);
}

.gomoku-board-shell.stones-restore .gomoku-move-number,
.gomoku-board-shell.stones-restore .gomoku-cell.is-last-move::before {
  animation: gomoku-marker-show 320ms ease-out backwards;
  animation-delay: calc(var(--stone-delay, 0) * 1ms);
}

.gomoku-board {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  grid-template-rows: repeat(15, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(89, 58, 39, 0.24);
  border-radius: 9px;
  background: rgba(250, 226, 188, 0.62);
  transition: filter 180ms ease, opacity 220ms ease, transform 220ms ease;
}

.gomoku-cell {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 0;
  border: 0;
  border-right: 1px solid rgba(89, 58, 39, 0.24);
  border-bottom: 1px solid rgba(89, 58, 39, 0.24);
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.gomoku-cell:nth-child(15n) {
  border-right: 0;
}

.gomoku-cell:nth-last-child(-n + 15) {
  border-bottom: 0;
}

.gomoku-cell[data-player="empty"]:hover {
  background: rgba(255, 253, 249, 0.22);
}

.gomoku-cell:focus-visible {
  z-index: 3;
  outline: 3px solid rgba(243, 107, 95, 0.6);
  outline-offset: -3px;
}

.gomoku-cell::after {
  position: absolute;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  content: "";
  opacity: 0;
  transform: scale(0.25);
  transition: opacity 160ms ease, transform 160ms ease;
}

.gomoku-cell[data-player="black"]::after {
  opacity: 1;
  background: #302b34;
  box-shadow: inset 0 3px 4px rgba(255, 255, 255, 0.16), 0 4px 7px rgba(48, 43, 52, 0.25);
  transform: scale(1);
}

.gomoku-cell[data-player="white"]::after {
  opacity: 1;
  border: 1px solid rgba(53, 44, 56, 0.15);
  background: #fffdf9;
  box-shadow: inset 0 -3px 4px rgba(95, 67, 75, 0.07), 0 4px 7px rgba(95, 67, 75, 0.16);
  transform: scale(1);
}

.gomoku-cell.is-winning::after {
  box-shadow: 0 0 0 3px var(--coral), inset 0 3px 4px rgba(255, 255, 255, 0.16), 0 4px 7px rgba(48, 43, 52, 0.22);
  animation: gomoku-winning-flash 250ms ease-in-out 4;
}

.gomoku-cell[data-player="white"].is-winning::after {
  box-shadow: 0 0 0 3px #9a87c2, inset 0 -3px 4px rgba(95, 67, 75, 0.07), 0 4px 7px rgba(95, 67, 75, 0.16);
}

.gomoku-cell.is-last-move::before {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 72%;
  aspect-ratio: 1;
  color: #ffd98a;
  content: "★";
  font-size: clamp(0.78rem, 2.8vw, 1.24rem);
  line-height: 1;
  transform: translate(-50%, -50%) scale(1.08);
  pointer-events: none;
  text-shadow: 0 0 6px rgba(48, 43, 52, 0.52), 0 1px 2px rgba(48, 43, 52, 0.55);
}

.gomoku-cell[data-player="white"].is-last-move::before {
  color: var(--coral-deep);
  text-shadow: 0 0 6px rgba(255, 253, 249, 0.92), 0 1px 2px rgba(95, 67, 75, 0.24);
}

.gomoku-cell[data-player="black"].is-forbidden::after {
  box-shadow: 0 0 0 3px #d95557, 0 0 0 6px rgba(217, 85, 87, 0.18), inset 0 3px 4px rgba(255, 255, 255, 0.16), 0 4px 7px rgba(48, 43, 52, 0.25);
}

@keyframes gomoku-winning-flash {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.35;
    transform: scale(0.78);
  }
}

@keyframes gomoku-stones-shake {
  0%,
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  18% {
    transform: translate(-8%, 1%) rotate(-10deg) scale(1.02);
  }

  38% {
    transform: translate(7%, -2%) rotate(8deg) scale(1.02);
  }

  58% {
    transform: translate(-5%, 1%) rotate(-6deg);
  }

  78% {
    transform: translate(4%, -1%) rotate(4deg);
  }
}

@keyframes gomoku-star-shake {
  0%,
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }

  18% {
    transform: translate(calc(-50% - 8%), calc(-50% + 1%)) rotate(-10deg) scale(1.08);
  }

  38% {
    transform: translate(calc(-50% + 7%), calc(-50% - 2%)) rotate(8deg) scale(1.08);
  }

  58% {
    transform: translate(calc(-50% - 5%), calc(-50% + 1%)) rotate(-6deg) scale(1.08);
  }

  78% {
    transform: translate(calc(-50% + 4%), calc(-50% - 1%)) rotate(4deg) scale(1.08);
  }
}

@keyframes gomoku-stone-fall {
  0% {
    transform: translate(0, 0) rotate(0deg);
    animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
  }

  38% {
    transform: translate(1%, calc(var(--stone-fall, 0) * 1%)) rotate(140deg) scale(1.08, 0.9);
    animation-timing-function: cubic-bezier(0, 0, 0.6, 1);
  }

  46% {
    transform: translate(-1%, calc(var(--stone-fall, 0) * 74%)) rotate(190deg) scale(0.98, 1.02);
    animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
  }

  58% {
    transform: translate(0, calc(var(--stone-fall, 0) * 1%)) rotate(230deg) scale(1.05, 0.93);
    animation-timing-function: cubic-bezier(0, 0, 0.6, 1);
  }

  66% {
    transform: translate(0, calc(var(--stone-fall, 0) * 90%)) rotate(250deg);
    animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
  }

  74% {
    transform: translate(0, calc(var(--stone-fall, 0) * 1%)) rotate(265deg) scale(1.03, 0.97);
    animation-timing-function: cubic-bezier(0, 0, 0.6, 1);
  }

  80% {
    transform: translate(0, calc(var(--stone-fall, 0) * 97%)) rotate(275deg);
    animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
  }

  86%,
  100% {
    transform: translate(0, calc(var(--stone-fall, 0) * 1%)) rotate(280deg) scale(1);
  }
}

@keyframes gomoku-marker-hide {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes gomoku-stone-return {
  0% {
    transform: translate(0, calc(var(--stone-fall, 0) * 1%)) rotate(280deg);
    animation-timing-function: cubic-bezier(0.3, 0, 0.3, 1);
  }

  70% {
    transform: translate(0, calc(var(--stone-fall, 0) * -4%)) rotate(360deg) scale(1.04);
    animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
  }

  85% {
    transform: translate(0, calc(var(--stone-fall, 0) * 1.5%)) rotate(360deg) scale(0.99);
  }

  100% {
    transform: translate(0, 0) rotate(360deg) scale(1);
  }
}

@keyframes gomoku-marker-show {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.gomoku-move-number {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 72%;
  aspect-ratio: 1;
  color: transparent;
  font-size: clamp(0.45rem, 1.8vw, 0.82rem);
  font-weight: 850;
  line-height: 1;
  pointer-events: none;
}

.gomoku-panel.is-finished .gomoku-move-number {
  color: #fffdf9;
}

.gomoku-panel.is-finished .gomoku-cell[data-player="white"] .gomoku-move-number {
  color: #302b34;
}

.gomoku-star {
  position: absolute;
  z-index: 0;
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(89, 58, 39, 0.56);
}

.gomoku-board-meta {
  justify-content: space-between;
  padding: 12px 3px 0;
  color: var(--soft-muted);
  font-size: 0.57rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.gomoku-how-to {
  gap: 12px;
  margin-top: 17px;
  padding: 12px 14px;
  border-radius: 15px;
  background: rgba(248, 238, 233, 0.68);
}

.gomoku-how-to .how-to-icon {
  color: var(--coral-deep);
  background: #f9dfd6;
  font-size: 0.75rem;
}

.gomoku-how-to strong,
.gomoku-how-to span {
  display: block;
}

.gomoku-how-to strong {
  color: var(--ink);
  font-size: 0.74rem;
}

.gomoku-how-to span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

@media (max-width: 800px) {
  .gomoku-layout {
    display: block;
    margin-top: 45px;
  }

  .gomoku-intro {
    padding-bottom: 38px;
  }

  .gomoku-intro .intro-copy {
    max-width: 100%;
  }

  .gomoku-panel {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .gomoku-layout {
    margin-top: 34px;
  }

  .gomoku-intro h1 {
    font-size: clamp(3.2rem, 16vw, 5rem);
  }

  .gomoku-panel {
    padding: 12px;
    border-radius: 21px;
  }

  .gomoku-toolbar {
    gap: 8px;
  }

  .gomoku-toolbar-actions {
    gap: 7px;
  }

  .gomoku-settings {
    grid-template-columns: 1fr 1fr;
  }

  .gomoku-settings > .gomoku-setting:first-child {
    grid-column: 1 / -1;
  }

  .gomoku-toolbar-actions .button {
    padding: 0 12px;
  }

  .gomoku-board-shell {
    padding: 8px;
    border-radius: 19px;
  }

  .gomoku-board-meta {
    font-size: 0.51rem;
  }

  .gomoku-how-to span {
    font-size: 0.64rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gomoku-cell::after {
    transition: none !important;
  }

  .gomoku-cell.is-winning::after {
    animation: none;
  }
}

/* Compact Gomoku layout */
.gomoku-shell {
  width: min(100%, 960px);
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.gomoku-shell > .back-link {
  margin-bottom: clamp(8px, 2vh, 16px);
}

.gomoku-result-cover {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 12, 22, 0.68);
  backdrop-filter: blur(8px);
}

.gomoku-result-dialog {
  box-sizing: border-box;
  width: min(100%, 390px);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  color: #f8fafc;
  background: linear-gradient(145deg, #202b40, #101724);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.gomoku-result-kicker {
  margin: 0 0 9px;
  color: #fda4af;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.gomoku-result-dialog h2 {
  margin: 0;
  color: inherit;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 1.05;
}

.gomoku-result-message {
  margin: 14px 0 24px;
  color: #cbd5e1;
  font-weight: 750;
}

.gomoku-result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.gomoku-panel {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(8px, 1.6vw, 16px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.gomoku-settings {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px;
}

.gomoku-settings:has(#gomoku-computer-settings[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}

.gomoku-computer-settings {
  display: contents;
}

.gomoku-toolbar {
  padding: 1px 0 8px;
}

.gomoku-status {
  margin: 0 0 8px;
}

.gomoku-board-shell {
  width: min(100%, calc(100dvh - 230px), 900px);
  margin: 0 auto;
}

@media (max-width: 430px) {
  .gomoku-shell {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .gomoku-shell > .back-link {
    margin-bottom: 6px;
  }

  .gomoku-panel {
    padding: 0;
  }

  .gomoku-toolbar-actions {
    gap: 6px;
  }

  .gomoku-toolbar-actions .button {
    padding: 0 11px;
  }

  .gomoku-board-shell {
    width: min(100%, calc(100dvh - 142px));
    padding: 6px;
    border-radius: 16px;
  }

  .gomoku-result-actions {
    grid-template-columns: 1fr;
  }
}

/* Knife throw game */
.knife-throw-shell {
  padding-top: clamp(30px, 6vw, 70px);
}

.knife-throw-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.84fr) minmax(470px, 1.16fr);
  align-items: center;
  gap: clamp(42px, 7vw, 100px);
  flex: 1;
  margin-top: clamp(35px, 5vw, 62px);
}

.knife-throw-intro {
  padding-bottom: 30px;
}

.knife-throw-intro h1 {
  margin-top: 17px;
  font-size: clamp(3.5rem, 7.8vw, 6.5rem);
}

.knife-throw-intro .intro-copy {
  max-width: 310px;
}

.knife-throw-rule-chips {
  display: grid;
  gap: 9px;
  max-width: 300px;
  margin-top: 29px;
}

.knife-throw-rule-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 13px;
  background: rgba(255, 253, 249, 0.57);
  color: var(--muted);
  font-size: 0.72rem;
}

.knife-throw-rule-chip strong {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: var(--coral-deep);
  background: #f9dfd6;
  font-size: 0.65rem;
}

.knife-throw-rule-chip:nth-child(2) strong {
  color: #75649b;
  background: var(--lavender);
}

.knife-throw-panel {
  width: min(100%, 560px);
  justify-self: end;
  padding: 17px;
  border: 1px solid rgba(53, 44, 56, 0.06);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.75);
  box-shadow: 0 22px 52px rgba(95, 67, 75, 0.12);
}

.knife-throw-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 1px 3px 14px;
}

.knife-level-box,
.knife-score-box {
  min-width: 70px;
  padding: 8px 11px 7px;
  border-radius: 13px;
  background: #f3ece9;
  text-align: center;
}

.knife-score-box {
  background: #f8eee9;
}

.knife-level-box strong,
.knife-score-box strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.13rem;
  line-height: 1;
}

.knife-restart-button {
  min-height: 38px;
  margin-left: auto;
}

.knife-status {
  min-height: 20px;
  margin: 0 3px 13px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.knife-status.is-ready {
  color: var(--coral-deep);
}

.knife-status.is-success {
  color: #5b9c79;
}

.knife-status.is-fail {
  color: var(--coral-deep);
}

.knife-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 23px;
  cursor: pointer;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 253, 249, 0.28), transparent 35%),
    linear-gradient(135deg, #e7c08e, #c78b5f);
  box-shadow: 0 18px 35px rgba(95, 67, 75, 0.17), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  outline: none;
}

.knife-stage:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.35);
  outline-offset: 4px;
}

.knife-target {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: calc(55% / 3);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  will-change: transform;
}

.knife-target-art {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-image: url("games/knife-throw/assets/target_red1_outline.png"), url("games/knife-throw/assets/target_red1.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100%, 90%;
  filter: drop-shadow(0 10px 7px rgba(95, 67, 75, 0.2));
}

.stuck-knives,
.knife-flying-layer {
  position: absolute;
  inset: 0;
}

.stuck-knives {
  z-index: 2;
}

.knife-flying-layer {
  z-index: 3;
  pointer-events: none;
}

.stuck-knife {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  transform-origin: 50% 50%;
}

.stuck-knife img {
  position: absolute;
  bottom: var(--target-radius);
  left: -9px;
  display: block;
  width: 18px;
  height: 74px;
  object-fit: fill;
  filter: drop-shadow(0 3px 2px rgba(95, 67, 75, 0.3));
}

.stuck-knife.is-collision img {
  filter: drop-shadow(0 0 5px #f36b5f) saturate(1.35);
}

.flying-knife {
  position: absolute;
  z-index: 4;
  width: 22px;
  height: 86px;
  transform: translate(-50%, 0);
}

.flying-knife img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: rotate(180deg);
  filter: drop-shadow(0 3px 2px rgba(95, 67, 75, 0.3));
}

.knife-message {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(253, 245, 239, 0.78);
  backdrop-filter: blur(4px);
  animation: fade-in 180ms ease-out;
}

.knife-message[hidden] {
  display: none;
}

.knife-message-card {
  width: min(100%, 340px);
  padding: 29px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 20px 45px rgba(95, 67, 75, 0.16);
  text-align: center;
}

.knife-message-card h2 {
  margin-top: 9px;
  color: var(--ink);
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  letter-spacing: -0.05em;
}

.knife-message-card p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.knife-message-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 20px;
}

.knife-tray-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-top: 18px;
  padding: 0 3px 7px;
  border-bottom: 1px solid rgba(53, 44, 56, 0.08);
}

.knife-tray-heading strong {
  color: var(--ink);
  font-size: 0.75rem;
}

.knife-tray {
  display: flex;
  gap: 7px;
  min-height: 48px;
  padding: 10px 3px 2px;
}

.knife-tray-item {
  width: 22px;
  height: 38px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.knife-tray-item img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  transform: rotate(180deg);
}

.knife-tray-item.is-used {
  opacity: 0.22;
  transform: translateY(3px);
}

.knife-throw-button {
  width: 100%;
  margin-top: 10px;
}

.knife-throw-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.knife-control-hint {
  margin-top: 10px;
  color: var(--soft-muted);
  font-size: 0.59rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
}

.knife-control-hint span {
  margin-right: 5px;
  color: var(--coral);
}

@media (max-width: 800px) {
  .knife-throw-layout {
    display: block;
    margin-top: 45px;
  }

  .knife-throw-intro {
    padding-bottom: 38px;
  }

  .knife-throw-panel {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .knife-throw-layout {
    margin-top: 34px;
  }

  .knife-throw-intro h1 {
    font-size: clamp(3.1rem, 16vw, 4.7rem);
  }

  .knife-throw-panel {
    padding: 12px;
    border-radius: 21px;
  }

  .knife-stage {
    border-radius: 19px;
  }

  .knife-throw-toolbar {
    gap: 6px;
  }

  .knife-level-box,
  .knife-score-box {
    min-width: 64px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .knife-message-actions {
    flex-direction: column;
  }

  .knife-message-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .knife-target,
  .flying-knife,
  .knife-tray-item {
    transition: none !important;
  }
}

/* SubaraCity game */
.subaracity-shell {
  padding-top: clamp(30px, 6vw, 70px);
}

.subaracity-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(480px, 1.18fr);
  align-items: center;
  gap: clamp(42px, 7vw, 100px);
  flex: 1;
  margin-top: clamp(35px, 5vw, 62px);
}

.subaracity-intro {
  padding-bottom: 30px;
}

.subaracity-intro h1 {
  margin-top: 17px;
  color: var(--ink);
  font-size: clamp(3.7rem, 7vw, 6.2rem);
  letter-spacing: -0.1em;
  line-height: 0.86;
}

.subaracity-intro h1 .title-period {
  color: var(--coral);
}

.subaracity-intro .intro-copy {
  max-width: 315px;
}

.subaracity-rule-chips {
  display: grid;
  gap: 8px;
  max-width: 320px;
  margin-top: 28px;
}

.subaracity-rule-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 13px;
  background: rgba(255, 253, 249, 0.57);
  color: var(--muted);
  font-size: 0.7rem;
}

.subaracity-rule-chip strong {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: var(--coral-deep);
  background: #f9dfd6;
  font-size: 0.63rem;
}

.subaracity-rule-chip:nth-child(2) strong {
  color: #638f7f;
  background: #dcece0;
}

.subaracity-rule-chip:nth-child(3) strong {
  color: #75649b;
  background: var(--lavender);
}

.subaracity-panel {
  width: min(100%, 570px);
  justify-self: end;
  padding: 17px;
  border: 1px solid rgba(53, 44, 56, 0.06);
  border-radius: 26px;
  background: rgba(255, 253, 249, 0.78);
  box-shadow: 0 22px 52px rgba(95, 67, 75, 0.12);
}

.subaracity-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1px 3px 14px;
}

.subaracity-metrics {
  display: flex;
  gap: 7px;
  min-width: 0;
}

.subaracity-stat {
  min-width: 70px;
  padding: 8px 10px 7px;
  border-radius: 13px;
  background: #f3ece9;
  text-align: center;
}

.subaracity-stat.is-population {
  min-width: 102px;
  background: #e9f0e8;
}

.subaracity-stat strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1;
}

.subaracity-restart {
  min-height: 38px;
  margin-left: auto;
}

.subaracity-board-shell {
  position: relative;
  padding: 14px;
  border-radius: 22px;
  background: #d9c6bc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36), 0 13px 28px rgba(95, 67, 75, 0.12);
}

.subaracity-board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 27px;
  margin: 0 2px 10px;
}

.subaracity-status {
  min-width: 0;
  margin: 0;
  color: #85716c;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 1.4;
}

.subaracity-status.is-ready {
  color: var(--coral-deep);
}

.subaracity-status.is-success {
  color: #5d997a;
}

.subaracity-status.is-fail {
  color: var(--coral-deep);
}

.subaracity-best {
  flex: 0 0 auto;
  color: rgba(255, 253, 249, 0.78);
  font-size: 0.56rem;
  font-weight: 850;
  letter-spacing: 0.13em;
}

.subaracity-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  padding: 9px;
  border-radius: 17px;
  background: rgba(130, 102, 94, 0.22);
}

.city-tile {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.city-tile::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 -4px 0 rgba(74, 56, 62, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.38);
  content: "";
  pointer-events: none;
}

.city-tile:hover,
.city-tile:focus-visible {
  z-index: 1;
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 13px rgba(95, 67, 75, 0.16);
  filter: saturate(1.08);
}

.city-tile:focus-visible {
  outline: 3px solid rgba(243, 107, 95, 0.45);
  outline-offset: 2px;
}

.city-tile img {
  position: relative;
  z-index: 1;
  display: block;
  width: 84%;
  height: 84%;
  object-fit: contain;
  filter: drop-shadow(0 4px 2px rgba(95, 67, 75, 0.2));
  pointer-events: none;
  user-select: none;
}

.city-tile-level {
  position: absolute;
  right: 5px;
  bottom: 4px;
  z-index: 2;
  min-width: 19px;
  padding: 2px 3px;
  border-radius: 6px;
  color: rgba(53, 44, 56, 0.67);
  background: rgba(255, 253, 249, 0.74);
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.city-tile.is-lime { background: #dce7a7; }
.city-tile.is-green { background: #c6dfcd; }
.city-tile.is-brown { background: #e5c7ae; }
.city-tile.is-gray { background: #d5d9df; }
.city-tile.is-white { background: #f5f2e9; }

.city-tile.is-white-building img {
  filter: grayscale(1) brightness(1.32) drop-shadow(0 4px 2px rgba(95, 67, 75, 0.2));
}

.city-tile.is-empty {
  cursor: default;
  border: 1px dashed rgba(255, 253, 249, 0.28);
  background: rgba(91, 68, 73, 0.08);
  box-shadow: inset 0 0 0 1px rgba(91, 68, 73, 0.05);
}

.city-tile.is-empty::after {
  box-shadow: none;
}

.subaracity-board.is-animating .city-tile {
  pointer-events: none;
}

.city-tile.is-merging {
  z-index: 3;
  animation: subaracity-merge-tile 260ms cubic-bezier(0.22, 0.78, 0.28, 1) forwards;
}

.city-tile.is-merge-anchor {
  z-index: 4;
  animation: subaracity-merge-anchor 260ms cubic-bezier(0.22, 0.78, 0.28, 1) forwards;
}

.city-tile.is-falling {
  z-index: 3;
  animation: subaracity-fall 155ms cubic-bezier(0.2, 0.78, 0.28, 1) both;
  animation-delay: calc(var(--fall-steps) * 9ms);
}

@keyframes subaracity-merge-tile {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }

  68% {
    opacity: 0.9;
    transform: translate(var(--merge-x), var(--merge-y)) scale(0.72);
  }

  100% {
    opacity: 0;
    transform: translate(var(--merge-x), var(--merge-y)) scale(0.3);
  }
}

@keyframes subaracity-merge-anchor {
  0%, 100% {
    transform: scale(1);
  }

  52% {
    box-shadow: 0 0 0 7px rgba(255, 253, 249, 0.3), 0 10px 19px rgba(95, 67, 75, 0.2);
    transform: scale(1.14);
  }
}

@keyframes subaracity-fall {
  0% {
    opacity: 0.18;
    transform: translateY(calc(var(--fall-steps) * -100%)) scale(0.9);
  }

  72% {
    opacity: 1;
    transform: translateY(5%) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.subaracity-board.is-mayor-mode .city-tile {
  cursor: crosshair;
}

.subaracity-board.is-mayor-mode .city-tile:hover {
  background: #f2aaa0;
  filter: saturate(1.15);
}

.subaracity-gameover {
  position: absolute;
  inset: 14px;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 18px;
  background: rgba(253, 245, 239, 0.8);
  backdrop-filter: blur(5px);
  animation: fade-in 180ms ease-out;
}

.subaracity-gameover[hidden] {
  display: none;
}

.subaracity-gameover-card {
  width: min(100%, 325px);
  padding: 26px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 21px;
  background: var(--paper);
  box-shadow: 0 20px 45px rgba(95, 67, 75, 0.16);
  text-align: center;
}

.subaracity-gameover-card h2 {
  margin-top: 9px;
  color: var(--ink);
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  letter-spacing: -0.05em;
}

.subaracity-gameover-card p {
  margin: 9px 0 19px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.subaracity-actions {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 3px 0;
}

.subaracity-mayor-copy span,
.subaracity-mayor-copy strong {
  display: block;
}

.subaracity-mayor-copy strong {
  max-width: 260px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

.subaracity-mayor-button {
  min-height: 40px;
  white-space: nowrap;
}

.subaracity-mayor-button span {
  margin-left: 5px;
  color: var(--coral-deep);
}

.subaracity-mayor-button.is-active {
  color: #fff;
  background: var(--coral-deep);
  box-shadow: 0 9px 18px rgba(217, 81, 87, 0.2);
}

.subaracity-mayor-button.is-active span {
  color: #fff;
}

.subaracity-mayor-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.subaracity-control-hint {
  margin: 11px 3px 0;
  color: var(--soft-muted);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
}

.subaracity-control-hint span {
  margin-right: 5px;
  color: var(--coral);
}

@media (max-width: 800px) {
  .subaracity-layout {
    display: block;
    margin-top: 45px;
  }

  .subaracity-intro {
    padding-bottom: 38px;
  }

  .subaracity-panel {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .subaracity-layout {
    margin-top: 34px;
  }

  .subaracity-intro h1 {
    font-size: clamp(3.3rem, 17vw, 4.8rem);
  }

  .subaracity-panel {
    padding: 12px;
    border-radius: 21px;
  }

  .subaracity-toolbar {
    gap: 6px;
  }

  .subaracity-metrics {
    gap: 4px;
  }

  .subaracity-stat {
    min-width: 53px;
    padding: 8px 5px 7px;
  }

  .subaracity-stat.is-population {
    min-width: 77px;
  }

  .subaracity-stat strong {
    font-size: 0.87rem;
  }

  .subaracity-board-shell {
    padding: 9px;
    border-radius: 18px;
  }

  .subaracity-board {
    gap: 4px;
    padding: 6px;
    border-radius: 14px;
  }

  .city-tile {
    padding: 2px;
    border-radius: 8px;
  }

  .city-tile-level {
    right: 2px;
    bottom: 2px;
    min-width: 15px;
    padding: 1px 2px;
    font-size: 0.39rem;
  }

  .subaracity-actions {
    align-items: center;
  }

  .subaracity-mayor-copy strong {
    max-width: 175px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .city-tile {
    transition: none !important;
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
}
