/* Motion follows the action: anticipation, contact, then a readable result. */
:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 1.5, 0.45, 1);
}
button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #63d4cb;
  outline-offset: 3px;
}
.table-surface button,
.pet-action,
.pet-scenes button,
.solid-button,
.outline-button,
.direction-key,
.touch-action {
  transition:
    transform 130ms var(--ease-out),
    background-color 160ms,
    box-shadow 160ms;
}
.table-surface button:active:not(:disabled),
.pet-action:active:not(:disabled),
.solid-button:active,
.outline-button:active {
  transform: scale(0.97);
}
.direction-key.pressed,
.touch-action.pressed {
  transform: translateY(2px) scale(0.94);
  box-shadow:
    inset 0 2px 10px #071f4550,
    0 0 0 3px #c5fff24d;
}
.control-mode {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: calc(174px + env(safe-area-inset-bottom));
  z-index: 7;
  pointer-events: auto;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid #cef4e566;
  border-radius: 18px;
  background: #153d43ee;
  color: #f1ffe9;
  font:
    600 11px "Arcade Sans",
    system-ui,
    sans-serif;
  box-shadow: 0 4px 12px #071d342b;
}
#play-screen[data-game="bomber"] .joystick {
  border: 0;
  background: transparent;
}
#play-screen .joystick .knob {
  transition: none;
}
#play-screen .stick-base {
  background: radial-gradient(circle, #4b829179 27%, #0f354bbd 28%);
  border-color: #b9e9e98c;
  box-shadow:
    inset 0 0 0 11px #acdce612,
    0 5px 18px #0d273d3d;
}
#play-screen .joystick.active .stick-base {
  border-color: #d1fff3;
  box-shadow:
    inset 0 0 0 11px #bafdea26,
    0 0 20px #99f2d51f;
}
.four-way .direction-key {
  background: linear-gradient(150deg, #386d78f2, #1a414fee);
  border: 1px solid #c4f4e873;
  box-shadow: 0 4px 0 #0b2b38ad;
  border-radius: 16px;
  touch-action: none;
}
.four-way .direction-key.pressed {
  background: #87d6ba;
  color: #153b39;
}

#play-screen .city-center {
  position: relative;
  gap: 10px;
  background-image:
    linear-gradient(#103c3829, #153f475e), url("./assets/scenes/tycoon.webp");
}
#play-screen .city-center .dice-stage {
  --die-size: clamp(40px, 8cqw, 74px);
  position: relative;
  isolation: isolate;
  padding: 6px 20px 8px;
  margin: 0;
  animation: none;
}
.dice-stage::before {
  content: "";
  position: absolute;
  inset: 17% 0 13%;
  z-index: -1;
  background: radial-gradient(ellipse at 50% 20%, #285e59e6, #0e343bd9);
  border: 1px solid #f9d58b80;
  border-radius: 50%;
  box-shadow:
    0 12px 22px #06323344,
    inset 0 0 0 5px #fbe3a814;
  transform: scaleY(0.82);
}
#play-screen .city-center .dice-faces {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--die-size) * 1.72);
  gap: calc(var(--die-size) * 0.52);
  padding: 18px 16px 0;
  overflow: visible;
}
.die {
  position: relative;
  display: block;
  width: var(--die-size);
  height: var(--die-size);
}
.die-shadow {
  position: absolute;
  left: -5%;
  top: 93%;
  width: 110%;
  height: 22%;
  border-radius: 50%;
  background: #041d1f;
  filter: blur(3px);
}
#play-screen .city-center .die-face {
  position: relative;
  display: block;
  width: var(--die-size);
  height: var(--die-size);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  transform: none;
}
.rolling .die-face {
  will-change: transform;
}
.die-side {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 15%;
  gap: 6%;
  border: 1px solid #d7d1b6;
  border-radius: calc(var(--die-size) * 0.07);
  background: linear-gradient(140deg, #fffef7, #f2e9d1 70%, #d3c7a9);
  box-shadow:
    inset 0 0 0 2px #fffbed,
    inset 0 -3px 8px #907a4530;
  transform-origin: 0 0;
  visibility: hidden;
}
#play-screen .city-center .die-side :is(.die-pip, .cube-pip) {
  display: block;
  place-self: center;
  width: 75%;
  height: 75%;
  border-radius: 50%;
  background: #244542;
  box-shadow:
    inset 0 2px 2px #081c28a6,
    0 1px 1px #fff;
}
#play-screen .city-center .die-side-1 :is(.die-pip, .cube-pip) {
  width: 94%;
  height: 94%;
  background: #cf644c;
}
.die-unknown {
  font-size: calc(var(--die-size) * 0.5);
  color: #cf9451;
}
#play-screen .city-center .dice-caption {
  position: relative;
  margin-top: 12px;
  padding: 6px 13px;
  background: #123c43ed;
  border: 1px solid #dfd6a640;
  border-radius: 20px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.rolling .dice-caption {
  color: #fff1b4;
}
.city-moment {
  display: flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: 90%;
  padding: 8px 18px 8px 9px;
  border: 1px solid #f8dda77d;
  border-radius: 16px;
  background: linear-gradient(115deg, #fff5da, #e6eacf);
  box-shadow: 0 9px 24px #103c4a36;
  color: #254c45;
  text-align: left;
  pointer-events: none;
  animation: city-moment 2.7s both;
  animation-delay: var(--moment-age, 0s);
}
.city-moment .moment-image {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.city-moment small {
  display: block;
  margin: 0 0 3px;
  color: #648173;
  font-size: 10px;
}
.city-moment strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}
.moment-expense,
.moment-rent {
  background: linear-gradient(115deg, #ffecdb, #ecd0c6);
}
.moment-card .moment-image {
  transform: rotate(-9deg);
}
.moment-reward .moment-image {
  animation: reward-hop 0.65s var(--ease-spring) both;
  animation-delay: var(--moment-age);
}
@keyframes city-moment {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
  15%,
  86% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}
@keyframes reward-hop {
  0% {
    transform: translateY(12px) scale(0.6) rotate(-12deg);
  }
  60% {
    transform: translateY(-4px) scale(1.12) rotate(5deg);
  }
  100% {
    transform: none;
  }
}
.city-tile.route-tile {
  box-shadow: inset 0 0 0 2px #ffeaab;
}
.route-step {
  position: absolute;
  z-index: 8;
  right: 1px;
  top: 25%;
  display: grid;
  place-items: center;
  width: clamp(15px, 2.3cqw, 22px);
  height: clamp(15px, 2.3cqw, 22px);
  border-radius: 50%;
  background: #1b675f;
  color: #fff8d8;
  font-size: clamp(8px, 1.25cqw, 12px);
  box-shadow: 0 2px 4px #12393466;
}
.tile-moment .building {
  animation: building-rise 0.65s var(--ease-spring) both;
  animation-delay: var(--moment-age);
  transform-origin: center bottom;
}
@keyframes building-rise {
  from {
    transform: translateY(8px) scale(0.6);
    filter: brightness(1.7);
  }
  to {
    transform: none;
    filter: brightness(1);
  }
}
.tile-moment::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 3px solid #fff0ab;
  border-radius: inherit;
  pointer-events: none;
  animation: tile-contact 0.85s ease-out both;
  animation-delay: var(--moment-age);
}
@keyframes tile-contact {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 1px #ffe6a0;
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 9px #ffe6a000;
  }
}
.traveler.is-ferry {
  background: none;
  width: 9%;
}
.traveler.is-ferry svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 5px 2px #12374655);
}
.traveler.is-driving {
  background: none;
  width: 8%;
  aspect-ratio: 1;
}
.traveler .travel-vehicle {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.wallet-strip > span {
  position: relative;
}
.wallet-strip b {
  font-variant-numeric: tabular-nums;
}
.wallet-delta {
  position: absolute;
  right: 0;
  bottom: -9px;
  z-index: 15;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  color: #aef6c3;
  text-shadow: 0 2px 3px #153536;
  pointer-events: none;
  animation: money-float 1.1s var(--ease-out) forwards;
}
.wallet-delta.negative {
  color: #ffc0a6;
}
@keyframes money-float {
  from {
    transform: translateY(9px);
    opacity: 1;
  }
  to {
    transform: translateY(-27px);
    opacity: 0;
  }
}
.city-sheet {
  animation: sheet-in 0.26s var(--ease-out);
}
.city-turn-preview {
  display: none;
}
@media (orientation: landscape) and (min-height: 650px) {
  .city-turn-action {
    align-self: stretch;
    display: flex;
    flex-direction: column;
  }
  .city-turn-action .turn-primary {
    height: auto;
    flex: 0 0 auto;
    padding: 12px 8px;
  }
  .city-turn-preview {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 14px 10px;
  }
  .turn-portrait {
    display: grid;
    justify-items: center;
    color: #ecf4d8;
  }
  .turn-portrait img {
    width: clamp(70px, 8vw, 112px);
    height: clamp(85px, 10vw, 132px);
    object-fit: contain;
    filter: drop-shadow(0 9px 6px #0e2f4380);
  }
  .turn-portrait span {
    color: #9fc6bf;
    font-size: 10px;
    letter-spacing: 0.15em;
    margin-top: 8px;
  }
  .turn-portrait strong {
    font-size: 23px;
    margin: 3px 0;
  }
  .turn-portrait small {
    color: #bfd8c8;
    font-size: 11px;
  }
  .turn-order {
    display: grid;
    gap: 3px;
  }
  .turn-order > div {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 9px;
    color: #b9d2c7;
    font-size: 11px;
  }
  .turn-order > div.current {
    background: #375d54;
    color: #ffedb5;
    box-shadow: inset 2px 0 #eed185;
  }
  .turn-order .bankrupt {
    opacity: 0.4;
  }
  .turn-order i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
  }
  .turn-order b {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
  }
  .city-turn-preview .turn-tip {
    color: #9dbbb3;
    font-size: 11px;
    line-height: 1.7;
    text-align: center;
    margin: 0;
  }
  .city-turn-action[data-decision="true"] .turn-portrait {
    display: none;
  }
  .city-turn-action[data-decision="true"] .turn-tip {
    display: none;
  }
}
@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.board-cell.check .chess-piece {
  box-shadow:
    0 0 0 4px #d253474d,
    0 0 20px #c3504633;
}
.board-cell.legal .chess-piece {
  outline: 3px solid #79ba81;
  outline-offset: 2px;
}
.board-cell.last-origin::after {
  content: "";
  width: 18%;
  height: 18%;
  position: absolute;
  border-radius: 50%;
  border: 2px solid #a67d49;
}
.board-cell.check::after {
  content: "将军";
  position: absolute;
  bottom: -5px;
  z-index: 5;
  background: #ac463a;
  color: #fff7df;
  padding: 2px 5px;
  border-radius: 8px;
  font-size: 10px;
}
.chess-board {
  isolation: isolate;
}
.chess-piece,
.stone {
  transform-origin: center;
}
.capture-ghost {
  position: absolute;
  inset: 7%;
  z-index: 8;
  pointer-events: none;
}
.capture-ghost > * {
  width: 100%;
  height: 100%;
}
.board-win-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}
.board-win-line line {
  stroke: #dc9944;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: win-line 0.55s 0.15s var(--ease-out) forwards;
}
@keyframes win-line {
  to {
    stroke-dashoffset: 0;
  }
}
.weapon-performance {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  padding: 9px 12px;
  margin: 10px 0;
  border-radius: 10px;
  background: #eef2e4;
  color: #526852;
  font-size: 11px;
}
.weapon-performance strong {
  color: #274b3e;
}
.equipment .weapon-slot {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #b2e4bf3d;
}
.weapon-slot .weapon-ready {
  position: absolute;
  inset: auto 3px 0;
  height: 2px;
  background: #b4f6b7;
  transform-origin: left;
}
.weapon-slot.is-firing {
  background: #d4f8b829;
}
.weapon-slot small {
  position: absolute;
  right: 0;
  top: -3px;
  color: #ffe49b;
  font-size: 8px;
}

