/**
 * @file        t-rex.css
 * @description 史莱姆魔法世界 — 日月星辰·山川河流·桃花梨花
 *               5 时间段颜色系统 + 视角深度 + 动态闪烁
 */

/* ==============================================================
   魔法主题色 — 6 主题 + 5 时间段双重系统
   ============================================================== */
:root {
  --trex-fill:        #7c4dff;
  --trex-fill-light:  #b388ff;
  --trex-fill-dark:   #5600e8;
  --trex-shadow:      rgba(124,77,255,0.25);
  --trex-ground-line: #b388ff;
  --trex-world-bg:    #f3e8ff;
  --trex-score-color: #5600e8;
  --trex-notif-color: #7c4dff;
  --trex-slime-body:  #80deea;
  --trex-slime-dark:  #4dd0e1;
  --trex-slime-light: #b2ebf2;
  --trex-magic-glow:  rgba(179,136,255,0.3);
  --trex-crystal-color: #b388ff;
  --trex-crystal-core: #e8d5ff;
  --trex-fairy-body:  #f8bbd0;
  --trex-fairy-wing:  rgba(248,187,208,0.5);
  --trex-river-color: #90caf9;
  --trex-tree-blossom: #f48fb1;
  --trex-tree-blossom2: #fff9c4;
}
[data-theme="dark"] {
  --trex-fill:        #b388ff;  --trex-fill-light:#dcc8ff;  --trex-fill-dark:#7c4dff;
  --trex-shadow:rgba(179,136,255,0.3); --trex-ground-line:#b388ff; --trex-world-bg:#1a1030;
  --trex-score-color:#dcc8ff; --trex-notif-color:#b388ff;
  --trex-slime-body:#4dd0e1; --trex-slime-dark:#26c6da; --trex-slime-light:#80deea;
  --trex-magic-glow:rgba(179,136,255,0.2); --trex-crystal-color:#9c7cff; --trex-crystal-core:#dcc8ff;
  --trex-fairy-body:#f48fb1; --trex-fairy-wing:rgba(244,143,177,0.4);
  --trex-river-color:#4a6fa5; --trex-tree-blossom:#e91e63; --trex-tree-blossom2:#fff176;
}
[data-theme="neon"] {
  --trex-fill:#ff00ff; --trex-fill-light:#ff66ff; --trex-fill-dark:#cc00cc;
  --trex-shadow:rgba(255,0,255,0.3); --trex-ground-line:#ff00ff; --trex-world-bg:#0a001a;
  --trex-score-color:#ff66ff; --trex-notif-color:#ff00ff;
  --trex-slime-body:#69f0ae; --trex-slime-dark:#40c4ff; --trex-slime-light:#b9f6ca;
  --trex-magic-glow:rgba(255,0,255,0.3); --trex-crystal-color:#ff44ff; --trex-crystal-core:#ffccff;
  --trex-fairy-body:#ff80ab; --trex-fairy-wing:rgba(255,128,171,0.4);
  --trex-river-color:#00bcd4; --trex-tree-blossom:#ff4081; --trex-tree-blossom2:#ffea00;
}
[data-theme="pastel"] {
  --trex-fill:#ce93d8; --trex-fill-light:#e1bee7; --trex-fill-dark:#ab47bc;
  --trex-shadow:rgba(206,147,216,0.25); --trex-ground-line:#ce93d8; --trex-world-bg:#fef6fb;
  --trex-score-color:#8e24aa; --trex-notif-color:#ce93d8;
  --trex-slime-body:#f8bbd0; --trex-slime-dark:#f48fb1; --trex-slime-light:#fce4ec;
  --trex-magic-glow:rgba(206,147,216,0.25); --trex-crystal-color:#f8bbd0; --trex-crystal-core:#fce4ec;
  --trex-fairy-body:#f8bbd0; --trex-fairy-wing:rgba(248,187,208,0.5);
  --trex-river-color:#b39ddb; --trex-tree-blossom:#f48fb1; --trex-tree-blossom2:#fff59d;
}
[data-theme="forest"] {
  --trex-fill:#66bb6a; --trex-fill-light:#a5d6a7; --trex-fill-dark:#388e3c;
  --trex-shadow:rgba(102,187,106,0.25); --trex-ground-line:#66bb6a; --trex-world-bg:#e8f5e9;
  --trex-score-color:#1b5e20; --trex-notif-color:#2e7d32;
  --trex-slime-body:#a5d6a7; --trex-slime-dark:#81c784; --trex-slime-light:#c8e6c9;
  --trex-magic-glow:rgba(102,187,106,0.25); --trex-crystal-color:#81c784; --trex-crystal-core:#c8e6c9;
  --trex-fairy-body:#a5d6a7; --trex-fairy-wing:rgba(165,214,167,0.5);
  --trex-river-color:#4db6ac; --trex-tree-blossom:#ef9a9a; --trex-tree-blossom2:#e6ee9c;
}
[data-theme="ocean"] {
  --trex-fill:#29b6f6; --trex-fill-light:#81d4fa; --trex-fill-dark:#0288d1;
  --trex-shadow:rgba(41,182,246,0.25); --trex-ground-line:#29b6f6; --trex-world-bg:#e1f5fe;
  --trex-score-color:#01579b; --trex-notif-color:#0277bd;
  --trex-slime-body:#81d4fa; --trex-slime-dark:#4fc3f7; --trex-slime-light:#b3e5fc;
  --trex-magic-glow:rgba(41,182,246,0.25); --trex-crystal-color:#4fc3f7; --trex-crystal-core:#b3e5fc;
  --trex-fairy-body:#81d4fa; --trex-fairy-wing:rgba(129,212,250,0.5);
  --trex-river-color:#4fc3f7; --trex-tree-blossom:#90caf9; --trex-tree-blossom2:#fff59d;
}

