:root {
  --ink: #eef2e6;
  --muted: #9aa89a;
  --panel: rgba(10, 16, 20, 0.78);
  --line: rgba(202, 224, 205, 0.18);
  --amber: #f2b84b;
  --danger: #ff5b45;
  --green: #82d78c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "FZLanTingHeiS-DB-GB", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(112, 151, 105, 0.16), transparent 28%),
    radial-gradient(circle at 82% 90%, rgba(171, 80, 42, 0.18), transparent 32%),
    linear-gradient(145deg, #11171b 0%, #0c1013 55%, #151812 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  mix-blend-mode: overlay;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.game-shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 28px) 20px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(160px, 0.7fr);
  align-items: center;
  gap: 24px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(105deg, rgba(14, 21, 23, 0.94), rgba(18, 23, 23, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  color: #12140f;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -2px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f6d577, #c98136);
  box-shadow: 0 8px 22px rgba(235, 162, 64, 0.28);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.brand h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(17px, 2vw, 24px);
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 30px);
}

.stat {
  display: flex;
  min-width: 72px;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 12px;
  border-left: 1px solid var(--line);
}

.stat:first-child {
  border-left: 0;
}

.stat .label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.stat strong {
  color: var(--ink);
  font-size: clamp(16px, 2vw, 22px);
  font-variant-numeric: tabular-nums;
}

.stat-time strong {
  color: var(--green);
}

.hud-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--ink);
  font-size: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  transition: 180ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(242, 184, 75, 0.7);
  background: rgba(242, 184, 75, 0.12);
  outline: none;
}

