:root {
  --theme: #FF8A3D;
  --theme-deep: #F26A1B;
  --gold: #FFD166;
  --ink: #062A44;
  --glass: rgba(6, 36, 58, 0.76);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

html {
  background: #062030;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(100% 80% at 50% 0%, #0f527b 0%, #082c44 55%, #041826 100%);
  color: #fff;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.sound-btn:focus,
.replay:focus {
  outline: none;
}

.sound-btn:focus-visible,
.replay:focus-visible {
  outline: 3px solid rgba(255, 220, 140, 0.92);
  outline-offset: 3px;
}

/* ------------------------------------------------------------
   游戏画布：竖屏铺满，顶部不留标题 / 导航
   ------------------------------------------------------------ */
.game {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 640px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #0d4266;
  cursor: pointer;
  isolation: isolate;
  container-type: inline-size;
}

/* 平板 / 桌面预览：保持 1:2 的竖屏画面，不做横向拉伸 */
@media (min-aspect-ratio: 3/5) {
  .game {
    width: 50dvh;
    max-width: 640px;
  }
}

@media (min-width: 560px) {
  .game {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08),
      0 30px 90px rgba(0, 0, 0, 0.55);
  }
}

.scenes {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #0c3b58;
  overflow: hidden;
}

/* 一张 gpt-image 成品图切成三格：抛竿 / 咬钩 / 收鱼 */
.scene {
  position: absolute;
  inset: 0;
  background-image: url("images/gen/gptimg_1795239673_look.png");
  background-repeat: no-repeat;
  background-size: 300% 100%;
  background-position: 0% 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: opacity;
}

.scene-1 { background-position: 0% 50%; }
.scene-2 { background-position: 50% 50%; }
.scene-3 { background-position: 100% 50%; }

.scene.is-on {
  opacity: 1;
}

.scene-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 25, 41, 0.1) 0%, rgba(3, 25, 41, 0) 16%, rgba(3, 25, 41, 0) 70%, rgba(3, 21, 34, 0.32) 100%),
    radial-gradient(120% 78% at 50% 42%, rgba(3, 22, 36, 0) 56%, rgba(3, 22, 36, 0.22) 100%);
}

/* ------------------------------------------------------------
   UI 层：全部用成品图内的百分比坐标，换机型也不会跑偏
   ------------------------------------------------------------ */
.ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* 右上角的水面/天空留白里放真实渔获数（同时盖住原图的 1250 + 商店加号） */
.score-chip {
  position: absolute;
  left: 19.8%;
  top: 2.9%;
  width: 33%;
  height: 5.4%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6%;
  padding: 0 4%;
  border-radius: 999px;
  background: linear-gradient(180deg, #65b9e6 0%, #3f94c6 48%, #2d7dab 100%);
  border: 2px solid rgba(255, 255, 255, 0.68);
  box-shadow:
    inset 0 2px 2px rgba(255, 255, 255, 0.58),
    inset 0 -4px 7px rgba(0, 47, 76, 0.28),
    0 4px 10px rgba(0, 24, 41, 0.28);
  color: #fff;
  font-size: 15px;
  font-size: clamp(12px, 3.9cqw, 26px);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 3px rgba(0, 38, 66, 0.55);
  white-space: nowrap;
  pointer-events: none;
}

.score-chip .mp-icon {
  width: 1.28em;
  height: 1.28em;
  flex: none;
  color: #ffe08a;
  filter: drop-shadow(0 1px 1px rgba(0, 39, 66, 0.4));
}

.score-text b {
  color: #ffefb0;
  font-size: 1.15em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.score-chip.bump {
  animation: scoreBump 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

/* 盖住原图齿轮，做真的声音开关 */
.sound-btn {
  position: absolute;
  left: 89.4%;
  top: 5.9%;
  width: 11.8%;
  height: 6.05%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 46%),
    linear-gradient(180deg, #4385ad 0%, #25658d 58%, #194e70 100%);
  border: 2px solid rgba(255, 255, 255, 0.52);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.34),
    inset 0 -3px 6px rgba(0, 30, 51, 0.34),
    0 4px 11px rgba(0, 20, 35, 0.3);
  pointer-events: auto;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.sound-btn::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}

.sound-btn .mp-icon {
  width: 60%;
  height: 60%;
  filter: drop-shadow(0 1px 2px rgba(0, 24, 40, 0.5));
}

.sound-btn:active {
  transform: translate(-50%, -50%) scale(0.9);
  filter: brightness(1.12);
}

/* 原图发光钓竿按钮外圈的呼吸提示，不遮住画面 */
.cast-hint {
  position: absolute;
  left: 54.3%;
  top: 82.5%;
  width: 48%;
  height: 24%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.game.state-ready .cast-hint {
  opacity: 1;
}

.cast-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 226, 150, 0.92);
  box-shadow:
    0 0 16px rgba(255, 197, 80, 0.72),
    inset 0 0 22px rgba(255, 197, 80, 0.18);
  opacity: 0;
  animation: hintPulse 2.1s ease-out infinite;
}

.cast-ring.ring-b {
  animation-delay: 1.05s;
}

/* 咬钩时机：用一条压暗的扇形扫过原图的彩色圆环 */
.bite-drain {
  --turn: 0deg;
  position: absolute;
  left: 54.7%;
  top: 48.1%;
  width: 42%;
  height: 21%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    rgba(3, 25, 41, 0.73) 0deg,
    rgba(3, 25, 41, 0.73) var(--turn),
    rgba(3, 25, 41, 0) var(--turn)
  );
  -webkit-mask: radial-gradient(farthest-side, transparent 63%, #000 65%);
  mask: radial-gradient(farthest-side, transparent 63%, #000 65%);
  opacity: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
  filter: drop-shadow(0 0 5px rgba(4, 29, 47, 0.3));
}

.game.state-bite .bite-drain {
  opacity: 1;
}

/* 鱼线入水处的涟漪 */
.ripples {
  position: absolute;
  left: 78.1%;
  top: 49.3%;
  width: 16%;
  height: 8%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.game.state-waiting .ripples {
  opacity: 1;
}

.ripples span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.58);
  opacity: 0;
  animation: waterRipple 2.7s linear infinite;
}

.ripples span:nth-child(2) { animation-delay: 0.9s; }
.ripples span:nth-child(3) { animation-delay: 1.8s; }

/* 抛竿瞬间的白色水花 */
.splash {
  position: absolute;
  left: 78.1%;
  top: 49.3%;
  width: 11%;
  height: 5.5%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.splash span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  opacity: 0;
}

.splash.burst {
  opacity: 1;
}

.splash.burst span {
  animation: splashBurst 0.68s ease-out forwards;
}

.splash.burst span:nth-child(2) {
  animation-delay: 0.11s;
}

/* 操作提示 */
.callout {
  position: absolute;
  left: 54.3%;
  top: 63%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-width: 78%;
  padding: 9px 19px 10px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(8, 43, 69, 0.8), rgba(4, 29, 48, 0.74));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 10px 26px rgba(0, 18, 32, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  text-align: center;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: top 0.22s ease, background 0.22s ease, border-color 0.22s ease, padding 0.22s ease, opacity 0.18s ease;
}

.game.state-caught .callout {
  opacity: 0;
  visibility: hidden;
}

.callout-main {
  display: block;
  color: #fff;
  font-size: 16px;
  font-size: clamp(15px, 4.15cqw, 27px);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 5px rgba(0, 20, 35, 0.45);
  white-space: nowrap;
}

.callout-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-size: clamp(10px, 2.95cqw, 19px);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.callout-sub .mp-icon {
  width: 1.18em;
  height: 1.18em;
  color: #ffd98a;
}

/* 咬钩：提示变大变亮 */
.game.state-bite .callout {
  top: 60.2%;
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.game.state-bite .callout-main {
  color: #ffd166;
  font-size: 29px;
  font-size: clamp(24px, 7.4cqw, 47px);
  letter-spacing: 0.04em;
  text-shadow:
    0 2px 0 #b95012,
    0 4px 0 rgba(110, 43, 7, 0.55),
    0 8px 22px rgba(255, 138, 61, 0.9);
  animation: bitePop 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.game.state-bite .callout-sub {
  margin-top: 7px;
  padding: 6px 17px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffad4d, #ff7a2e);
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-size: 13px;
  font-size: clamp(12px, 3.35cqw, 22px);
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(255, 112, 40, 0.48);
  animation: subPulse 0.78s ease-in-out infinite;
}

.game.state-bite .callout-sub .mp-icon {
  display: none;
}

.game.state-bite.urgent .callout-sub {
  background: linear-gradient(180deg, #ff6b57, #d92d20);
  animation-duration: 0.36s;
}

/* 抛竿瞬间 */
.game.state-casting .callout {
  animation: castLift 0.26s ease;
}

/* 鱼跑掉 */
.game.state-miss .callout {
  background: linear-gradient(180deg, rgba(92, 34, 27, 0.82), rgba(58, 19, 15, 0.76));
  border-color: rgba(255, 150, 120, 0.38);
}

.game.state-miss .callout-main {
  color: #ffd7c9;
}

/* 收鱼结算卡：底部浮起，盖住码头，不挡鱼和 +100 */
.catch-sheet {
  position: absolute;
  left: 50%;
  bottom: calc(4.2% + var(--safe-bottom));
  width: 86%;
  transform: translate(-50%, 26px) scale(0.98);
  opacity: 0;
  padding: 13px 17px 16px;
  border-radius: 26px;
  background:
    linear-gradient(165deg, rgba(14, 58, 87, 0.97) 0%, rgba(6, 31, 50, 0.98) 62%, rgba(5, 26, 43, 0.99) 100%);
  border: 1px solid rgba(255, 197, 102, 0.56);
  box-shadow:
    0 24px 56px rgba(0, 10, 20, 0.56),
    inset 0 1px 0 rgba(255, 255, 255, 0.17);
  pointer-events: none;
  transition: transform 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.1), opacity 0.26s ease;
}

.game.state-caught .catch-sheet {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0.1s;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 0 auto 11px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.24);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.sheet-kicker {
  flex: none;
  color: #ffc56e;
  font-size: 11px;
  font-size: clamp(10px, 2.7cqw, 18px);
  font-weight: 900;
  letter-spacing: 0.16em;
}

.sheet-fish {
  overflow: hidden;
  color: #fff;
  font-size: 25px;
  font-size: clamp(21px, 6.2cqw, 40px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 3px 10px rgba(0, 12, 24, 0.5);
}

.sheet-badge {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe29a 0%, #ffc24d 45%, #ff9e2e 100%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    0 5px 12px rgba(255, 135, 40, 0.35),
    inset 0 1px 1px rgba(255, 255, 255, 0.8);
  color: #7a3a00;
  font-size: 12px;
  font-size: clamp(11px, 3cqw, 20px);
  font-weight: 900;
  white-space: nowrap;
}

.sheet-badge .mp-icon {
  width: 1.2em;
  height: 1.2em;
  color: #a85100;
}

.sheet-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-size: clamp(11px, 3cqw, 20px);
  font-weight: 600;
}

.sheet-meta b {
  color: #ffd98a;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
}

.replay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 13px;
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffb452 0%, #ff8a3d 46%, #f26a1b 100%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 10px 22px rgba(226, 87, 18, 0.42),
    inset 0 2px 1px rgba(255, 235, 200, 0.55),
    inset 0 -3px 7px rgba(159, 52, 3, 0.28);
  color: #fff;
  font-size: 16px;
  font-size: clamp(15px, 4.1cqw, 27px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 3px rgba(140, 46, 2, 0.38);
  pointer-events: auto;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.replay .mp-icon {
  width: 1.25em;
  height: 1.25em;
  filter: drop-shadow(0 1px 1px rgba(120, 38, 0, 0.35));
}

.replay:active {
  transform: translateY(1px) scale(0.985);
  filter: brightness(1.06);
}

/* 轻提示 */
.toast {
  position: absolute;
  left: 50%;
  top: 56.5%;
  transform: translate(-50%, 6px);
  max-width: 76%;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(5, 28, 45, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 20px rgba(0, 12, 24, 0.35);
  color: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  font-size: clamp(11px, 3.15cqw, 21px);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 全屏闪光 / 边缘暗角 */
.flash {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
}

.flash.bite {
  background: radial-gradient(circle at 54% 47%, rgba(255, 229, 155, 0.62) 0%, rgba(255, 176, 76, 0.24) 26%, rgba(255, 138, 61, 0) 58%);
}

.flash.gold {
  background: radial-gradient(circle at 54% 45%, rgba(255, 240, 180, 0.68) 0%, rgba(255, 190, 85, 0.26) 30%, rgba(255, 138, 61, 0) 64%);
}

.flash.red {
  background: radial-gradient(circle at 50% 50%, rgba(255, 92, 70, 0) 38%, rgba(170, 26, 18, 0.4) 100%);
}

.flash.on {
  animation: flashOut 0.52s ease-out forwards;
}

.edge-vignette {
  position: absolute;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  background: radial-gradient(130% 92% at 50% 46%, rgba(2, 16, 27, 0) 62%, rgba(2, 16, 27, 0.26) 100%);
}

/* ------------------------------------------------------------
   动画
   ------------------------------------------------------------ */
@keyframes hintPulse {
  0% { transform: scale(0.88); opacity: 0; }
  22% { opacity: 0.95; }
  72% { opacity: 0.3; }
  100% { transform: scale(1.07); opacity: 0; }
}

@keyframes waterRipple {
  0% { transform: scale(0.28); opacity: 0; }
  16% { opacity: 0.68; }
  100% { transform: scale(1.22); opacity: 0; }
}

@keyframes splashBurst {
  0% { transform: scale(0.2); opacity: 0; }
  24% { opacity: 1; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes bitePop {
  0% { transform: scale(0.66); opacity: 0; }
  70% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes subPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 20px rgba(255, 112, 40, 0.42); }
  50% { transform: scale(1.045); box-shadow: 0 10px 26px rgba(255, 112, 40, 0.7); }
}

@keyframes castLift {
  0% { transform: translateX(-50%) translateY(5px) scale(0.97); opacity: 0.7; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

@keyframes flashOut {
  0% { opacity: 0; }
  16% { opacity: 1; }
  100% { opacity: 0; }
}

/* ------------------------------------------------------------
   小屏兜底
   ------------------------------------------------------------ */
@media (max-height: 700px) {
  .callout {
    top: 62%;
    padding: 8px 16px 9px;
  }
  .catch-sheet {
    padding: 11px 15px 13px;
    border-radius: 22px;
  }
  .replay {
    min-height: 47px;
    margin-top: 10px;
  }
  .sheet-grip {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cast-ring,
  .ripples span,
  .splash.burst span,
  .sheet-badge,
  .toast,
  .scene {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .cast-ring {
    opacity: 0.78;
  }
  .cast-ring.ring-b {
    display: none;
  }
  .game.state-bite .callout-sub {
    animation: none;
  }
}