/* ==============================================================
   时间段颜色系统 — 史莱姆/水晶/精灵龙随 data-time 变色
   ============================================================== */
#trex-world[data-time="day"] {
  --trex-slime-body: #80deea;  --trex-slime-dark: #4dd0e1;  --trex-slime-light: #b2ebf2;
  --trex-crystal-color: #b388ff; --trex-crystal-core: #e8d5ff;
  --trex-fairy-body: #f8bbd0;
  --trex-river-color: #90caf9;
  --trex-tree-blossom: #f48fb1; --trex-tree-blossom2: #fff9c4;
  --trex-slime-glow: rgba(128,222,234,0.25);
  --trex-bg-geo-color: rgba(179,136,255,0.2);
}
#trex-world[data-time="sunset"] {
  --trex-slime-body: #ffcc80;  --trex-slime-dark: #ffb74d;  --trex-slime-light: #ffe0b2;
  --trex-crystal-color: #ffab91; --trex-crystal-core: #ffccbc;
  --trex-fairy-body: #ffab91;
  --trex-river-color: #ffab76;
  --trex-tree-blossom: #ff8a65; --trex-tree-blossom2: #ffe0b2;
  --trex-slime-glow: rgba(255,204,128,0.3);
  --trex-bg-geo-color: rgba(255,171,145,0.25);
}
#trex-world[data-time="night"] {
  --trex-slime-body: #5c6bc0;  --trex-slime-dark: #7986cb;  --trex-slime-light: #9fa8da;
  --trex-crystal-color: #6a4c9c; --trex-crystal-core: #b39ddb;
  --trex-fairy-body: #7986cb;
  --trex-river-color: #1a3a5a;
  --trex-tree-blossom: #5c6bc0; --trex-tree-blossom2: #7986cb;
  --trex-slime-glow: rgba(92,107,192,0.35);
  --trex-bg-geo-color: rgba(121,134,203,0.2);
}
#trex-world[data-time="deepnight"] {
  --trex-slime-body: #7986cb;  --trex-slime-dark: #5c6bc0;  --trex-slime-light: #9fa8da;
  --trex-crystal-color: #4a307a; --trex-crystal-core: #7e57c2;
  --trex-fairy-body: #5c6bc0;
  --trex-river-color: #0d1a2a;
  --trex-tree-blossom: #3949ab; --trex-tree-blossom2: #5c6bc0;
  --trex-slime-glow: rgba(121,134,203,0.4);
  --trex-bg-geo-color: rgba(92,107,192,0.15);
}
#trex-world[data-time="dawn"] {
  --trex-slime-body: #90caf9;  --trex-slime-dark: #64b5f6;  --trex-slime-light: #bbdefb;
  --trex-crystal-color: #9fa8da; --trex-crystal-core: #c5cae9;
  --trex-fairy-body: #9fa8da;
  --trex-river-color: #6a9ab8;
  --trex-tree-blossom: #7986cb; --trex-tree-blossom2: #c5cae9;
  --trex-slime-glow: rgba(144,202,249,0.25);
  --trex-bg-geo-color: rgba(159,168,218,0.2);
}

