/* ==========================================================================
   抓娃娃页样式（game-dev 作用域）
   依赖 css/theme.css 的设计 token；页面级一次性加载，无动态注入。
   ========================================================================== */

.game-page {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(130% 55% at 50% -4%, rgba(139, 108, 255, 0.2), transparent 62%),
    radial-gradient(80% 46% at 102% 104%, rgba(255, 93, 143, 0.14), transparent 62%),
    radial-gradient(60% 40% at 0% 92%, rgba(92, 242, 197, 0.07), transparent 60%),
    linear-gradient(180deg, #0d0a17 0%, #100c1c 46%, #0a0810 100%);
}

/* -------------------------------- 顶部栏 -------------------------------- */

.game-top {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
}

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

.game-brand__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  background: linear-gradient(145deg, #ff7ba6, #e03b6f 58%, #8b6cff);
  box-shadow: 0 8px 20px rgba(224, 59, 111, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.game-brand__text {
  min-width: 0;
  line-height: 1.12;
}

.game-brand__text b {
  display: block;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.game-brand__text span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.26em;
  white-space: nowrap;
}

.game-top__right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.game-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, color 0.2s ease;
}

.game-chip:active {
  background: rgba(255, 255, 255, 0.1);
}

.game-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(92, 242, 197, 0.9);
}

.game-coin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px 0 8px;
  border-radius: 999px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid rgba(255, 209, 102, 0.26);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.game-coin .coin-dot {
  width: 15px;
  height: 15px;
}

.game-coin.is-empty {
  opacity: 0.6;
  filter: saturate(0.5);
}

.game-coin.is-bump {
  animation: game-coin-bump 0.55s var(--ease);
}

@keyframes game-coin-bump {
  0% { transform: scale(1); }
  32% { transform: scale(1.14); border-color: rgba(255, 209, 102, 0.9); }
  100% { transform: scale(1); }
}

.game-icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 15px;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, opacity 0.2s ease;
}

.game-icon-btn:active {
  background: rgba(255, 255, 255, 0.11);
}

.game-icon-btn.is-muted {
  opacity: 0.62;
}

/* -------------------------------- 3D 舞台 -------------------------------- */

.game-stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  margin: 2px 10px 0;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(120% 78% at 50% 8%, rgba(64, 45, 118, 0.85) 0%, rgba(29, 21, 51, 0.9) 42%, rgba(12, 8, 22, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 0 60px rgba(8, 5, 16, 0.65),
    0 18px 44px rgba(0, 0, 0, 0.3);
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.game-stage__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 74% at 50% 16%, transparent 42%, rgba(7, 4, 13, 0.6) 100%),
    linear-gradient(180deg, rgba(10, 7, 18, 0.35) 0%, transparent 22%, transparent 76%, rgba(10, 7, 18, 0.55) 100%);
}

.game-status {
  position: absolute;
  left: 50%;
  bottom: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100% - 26px);
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  background: rgba(14, 10, 24, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.game-status__dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(92, 242, 197, 0.9);
}

.game-status[data-tone="busy"] {
  color: #ffd0dd;
  border-color: rgba(255, 93, 143, 0.32);
}

.game-status[data-tone="busy"] .game-status__dot {
  background: var(--coral);
  box-shadow: 0 0 9px rgba(255, 93, 143, 0.95);
  animation: game-dot-pulse 1s ease-in-out infinite;
}

.game-status[data-tone="warn"] {
  color: #ffe3a3;
  border-color: rgba(255, 209, 102, 0.32);
}

.game-status[data-tone="warn"] .game-status__dot {
  background: var(--gold);
  box-shadow: 0 0 9px rgba(255, 209, 102, 0.9);
}

.game-status[data-tone="good"] {
  color: #b8ffe6;
  border-color: rgba(92, 242, 197, 0.34);
}

.game-status[data-tone="good"] .game-status__dot {
  background: var(--mint);
  box-shadow: 0 0 10px rgba(92, 242, 197, 0.95);
  animation: game-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes game-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.78); }
}

.game-page[data-phase="loading"] .game-status {
  opacity: 0;
}

/* -------------------------------- 加载态 -------------------------------- */

.game-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background:
    radial-gradient(90% 60% at 50% 40%, rgba(38, 27, 68, 0.96), rgba(11, 8, 20, 0.98) 78%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.game-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.game-loading__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: linear-gradient(150deg, #ff7ba6, #e03b6f 55%, #8b6cff);
  box-shadow: 0 18px 44px rgba(224, 59, 111, 0.34), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  animation: game-loading-float 2.2s var(--ease) infinite;
}

.game-loading__claw {
  position: absolute;
  top: 4px;
  right: 8px;
  color: #fff;
  font-size: 18px;
  transform: rotate(-16deg);
  animation: game-loading-claw 1.9s ease-in-out infinite;
}

.game-loading__doll {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.3));
}