dialog[open] {
  animation: dialog-in 0.25s var(--ease-out);
}
dialog[open]::backdrop {
  animation: backdrop-in 0.2s ease-out;
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes backdrop-in {
  from {
    background-color: transparent;
  }
}
.result-stars .lit {
  animation: reward-hop 0.6s var(--ease-spring) both;
}
.result-stars .lit:nth-child(1) {
  animation-delay: 0.18s;
}
.result-stars .lit:nth-child(2) {
  animation-delay: 0.36s;
}
.result-stars .lit:nth-child(3) {
  animation-delay: 0.54s;
}
.result-score strong {
  display: inline-block;
  animation: score-in 0.6s 0.2s var(--ease-out) both;
  font-variant-numeric: tabular-nums;
}
@keyframes score-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.game-card {
  transition:
    transform 0.22s var(--ease-out),
    box-shadow 0.22s ease-out;
}
.play-screen[data-phase="paused"] *,
.play-screen[data-phase="paused"] *::before,
.play-screen[data-phase="paused"] *::after {
  animation-play-state: paused !important;
}
@media (hover: hover) {
  .game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 32px #294f681c;
  }
  .game-card:hover .game-card-cover img {
    transform: scale(1.04);
  }
}
@media (orientation: landscape) {
  .control-mode {
    bottom: calc(148px + env(safe-area-inset-bottom));
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .control-mode {
    bottom: calc(121px + env(safe-area-inset-bottom));
    min-height: 32px;
    font-size: 10px;
  }
  #play-screen .city-center {
    gap: 4px;
  }
  #play-screen .city-center .dice-stage {
    --die-size: 32px;
    padding: 0 12px;
  }
  #play-screen .city-center .dice-faces {
    padding-top: 8px;
    height: 57px;
  }
  #play-screen .city-center .dice-caption {
    font-size: 10px;
    padding: 3px 8px;
    margin-top: 4px;
  }
  .city-moment {
    position: absolute;
    left: 50%;
    top: 5px;
    transform: translateX(-50%);
    padding: 4px 10px;
    max-width: 90%;
    animation-name: city-moment-compact;
  }
  .city-moment .moment-image {
    width: 26px;
    height: 26px;
  }
  .city-moment small {
    display: none;
  }
  .city-moment strong {
    font-size: 11px;
  }
  .city-center:has(.city-moment) .dice-stage {
    margin-top: 32px;
  }
  @keyframes city-moment-compact {
    0% {
      opacity: 0;
      transform: translate(-50%, 8px);
    }
    15%,
    86% {
      opacity: 1;
      transform: translate(-50%, 0);
    }
    100% {
      opacity: 0;
      transform: translate(-50%, -5px);
    }
  }
}
@media (max-width: 550px) {
  .city-moment {
    padding: 5px 12px 5px 7px;
  }
  .city-moment .moment-image {
    width: 36px;
    height: 36px;
  }
  .city-moment strong {
    font-size: 12px;
  }
  .city-moment small {
    font-size: 9px;
  }
}
[data-motion="reduced"] *,
[data-motion="reduced"] *::before,
[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0s !important;
  transition-duration: 0.001ms !important;
}
[data-motion="reduced"] .city-moment {
  opacity: 1;
  animation: none !important;
}
[data-motion="reduced"] .wallet-delta,
[data-motion="reduced"] .tile-moment::after {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.001ms !important;
  }
  .city-moment {
    opacity: 1;
    animation: none !important;
  }
  .wallet-delta,
  .tile-moment::after {
    display: none;
  }
}