/* ==============================================================
   游戏容器
   ============================================================== */
#trex-game {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100dvh;
  background: var(--color-bg, #faf8ef);
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background var(--transition-theme, 0.4s ease);
}

/* ==============================================================
   游戏世界 — 魔法天空 + 视角深度渐变
   ============================================================== */
#trex-world {
  position: relative;
  width: min(95vw, 900px);
  height: min(60vh, 420px);
  overflow: hidden;
  cursor: pointer;
  border-radius: var(--border-radius-lg, 12px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1), 0 8px 32px rgba(0,0,0,0.06);
  transition: background 1s ease, box-shadow 0.4s ease;
  border: 1px solid rgba(0,0,0,0.04);
  touch-action: none; /* 防止浏览器手势截获触控 */
}
/* 视角深度渐变（底部暗角模拟景深） */
#trex-world::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 40%;
  background: linear-gradient(0deg, rgba(0,0,0,0.06) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* 魔法天空 5 时间段 */
#trex-world[data-time="day"] {
  background: linear-gradient(180deg, #90caf9 0%, #bbdefb 25%, #e3f2fd 50%, var(--trex-world-bg) 100%);
}
#trex-world[data-time="sunset"] {
  background: linear-gradient(180deg, #ff8a65 0%, #ffab91 20%, #ffcc80 40%, #ffe0b2 60%, var(--trex-world-bg) 100%);
}
#trex-world[data-time="night"] {
  background: linear-gradient(180deg, #0d0221 0%, #1a0533 25%, #1a1030 50%, #1a1a3e 100%);
}
#trex-world[data-time="deepnight"] {
  background: linear-gradient(180deg, #050010 0%, #0d0221 25%, #0d0d2b 50%, #0d0d2b 100%);
}
#trex-world[data-time="dawn"] {
  background: linear-gradient(180deg, #3949ab 0%, #5c6bc0 25%, #7986cb 50%, #b39ddb 75%, var(--trex-world-bg) 100%);
}

/* ==============================================================
   太阳/月亮 — 增强光晕 + 光芒
   ============================================================== */
.trex-bg-sunmoon {
  position: absolute;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  transition: all 0.8s ease;
}

/* 白天太阳 */
#trex-world[data-time="day"] .trex-bg-sunmoon {
  top: 24px; right: 60px;
  width: 32px; height: 32px;
  background: radial-gradient(circle at 35% 35%, #fff8e1, #ffd54f);
  box-shadow: 0 0 40px rgba(255,213,79,0.6), 0 0 80px rgba(255,213,79,0.3), 0 0 120px rgba(255,213,79,0.1);
}
#trex-world[data-time="day"] .trex-bg-sunmoon::after {
  content: ''; position: absolute; top: -8px; left: -8px; right: -8px; bottom: -8px;
  background: radial-gradient(circle, rgba(255,213,79,0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: sunRays 4s ease-in-out infinite alternate;
}
@keyframes sunRays {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* 黄昏落日 */
#trex-world[data-time="sunset"] .trex-bg-sunmoon {
  top: 60px; right: 80px;
  width: 38px; height: 38px;
  background: radial-gradient(circle at 35% 35%, #ffccbc, #ff6e40);
  box-shadow: 0 0 50px rgba(255,110,64,0.6), 0 0 100px rgba(255,110,64,0.3);
}

/* 夜晚弯月 */
#trex-world[data-time="night"] .trex-bg-sunmoon {
  top: 28px; right: 55px;
  width: 26px; height: 26px;
  background: radial-gradient(circle at 55% 45%, #e8d5ff, #b388ff);
  box-shadow: 0 0 30px rgba(179,136,255,0.4), 0 0 60px rgba(179,136,255,0.15);
}
#trex-world[data-time="night"] .trex-bg-sunmoon::after {
  content: ''; position: absolute; top: -3px; left: -5px;
  width: 24px; height: 24px;
  background: #0d0221; border-radius: 50%;
}

/* 深夜月 */
#trex-world[data-time="deepnight"] .trex-bg-sunmoon {
  top: 32px; right: 55px;
  width: 22px; height: 22px;
  background: radial-gradient(circle at 55% 45%, #dcc8ff, #9c7cff);
  box-shadow: 0 0 20px rgba(156,124,255,0.3);
}
#trex-world[data-time="deepnight"] .trex-bg-sunmoon::after {
  content: ''; position: absolute; top: -2px; left: -4px;
  width: 20px; height: 20px;
  background: #050010; border-radius: 50%;
}

/* 黎明淡月 */
#trex-world[data-time="dawn"] .trex-bg-sunmoon {
  top: 32px; right: 58px;
  width: 24px; height: 24px;
  background: radial-gradient(circle at 35% 35%, #e8eaf6, #c5cae9);
  box-shadow: 0 0 20px rgba(197,202,233,0.3);
}

/* ==============================================================
   星星 — 闪烁动画（仅夜晚/深夜）
   ============================================================== */
@keyframes starTwinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

#trex-world[data-time="night"] .trex-bg-stars,
#trex-world[data-time="deepnight"] .trex-bg-stars {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1;
}
#trex-world[data-time="night"] .trex-bg-stars::before,
#trex-world[data-time="deepnight"] .trex-bg-stars::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(2px 2px at 8% 12%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1.5px 1.5px at 22% 8%, rgba(255,255,255,0.7), transparent),
    radial-gradient(2.5px 2.5px at 38% 18%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 52% 10%, rgba(255,255,255,0.9), transparent),
    radial-gradient(2px 2px at 68% 15%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 82% 8%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2.5px 2.5px at 15% 22%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 58% 20%, rgba(255,255,255,0.8), transparent),
    radial-gradient(2px 2px at 88% 25%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 32% 28%, rgba(255,255,255,0.6), transparent),
    radial-gradient(2.5px 2.5px at 72% 8%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 45% 32%, rgba(255,255,255,0.5), transparent),
    radial-gradient(2px 2px at 12% 35%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 78% 30%, rgba(255,255,255,0.7), transparent);
  animation: starTwinkle 3s ease-in-out infinite;
}
#trex-world[data-time="deepnight"] .trex-bg-stars::before {
  animation-duration: 4s;
}