@keyframes game-loading-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1.5deg); }
}

@keyframes game-loading-claw {
  0%, 100% { transform: rotate(-16deg) translateY(0); }
  50% { transform: rotate(-16deg) translateY(-3px); }
}

.game-loading__text {
  color: var(--ink-dim);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.game-loading__bar {
  width: 124px;
  height: 4px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.game-loading__bar i {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--gold));
  transition: width 0.35s var(--ease);
}

.game-loading.is-error .game-loading__bar {
  display: none;
}

.game-retry {
  margin-top: 6px;
  pointer-events: auto;
}

/* -------------------------------- 操作台 -------------------------------- */

.game-deck {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px 14px;
}

.game-dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  touch-action: none;
}

.game-dir {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 17px;
  color: var(--ink-dim);
  font-size: 13px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.028));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 16px rgba(0, 0, 0, 0.24);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.09s var(--ease), background 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.game-dir--up { grid-area: 1 / 2; }
.game-dir--left { grid-area: 2 / 1; }
.game-dir--right { grid-area: 2 / 3; }
.game-dir--down { grid-area: 3 / 2; }

.game-dir.is-active {
  color: #fff;
  background: linear-gradient(160deg, rgba(255, 93, 143, 0.42), rgba(139, 108, 255, 0.28));
  border-color: rgba(255, 93, 143, 0.52);
  box-shadow: 0 0 20px rgba(255, 93, 143, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: scale(0.93);
}

.game-dpad__hub {
  grid-area: 2 / 2;
  display: grid;
  place-items: center;
  color: rgba(169, 156, 196, 0.5);
  font-size: 13px;
}

.game-grab-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-grab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  color: #30081a;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.12em;
  background:
    radial-gradient(circle at 36% 26%, #ffc2d4 0%, #ff7ba6 30%, #ff5d8f 62%, #d92d62 100%);
  box-shadow:
    0 16px 34px rgba(224, 59, 111, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -6px 14px rgba(140, 20, 60, 0.35);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s var(--ease), filter 0.2s ease, box-shadow 0.2s ease;
}

.game-grab:active {
  transform: scale(0.95);
}

.game-grab__ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 209, 102, 0.42);
  animation: game-ring-spin 12s linear infinite;
  pointer-events: none;
}

@keyframes game-ring-spin {
  to { transform: rotate(360deg); }
}

.game-grab__icon {
  font-size: 21px;
  line-height: 1;
  margin-bottom: 2px;
  color: #3a0a1e;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.game-grab__label {
  line-height: 1;
}

.game-grab__cost {
  margin-top: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.66;
}

.game-grab.is-disabled {
  filter: saturate(0.4) brightness(0.74);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34), inset 0 2px 0 rgba(255, 255, 255, 0.18);
}

.game-grab:disabled {
  pointer-events: none;
}

.game-page:not([data-phase="idle"]) .game-dir {
  opacity: 0.42;
}

/* -------------------------------- 弹层 -------------------------------- */

.game-modal {
  border-radius: var(--radius-l);
}

.game-modal .modal__title {
  letter-spacing: 0.04em;
}

.game-modal--win .modal__head {
  background: radial-gradient(120% 160% at 20% 0%, rgba(255, 209, 102, 0.14), transparent 62%);
}

.game-modal--win .modal__title {
  background: linear-gradient(100deg, #ffe7a8, #ff8db0 55%, #c8b6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-modal__foot-row {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  width: 100%;
}

.game-modal__foot-row .btn {
  flex: 1 1 0;
}

/* 开箱 */
.game-unbox {
  position: relative;
  text-align: center;
  padding: 2px 0 4px;
  isolation: isolate;
}

.game-unbox__glow {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 260px;
  height: 200px;
  transform: translateX(-50%);
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(255, 209, 102, 0.34), rgba(255, 93, 143, 0.12) 45%, transparent 70%);
  filter: blur(6px);
  pointer-events: none;
}

.game-unbox[data-rarity="R"] .game-unbox__glow {
  background: radial-gradient(circle at 50% 45%, rgba(127, 178, 255, 0.4), rgba(139, 108, 255, 0.16) 45%, transparent 70%);
}

.game-unbox[data-rarity="SR"] .game-unbox__glow {
  background: radial-gradient(circle at 50% 45%, rgba(255, 209, 102, 0.6), rgba(255, 159, 28, 0.2) 42%, transparent 72%);
}

.game-unbox__stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 150px;
  margin-bottom: 4px;
}