.canvas-wrap {
  position: relative;
  width: min(100%, 660px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(225, 238, 222, 0.22);
  border-radius: 26px;
  background: #0b0f12;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

#game-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-width: calc((100dvh - 150px) * 9 / 16);
  margin: 0 auto;
  max-height: calc(100dvh - 150px);
  object-fit: contain;
  background: #0b0f12;
  touch-action: manipulation;
}

.skill-dock {
  position: absolute;
  top: 50%;
  left: 14px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  transform: translateY(-50%);
}

.skill-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.skill-button {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  padding: 0;
  place-items: center;
  overflow: hidden;
  color: #e8efe4;
  border: 1px solid rgba(222, 238, 219, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 25%, rgba(255, 255, 255, 0.16), transparent 32%),
    linear-gradient(145deg, #26342e, #101815 72%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 12px 28px rgba(0, 0, 0, 0.46);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.skill-button::after {
  position: absolute;
  inset: 5px;
  content: "";
  border: 1px solid rgba(222, 238, 219, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

.skill-button:hover:not(:disabled),
.skill-button:focus-visible {
  border-color: rgba(242, 184, 75, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 0 5px rgba(242, 184, 75, 0.12),
    0 14px 32px rgba(0, 0, 0, 0.52);
  outline: none;
  transform: scale(1.04);
}

.skill-button:disabled {
  cursor: not-allowed;
  filter: saturate(0.7);
  opacity: 0.72;
}

.skill-button.is-active {
  border-color: #ff6b50;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 0 6px rgba(255, 107, 80, 0.12),
    0 16px 36px rgba(0, 0, 0, 0.55);
}

.skill-icon {
  position: relative;
  z-index: 1;
  width: 45px;
  height: 45px;
  color: #d8e7d7;
  transition: color 160ms ease, transform 160ms ease;
}

.skill-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.skill-button.is-active .skill-icon {
  color: #ff8a70;
  transform: scale(1.08);
}

.skill-button.rewind-button.is-active {
  border-color: #54d6e4;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 6px rgba(84, 214, 228, 0.12),
    0 16px 36px rgba(0, 0, 0, 0.55);
}

.skill-button.rewind-button.is-active .skill-icon {
  color: #79e9f2;
  animation: rewind-pulse 650ms ease-in-out infinite alternate;
}

.skill-button.fold-button.is-active {
  border-color: #e6c86b;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 6px rgba(230, 200, 107, 0.14),
    0 16px 36px rgba(0, 0, 0, 0.55);
}

.skill-button.fold-button.is-active .skill-icon {
  color: #ffe49a;
  animation: fold-pulse 700ms ease-in-out infinite alternate;
}

.skill-cooldown {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: grid;
  height: 0%;
  place-items: center;
  overflow: hidden;
  color: #fff4c9;
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: rgba(5, 10, 11, 0.76);
  border-radius: 0 0 50% 50% / 0 0 50% 50%;
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.skill-label {
  color: #a7b4a6;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(7, 10, 12, 0.2), rgba(7, 10, 12, 0.84)),
    radial-gradient(circle at 50% 45%, transparent, rgba(0, 0, 0, 0.5));
  backdrop-filter: blur(3px);
  transition: opacity 200ms ease;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(650px, 94%);
  padding: clamp(24px, 4vw, 42px);
  text-align: center;
  border: 1px solid rgba(238, 242, 230, 0.18);
  border-radius: 26px;
  background:
    linear-gradient(145deg, rgba(24, 31, 30, 0.96), rgba(10, 15, 17, 0.96)),
    radial-gradient(circle at 50% 0%, rgba(242, 184, 75, 0.12), transparent 45%);
  box-shadow: var(--shadow);
  animation: rise-in 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay-card.compact {
  width: min(420px, 90%);
}

.overlay-card h2 {
  margin: 4px 0 18px;
  font-size: clamp(30px, 6vw, 58px);
  line-height: 1;
  letter-spacing: 0.06em;
}

.lede {
  max-width: 520px;
  margin: 0 auto 22px;
  color: #cfd8ca;
  font-size: 15px;
  line-height: 1.75;
}

.rules {
  display: grid;
  gap: 9px;
  max-width: 540px;
  margin: 0 auto 26px;
  padding: 0;
  color: #b9c3b5;
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
  list-style: none;
}

.rules li {
  padding: 9px 12px;
  border: 1px solid rgba(238, 242, 230, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.rules b {
  color: var(--amber);
}

.overlay-card button {
  min-width: 170px;
  padding: 12px 24px;
  color: #15150f;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7dc87, #e29a42);
  box-shadow: 0 12px 32px rgba(225, 151, 62, 0.26);
  transition: 180ms ease;
}

.overlay-card button:hover,
.overlay-card button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(225, 151, 62, 0.36);
  outline: none;
}

.hint {
  margin: 16px 0 0;
  color: #879489;
  font-size: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 auto 26px;
}

.result-grid div {
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.result-grid span,
.result-grid strong {
  display: block;
}

.result-grid span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.result-grid strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.mobile-controls {
  position: absolute;
  right: 50%;
  bottom: 16px;
  display: none;
  flex-direction: row;
  gap: 12px;
  transform: translateX(50%);
}

.mobile-controls button {
  width: 52px;
  height: 52px;
  color: var(--ink);
  font-size: 22px;
  border: 1px solid rgba(238, 242, 230, 0.25);
  border-radius: 16px;
  background: rgba(10, 15, 17, 0.72);
  backdrop-filter: blur(8px);
}

.mobile-controls button:active {
  background: rgba(242, 184, 75, 0.24);
}

.footer-note {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
  color: #687468;
  font-size: 11px;
  letter-spacing: 0.06em;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rewind-pulse {
  from {
    transform: scale(1) rotate(-8deg);
  }
  to {
    transform: scale(1.12) rotate(8deg);
  }
}

@keyframes fold-pulse {
  from {
    transform: scale(1) rotate(-3deg);
  }
  to {
    transform: scale(1.1) rotate(3deg);
  }
}

@media (max-width: 760px) {
  .game-shell {
    padding: 10px 8px 14px;
  }

  .hud {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 14px;
  }

  .brand {
    grid-column: 1 / -1;
  }

  .stats {
    gap: 2px;
  }

  .stat {
    min-width: 0;
    padding: 3px 7px;
  }

  .stat .label {
    font-size: 9px;
  }

  .stat strong {
    font-size: 16px;
  }

  .hud-actions {
    gap: 5px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  #game-canvas {
    max-width: calc((100dvh - 180px) * 9 / 16);
    max-height: calc(100dvh - 180px);
  }

  .skill-dock {
    left: 8px;
  }

  .skill-button {
    width: 64px;
    height: 64px;
  }

  .skill-icon {
    width: 38px;
    height: 38px;
  }

  .mobile-controls {
    display: flex;
  }

  .footer-note {
    flex-direction: column;
    gap: 4px;
  }

  .overlay {
    padding: 12px;
  }

  .overlay-card {
    padding: 24px 18px;
    border-radius: 20px;
  }

  .overlay-card h2 {
    font-size: 36px;
  }

  .lede,
  .rules {
    font-size: 12px;
  }

  .result-grid strong {
    font-size: 19px;
  }
}

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