/* 第二层星星 — 不同频率闪烁 */
#trex-world[data-time="night"] .trex-bg-stars::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(1px 1px at 5% 18%, rgba(200,200,255,0.8), transparent),
    radial-gradient(1.5px 1.5px at 28% 14%, rgba(200,200,255,0.6), transparent),
    radial-gradient(1px 1px at 48% 25%, rgba(200,200,255,0.7), transparent),
    radial-gradient(2px 2px at 62% 28%, rgba(200,200,255,0.8), transparent),
    radial-gradient(1px 1px at 75% 12%, rgba(200,200,255,0.6), transparent),
    radial-gradient(1.5px 1.5px at 92% 22%, rgba(200,200,255,0.7), transparent),
    radial-gradient(1px 1px at 40% 36%, rgba(200,200,255,0.5), transparent);
  animation: starTwinkle 2.2s ease-in-out 1.5s infinite;
}

/* ==============================================================
   远山 — 双层，更丰富
   ============================================================== */
.trex-bg-mountains-far {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  height: 90px; z-index: 1; pointer-events: none; overflow: hidden;
}
.trex-bg-mountains-far::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; width: 200%; height: 100%;
  background:
    radial-gradient(ellipse 70px 60px at 10% 100%, rgba(150,170,220,0.2), transparent),
    radial-gradient(ellipse 90px 70px at 28% 100%, rgba(150,170,220,0.15), transparent),
    radial-gradient(ellipse 80px 65px at 48% 100%, rgba(150,170,220,0.2), transparent),
    radial-gradient(ellipse 100px 75px at 70% 100%, rgba(150,170,220,0.15), transparent),
    radial-gradient(ellipse 85px 60px at 88% 100%, rgba(150,170,220,0.18), transparent);
  animation: trexMountainScroll 35s linear infinite;
}
/* 远山第二层 */
.trex-bg-mountains-far::after {
  content: '';
  position: absolute;
  bottom: 0; left: 30px; width: 200%; height: 80%;
  background:
    radial-gradient(ellipse 60px 50px at 18% 100%, rgba(130,150,200,0.12), transparent),
    radial-gradient(ellipse 75px 55px at 40% 100%, rgba(130,150,200,0.1), transparent),
    radial-gradient(ellipse 65px 45px at 60% 100%, rgba(130,150,200,0.12), transparent),
    radial-gradient(ellipse 80px 60px at 82% 100%, rgba(130,150,200,0.1), transparent);
  animation: trexMountainScroll 45s linear infinite;
}

/* ==============================================================
   近山
   ============================================================== */