.game-unbox__thumb {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 30%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(10, 7, 18, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: game-unbox-pop 0.72s var(--ease);
}

.game-unbox__thumb img {
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.42));
}

@keyframes game-unbox-pop {
  0% { transform: scale(0.55) rotate(-8deg); opacity: 0; }
  62% { transform: scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.game-unbox__sparkles {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 15px;
  letter-spacing: 26px;
  padding-left: 26px;
  opacity: 0.85;
  animation: game-sparkle 2.6s ease-in-out infinite;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.7);
}

@keyframes game-sparkle {
  0%, 100% { opacity: 0.3; transform: scale(0.96); }
  50% { opacity: 0.95; transform: scale(1.04); }
}

.game-unbox__kicker {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
}

.game-unbox__name {
  margin-top: 5px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.22;
  background: linear-gradient(100deg, #ffe7a8, #ff8db0 55%, #c8b6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-unbox__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 9px;
}

.game-unbox__chip {
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-unbox__facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 14px 0 0;
  padding: 11px 8px;
  border-radius: 15px;
  background: rgba(9, 6, 17, 0.38);
  border: 1px solid var(--line-soft);
}

.game-unbox__facts dt {
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.game-unbox__facts dd {
  margin: 3px 0 0;
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-all;
}

/* 失败 */
.game-fail {
  text-align: center;
  padding: 2px 0 2px;
}

.game-fail__art {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
}

.game-fail__line {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

.game-fail__tips {
  margin: 14px 0 0;
  padding: 12px 14px;
  list-style: none;
  text-align: left;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.75;
}

.game-fail__tips li::before {
  content: "·";
  margin-right: 7px;
  color: var(--coral);
  font-weight: 900;
}

/* 金币不足 */
.game-nocoins {
  text-align: center;
  padding: 2px 0;
}

.game-nocoins__art {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
}

.game-nocoins p {
  margin-top: 10px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.7;
}

.game-nocoins__hint {
  color: var(--gold) !important;
  font-size: 11.5px !important;
  font-weight: 700;
}

/* 概率说明 */
.game-prob-modal__lead {
  color: var(--ink-dim);
  font-size: 12.5px;
  line-height: 1.7;
}

.game-prob-modal__row {
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.game-prob-modal__row b {
  display: inline-block;
  margin-right: 7px;
  color: var(--gold);
  font-size: 11.5px;
}

.game-prob-modal__note {
  margin-top: 12px;
  color: rgba(169, 156, 196, 0.72);
  font-size: 10.5px;
  line-height: 1.65;
}

/* ------------------------------ 横屏/矮屏布局 ------------------------------ */

.game-page[data-layout="landscape"] .game-top {
  padding: calc(var(--safe-t) + 6px) 14px 2px;
}

.game-page[data-layout="landscape"] .game-brand__text span {
  display: none;
}

.game-page[data-layout="landscape"] .game-stage {
  margin: 0 8px 4px;
  border-radius: 18px;
}

.game-page[data-layout="landscape"] .game-deck {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  padding: 0;
  pointer-events: none;
}

.game-page[data-layout="landscape"] .game-dpad {
  position: absolute;
  left: 16px;
  bottom: 14px;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 3px;
  pointer-events: auto;
}

.game-page[data-layout="landscape"] .game-dir {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 12px;
}

.game-page[data-layout="landscape"] .game-grab-wrap {
  position: absolute;
  right: 20px;
  bottom: 18px;
  pointer-events: auto;
}

.game-page[data-layout="landscape"] .game-grab {
  width: 86px;
  height: 86px;
  font-size: 14px;
}

.game-page[data-layout="landscape"] .game-grab__icon {
  font-size: 17px;
}

.game-page[data-layout="landscape"] .game-grab__cost {
  display: none;
}

.game-page[data-layout="landscape"] .game-status {
  bottom: 8px;
  font-size: 10.5px;
}

@media (max-height: 740px) and (min-height: 0px) {
  .game-page[data-layout="portrait"] .game-stage {
    margin: 0 8px;
    border-radius: 20px;
  }

  .game-page[data-layout="portrait"] .game-dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
  }

  .game-page[data-layout="portrait"] .game-dir {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .game-page[data-layout="portrait"] .game-grab {
    width: 92px;
    height: 92px;
    font-size: 15px;
  }

  .game-page[data-layout="portrait"] .game-deck {
    padding: 8px 16px 10px;
  }
}

@media (max-height: 620px) {
  .game-brand__text {
    display: none;
  }

  .game-top {
    padding-top: calc(var(--safe-t) + 6px);
    padding-bottom: 2px;
  }
}