.trex-bg-mountains-near {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  height: 55px; z-index: 1; pointer-events: none; overflow: hidden;
}
.trex-bg-mountains-near::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; width: 200%; height: 100%;
  background:
    radial-gradient(ellipse 55px 45px at 12% 100%, rgba(124,77,255,0.2), transparent),
    radial-gradient(ellipse 65px 50px at 32% 100%, rgba(124,77,255,0.15), transparent),
    radial-gradient(ellipse 60px 42px at 52% 100%, rgba(124,77,255,0.2), transparent),
    radial-gradient(ellipse 70px 48px at 72% 100%, rgba(124,77,255,0.15), transparent),
    radial-gradient(ellipse 50px 38px at 90% 100%, rgba(124,77,255,0.18), transparent);
  animation: trexMountainScroll 20s linear infinite;
}
@keyframes trexMountainScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ==============================================================
   河流 — 流动水带
   ============================================================== */
.trex-bg-river {
  position: absolute;
  bottom: 18px; left: 0; right: 0;
  height: 8px; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--trex-river-color) 10%,
    var(--trex-river-color) 90%,
    transparent 100%
  );
  opacity: 0.35;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
/* 河流波光 */
.trex-bg-river::after {
  content: '';
  position: absolute;
  top: 1px; left: 0; right: 0; bottom: 1px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.15) 0px,
    transparent 3px,
    rgba(255,255,255,0.1) 6px,
    transparent 10px,
    rgba(255,255,255,0.12) 14px,
    transparent 20px
  );
  animation: riverFlow 2s linear infinite;
}
@keyframes riverFlow {
  0% { background-position-x: 0; }
  100% { background-position-x: 20px; }
}

/* ==============================================================
   几何魔方背景 — GSAP 驱动，浮动光圈/菱形/圆
   ============================================================== */
.trex-bg-geo {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.trex-geo-shape {
  position: absolute;
  border-radius: 50%;
  opacity: 0.35;
  will-change: transform;
}

/* 菱形变体 */
.trex-geo-shape.is-diamond {
  border-radius: 2px;
  transform: rotate(45deg);
}

/* 圆角矩形变体 */
.trex-geo-shape.is-rect {
  border-radius: 30%;
}

/* ==============================================================
   云彩
   ============================================================== */
.trex-bg-clouds {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 160px; z-index: 1; pointer-events: none; overflow: hidden;
}
.trex-bg-clouds::before {
  content: '';
  position: absolute; top: 30px;
  width: 60px; height: 24px;
  background: radial-gradient(ellipse at 30% 50%, rgba(255,255,255,0.5) 0%, transparent 70%);
  border-radius: 50%;
  animation: trexCloudDrift 25s linear infinite;
  left: -80px;
}
.trex-bg-clouds::after {
  content: '';
  position: absolute; top: 60px;
  width: 40px; height: 16px;
  background: radial-gradient(ellipse at 40% 50%, rgba(255,255,255,0.35) 0%, transparent 70%);
  border-radius: 50%;
  animation: trexCloudDrift2 35s linear infinite;
  left: -60px;
}
@keyframes trexCloudDrift {
  0% { transform: translateX(0); opacity: 0; }
  5% { opacity: 0.5; }
  90% { opacity: 0.5; }
  100% { transform: translateX(calc(95vw + 200px)); opacity: 0; }
}
@keyframes trexCloudDrift2 {
  0% { transform: translateX(0); opacity: 0; }
  5% { opacity: 0.35; }
  90% { opacity: 0.35; }
  100% { transform: translateX(calc(95vw + 160px)); opacity: 0; }
}

/* ==============================================================
   地面
   ============================================================== */
#trex-ground { --ground-speed: 0.4s; }
.trex-ground {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 16px; pointer-events: none; z-index: 4;
}
.trex-ground::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--trex-ground-line) 10%, var(--trex-ground-line) 90%, transparent 100%);
  opacity: 0.4; box-shadow: 0 0 6px var(--trex-magic-glow);
}
@keyframes trexGroundMove {
  0% { background-position: 0 0; }
  100% { background-position: -20px 0; }
}
.trex-ground::after {
  content: '';
  position: absolute; top: 5px; left: 0; right: 0; height: 6px;
  background: repeating-linear-gradient(90deg, transparent 0px, transparent 3px, var(--trex-ground-line) 3px, var(--trex-ground-line) 5px, transparent 5px, transparent 20px);
  animation: trexGroundMove var(--ground-speed, 0.4s) linear infinite;
  opacity: 0.2; filter: blur(0.5px);
}

/* ==============================================================
   史莱姆
   ============================================================== */
.trex-dino {
  position: absolute; bottom: 16px; left: 30px;
  width: 40px; height: 36px; z-index: 10;
  transform-origin: bottom center;
  filter: drop-shadow(0 3px 6px var(--trex-shadow));
  transition: filter 0.5s ease;
}
.trex-slime-body {
  position: absolute; bottom: 0; left: 2px;
  width: 36px; height: 34px;
  background: radial-gradient(ellipse at 35% 30%, var(--trex-slime-light), var(--trex-slime-body) 45%, var(--trex-slime-dark) 100%);
  border-radius: 50% 50% 45% 45% / 55% 55% 40% 40%;
  z-index: 2;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.08), inset 0 3px 6px rgba(255,255,255,0.25), 0 0 16px var(--trex-slime-glow);
  animation: slimeBreath 2.4s ease-in-out infinite;
  transition: background 0.8s ease, box-shadow 0.8s ease;
}
.trex-slime-highlight {
  position: absolute; top: 5px; left: 7px;
  width: 18px; height: 10px;
  background: radial-gradient(ellipse, rgba(255,255,255,0.45) 0%, transparent 70%);
  border-radius: 50%; z-index: 3; pointer-events: none;
}
/* 史莱姆呼吸 + 静止小动作 */
@keyframes slimeBreath {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  25% { transform: scaleY(0.97) scaleX(1.02); }
  50% { transform: scaleY(1) scaleX(1); }
  75% { transform: scaleY(0.98) scaleX(1.01); }
}
/* 静止时轻微上下浮动 */
.trex-dino:not(.is-jumping):not(.is-ducking) {
  animation: slimeFloat 3s ease-in-out infinite;
}
@keyframes slimeFloat {
  0%, 100% { transform: translateY(0); }
  33% { transform: translateY(-1px); }
  66% { transform: translateY(0); }
}
/* 眨眼 */
.trex-slime-eye {
  animation: slimeBlink 3.5s ease-in-out infinite;
}
@keyframes slimeBlink {
  0%, 96%, 100% { transform: scaleY(1); }
  98% { transform: scaleY(0.1); }
}
.trex-slime-eye {
  position: absolute; width: 9px; height: 10px;
  background: #fff; border-radius: 50%; z-index: 4; top: 7px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.trex-slime-eye.left  { left: 7px; }
.trex-slime-eye.right { left: 23px; }
.trex-slime-pupil {
  position: absolute; top: 2px; left: 3px;
  width: 4px; height: 5px; background: #333; border-radius: 50%;
}
.trex-slime-catchlight {
  position: absolute; top: 1px; left: 1px;
  width: 2px; height: 2px; background: #fff; border-radius: 50%;
}
.trex-slime-smile {
  position: absolute; bottom: 7px; left: 13px;
  width: 14px; height: 5px;
  border-bottom: 2px solid rgba(0,0,0,0.12);
  border-radius: 0 0 50% 50%; z-index: 4;
}
.trex-dino.is-jumping .trex-slime-body {
  animation: none; transform: scaleY(1.25) scaleX(0.85);
  box-shadow: 0 0 30px var(--trex-slime-glow);
}
.trex-dino.is-ducking { transform: scaleY(0.5); transform-origin: bottom center; }
.trex-dino.is-ducking .trex-slime-body { animation: none; }
.trex-dino.slime-land .trex-slime-body { animation: slimeLand 0.2s ease-out; }
@keyframes slimeLand {
  0% { transform: scaleY(0.7) scaleX(1.15); }
  50% { transform: scaleY(1.15) scaleX(0.9); }
  100% { transform: scaleY(1) scaleX(1); }
}

/* ==============================================================
   障碍物 — 魔法水晶（颜色随 data-time 变）
   ============================================================== */
.trex-obstacle {
  position: absolute; z-index: 5; pointer-events: none;
  filter: drop-shadow(0 2px 6px var(--trex-shadow));
  transition: filter 0.5s ease;
}
.trex-crystal {
  width: 18px; height: 40px;
  background: linear-gradient(180deg, var(--trex-crystal-core), var(--trex-crystal-color) 40%, var(--trex-fill-dark) 100%);
  border-radius: 4px 4px 2px 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 0 15px var(--trex-magic-glow);
  clip-path: polygon(50% 0%, 100% 20%, 100% 80%, 50% 100%, 0% 80%, 0% 20%);
  animation: crystalFloat 2s ease-in-out infinite alternate;
  transition: background 0.8s ease, box-shadow 0.8s ease;
}
@keyframes crystalFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-2px); }
}
.trex-crystal::before {
  content: ''; position: absolute; top: 6px; left: 4px;
  width: 4px; height: 12px; background: rgba(255,255,255,0.3);
  border-radius: 2px; transform: rotate(-10deg);
}
.trex-crystal::after {
  content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 6px;
  background: radial-gradient(ellipse, var(--trex-magic-glow) 0%, transparent 70%);
  border-radius: 50%;
}
.trex-crystal-double {
  width: 32px; height: 34px;
  background: linear-gradient(180deg, var(--trex-crystal-core), var(--trex-crystal-color) 35%, var(--trex-fill-dark) 100%);
  border-radius: 4px 4px 2px 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 0 15px var(--trex-magic-glow);
  clip-path: polygon(50% 0%, 100% 15%, 100% 85%, 50% 100%, 0% 85%, 0% 15%);
  animation: crystalFloat 2.4s ease-in-out infinite alternate-reverse;
  transition: background 0.8s ease, box-shadow 0.8s ease;
}
.trex-crystal-double::before {
  content: ''; position: absolute; top: 2px; left: -5px;
  width: 10px; height: 20px;
  background: linear-gradient(180deg, var(--trex-crystal-core), var(--trex-crystal-color));
  border-radius: 2px; box-shadow: 0 0 8px var(--trex-magic-glow);
  clip-path: polygon(50% 0%, 100% 30%, 100% 70%, 50% 100%, 0% 70%, 0% 30%);
}
.trex-crystal-double::after {
  content: ''; position: absolute; bottom: -3px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 5px;
  background: radial-gradient(ellipse, var(--trex-magic-glow) 0%, transparent 70%);
  border-radius: 50%;
}

/* ==============================================================
   精灵龙（颜色随 data-time 变，增强版：更大更亮）
   ============================================================== */
.trex-fairy { z-index: 6; }
.trex-fairy-body {
  position: absolute; left: 10px; top: 8px;
  width: 14px; height: 12px;
  background: var(--trex-fairy-body); border-radius: 50%; z-index: 2;
  box-shadow: 0 0 16px var(--trex-magic-glow), 0 0 30px var(--trex-magic-glow);
  transition: background 0.8s ease;
}
.trex-fairy-wing {
  position: absolute; top: 2px; width: 14px; height: 18px;
  background: var(--trex-fairy-wing); border-radius: 50% 50% 0 50%; z-index: 1;
  animation: fairyFlap 0.12s ease-in-out infinite alternate;
  box-shadow: 0 0 8px var(--trex-magic-glow);
}
.trex-fairy-wing.left  { left: -5px; transform-origin: right center; }
.trex-fairy-wing.right { right: -5px; transform-origin: left center; border-radius: 50% 50% 50% 0; }
@keyframes fairyFlap {
  0% { transform: scaleY(0.4) scaleX(0.8); }
  100% { transform: scaleY(1.2) scaleX(1.1); }
}
.trex-fairy-eye {
  position: absolute; top: 10px; left: 18px;
  width: 3px; height: 3px; background: #333; border-radius: 50%; z-index: 3;
  box-shadow: 0 0 2px rgba(0,0,0,0.2), -10px 0 0 #333;
}
.trex-fairy-glow {
  position: absolute; top: 6px; left: 8px;
  width: 28px; height: 26px;
  background: radial-gradient(ellipse, var(--trex-magic-glow) 0%, transparent 70%);
  border-radius: 50%; z-index: 0;
  animation: fairyGlow 1s ease-in-out infinite alternate;
}
@keyframes fairyGlow {
  0% { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 0.9; transform: scale(1.4); }
}

/* ==============================================================
   分数面板
   ============================================================== */
#trex-score {
  position: absolute; top: 12px; right: 16px; z-index: 20;
  text-align: right;
  background: var(--color-cell-bg, rgba(0,0,0,0.04));
  border-radius: var(--border-radius-md, 6px);
  padding: 4px 12px 6px; min-width: 80px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
#trex-score-value {
  font-size: 18px; font-weight: 700; color: var(--trex-score-color);
  letter-spacing: 2px; font-variant-numeric: tabular-nums;
  font-family: 'Courier New', Courier, monospace;
  display: inline-block; line-height: 1.3;
}
#trex-highscore {
  font-size: 9px; color: var(--color-text-dark, #776e65);
  letter-spacing: 1px; margin-top: 0; line-height: 1.2;
  opacity: 0.5; text-transform: uppercase;
}
.trex-speed-notif {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 25; font-size: 32px; font-weight: 800;
  color: var(--trex-notif-color);
  font-family: 'Clear Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif; letter-spacing: 1px;
  text-shadow: 0 0 20px var(--trex-magic-glow), 0 2px 12px rgba(0,0,0,0.12);
  pointer-events: none; display: none; white-space: nowrap;
}

/* ==============================================================
   遮罩
   ============================================================== */
.trex-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-overlay, rgba(238,228,218,0.73));
  z-index: 30; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.trex-overlay-inner { text-align: center; padding: 32px; max-width: 300px; }
.trex-overlay-title {
  font-size: 28px; font-weight: 700; color: var(--trex-score-color);
  margin: 0 0 12px 0; font-family: var(--font-family, 'Clear Sans', sans-serif); letter-spacing: -0.5px;
}
.trex-overlay-desc {
  font-size: 14px; color: var(--color-text-dark, #776e65);
  margin: 0 0 24px 0; line-height: 1.6; opacity: 0.7;
}
.trex-overlay-score {
  font-size: 40px; font-weight: 800; color: var(--trex-score-color);
  margin: 8px 0; font-family: 'Courier New', Courier, monospace; letter-spacing: 1px;
}
.trex-overlay-highscore {
  font-size: 13px; color: var(--color-text-dark, #776e65);
  margin: 0 0 24px 0; opacity: 0.6;
}
.trex-overlay-btn { margin: 6px auto; min-width: 120px; }
#trex-start-screen { display: flex; }
#trex-gameover-screen { display: none; }
#trex-hint {
  margin-top: 10px; font-size: 12px; color: var(--color-text-dark, #776e65);
  text-align: center; opacity: 0.4; font-family: var(--font-family, 'Clear Sans', sans-serif);
}

/* ==============================================================
   减少动画
   ============================================================== */
@media (prefers-reduced-motion: reduce) {
  .trex-dino, .trex-crystal, .trex-crystal-double, .trex-fairy, .trex-ground,
  .trex-bg-mountains-far, .trex-bg-mountains-near, .trex-bg-clouds,
  .trex-bg-river, #trex-world[data-time="night"] .trex-bg-stars::before,
  #trex-world[data-time="deepnight"] .trex-bg-stars::before,
  #trex-world[data-time="night"] .trex-bg-stars::after {
    animation: none !important; transition: none !important;
  }
}

/* ==============================================================
   响应式
   ============================================================== */
@media (max-width: 640px) {
  #trex-world { width: min(96vw, 480px); height: min(50vh, 280px); }
  .trex-dino { left: 20px; transform: scale(0.82); transform-origin: bottom left; }
  .trex-dino.is-ducking { transform: scale(0.82) scaleY(0.5); transform-origin: bottom left; }
  .trex-crystal { width: 15px; height: 32px; }
  .trex-crystal-double { width: 26px; height: 28px; }
  .trex-fairy-body { width: 10px; height: 8px; }
  #trex-score { padding: 3px 10px 5px; min-width: 64px; top: 10px; right: 12px; }
  #trex-score-value { font-size: 15px; }
  .trex-bg-sunmoon { transform: scale(0.75); transform-origin: top right; }
  .trex-overlay-title { font-size: 22px; }
  .trex-speed-notif { font-size: 26px; }
  #trex-hint { font-size: 11px; margin-top: 6px; }
  .trex-overlay-btn { min-width: 100px; font-size: 14px; padding: 10px 20px; }
  .trex-overlay-inner { padding: 24px; }
  .trex-overlay-score { font-size: 32px; }
}
@media (max-width: 380px) {
  #trex-world { width: 98vw; height: min(44vh, 220px); }
  .trex-dino { left: 14px; transform: scale(0.68); transform-origin: bottom left; }
  .trex-dino.is-ducking { transform: scale(0.68) scaleY(0.5); transform-origin: bottom left; }
  .trex-crystal { width: 12px; height: 26px; }
  .trex-crystal-double { width: 20px; height: 22px; }
  #trex-score { padding: 2px 8px 4px; min-width: 56px; top: 8px; right: 10px; }
  #trex-score-value { font-size: 13px; }
  .trex-overlay-title { font-size: 18px; }
  .trex-overlay-score { font-size: 26px; }
  .trex-speed-notif { font-size: 22px; }
}
