@import url(fonts/clear-sans.css);

/* ========================================
   2048 马年限定版 — 红金中国风 · 斗地主主题
   ======================================== */

/* ===== CSS 变量 ===== */
:root {
  --crimson:       #5c0612;
  --crimson-dark:  #3d0410;
  --crimson-mid:   #8b0000;
  --red:           #c41e3a;
  --red-light:     #e04030;
  --gold:          #ffd700;
  --gold-dark:     #daa520;
  --gold-light:    #ffe44d;
  --cream:         #f9e4c8;
  --white:         #fff;
}

/* ===== 全局 ===== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at center top, #8b1a1a 0%, var(--crimson) 40%, var(--crimson-dark) 100%);
  color: var(--cream);
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  overflow-x: hidden;
  min-height: 100vh;
}

body {
  margin: 70px 0 40px;
}

/* ===== 背景祥云暗纹 ===== */
.bg-clouds {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.04;
  background:
    radial-gradient(ellipse 120px 60px at 15% 20%, var(--gold) 0%, transparent 70%),
    radial-gradient(ellipse 160px 70px at 75% 35%, var(--gold) 0%, transparent 70%),
    radial-gradient(ellipse 100px 50px at 40% 70%, var(--gold) 0%, transparent 70%),
    radial-gradient(ellipse 140px 55px at 85% 80%, var(--gold) 0%, transparent 70%);
}

/* ===== 灯笼 ===== */
.lantern {
  position: fixed;
  top: -10px;
  z-index: 1;
  pointer-events: none;
  animation: lanternSwing 4s ease-in-out infinite;
}
.lantern-left  { left: 20px; animation-delay: 0s; }
.lantern-right { right: 20px; animation-delay: 1.5s; }

@keyframes lanternSwing {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

.lantern-body {
  width: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lantern-top {
  width: 30px; height: 8px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  border-radius: 4px 4px 0 0;
}
.lantern-mid {
  width: 50px; height: 60px;
  background: radial-gradient(ellipse at 40% 35%, #ff4444, #cc0000 60%, #990000);
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
  box-shadow: 0 0 20px rgba(255,60,60,0.4), inset 0 0 15px rgba(255,200,0,0.15);
  position: relative;
}
.lantern-mid::after {
  content: '';
  position: absolute;
  top: 6px; left: 8px;
  width: 14px; height: 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  transform: rotate(-20deg);
}
.lantern-bottom {
  width: 30px; height: 8px;
  background: linear-gradient(180deg, var(--gold-dark), var(--gold));
  border-radius: 0 0 4px 4px;
}
.lantern-tassel {
  width: 2px; height: 25px;
  background: var(--gold);
  margin: 0 auto;
  position: relative;
}
.lantern-tassel::after {
  content: '';
  position: absolute;
  bottom: 0; left: -4px;
  width: 10px; height: 10px;
  background: var(--gold);
  border-radius: 50%;
}

/* ===== Canvas 粒子层 ===== */
#particleCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* ===== 标题区 ===== */
.heading:after { content:""; display:block; clear:both; }

h1.title {
  font-size: 72px;
  font-weight: 900;
  margin: 0;
  display: block;
  float: left;
  color: var(--gold);
  text-shadow:
    0 0 30px rgba(255,215,0,0.5),
    0 2px 0 var(--gold-dark),
    0 4px 8px rgba(0,0,0,0.5);
  letter-spacing: 2px;
  line-height: 1;
}
.title-icon {
  font-size: 56px;
  margin-right: 4px;
  animation: horseBounce 2s ease-in-out infinite;
}
.title-sub {
  font-size: 28px;
  display: block;
  letter-spacing: 6px;
  color: var(--gold-dark);
  margin-top: -2px;
}

@keyframes horseBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ===== Score boxes ===== */
.scores-container { float: right; text-align: right; display: flex; gap: 8px; }

.score-container, .best-container {
  position: relative;
  background: linear-gradient(135deg, var(--crimson-mid), var(--red));
  border: 2px solid var(--gold);
  padding: 12px 18px;
  font-size: 14px;
  min-width: 80px;
  text-align: center;
  border-radius: 8px;
  color: var(--gold);
  margin-top: 8px;
  box-shadow:
    0 0 12px rgba(255,215,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 4px 12px rgba(0,0,0,0.3);
}

.score-inner, .best-inner {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.score-container::before, .best-container::before {
  content: attr(data-label);
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  color: var(--gold-dark);
  letter-spacing: 1px;
  background: var(--crimson-mid);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--gold-dark);
}
.score-container::before { content: "SCORE"; }
.best-container::before  { content: "BEST"; }

.score-container .score-addition, .best-container .score-addition {
  position: absolute;
  right: 50%;
  transform: translateX(50%);
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  z-index: 100;
  animation: move-up 600ms ease-in;
  animation-fill-mode: both;
  text-shadow: 0 0 8px rgba(255,215,0,0.6);
}

@keyframes move-up {
  0%   { top: 25px; opacity: 1; }
  100% { top: -40px; opacity: 0; }
}

p { margin-top: 0; margin-bottom: 10px; line-height: 1.65; }

a {
  color: var(--cream);
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}
strong.important { text-transform: uppercase; }
hr {
  border: none;
  border-bottom: 1px solid rgba(255,215,0,0.2);
  margin: 20px 0 30px;
}

.container {
  width: 500px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

@keyframes fade-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ===== 游戏容器 ===== */
.game-container {
  margin-top: 30px;
  position: relative;
  padding: 15px;
  cursor: default;
  touch-action: none;
  background:
    linear-gradient(145deg, rgba(139,0,0,0.95), rgba(160,16,32,0.9));
  border: 3px solid var(--gold);
  border-radius: 12px;
  width: 500px;
  height: 500px;
  box-shadow:
    0 0 0 1px rgba(255,215,0,0.1),
    0 0 40px rgba(255,215,0,0.15),
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 0 60px rgba(0,0,0,0.25);
}

.game-container::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px; bottom: -1px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--gold) 0%, transparent 30%, transparent 70%, var(--gold) 100%);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* 游戏结束/胜利覆盖 */
.game-container .game-message {
  display: none;
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(61,4,16,0.88);
  border-radius: 10px;
  z-index: 100;
  text-align: center;
  animation: fade-in 800ms ease 1200ms;
  animation-fill-mode: both;
  backdrop-filter: blur(4px);
}
.game-container .game-message p {
  font-size: 60px;
  font-weight: 900;
  height: 60px;
  line-height: 60px;
  margin-top: 200px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
}
.game-container .game-message .lower { display: block; margin-top: 59px; }
.game-container .game-message a {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border-radius: 6px;
  padding: 0 24px;
  text-decoration: none;
  color: var(--crimson);
  height: 44px;
  line-height: 46px;
  margin-left: 9px;
  font-weight: 900;
  box-shadow: 0 0 15px rgba(255,215,0,0.3), 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s;
}
.game-container .game-message a:hover {
  box-shadow: 0 0 25px rgba(255,215,0,0.6);
  transform: translateY(-1px);
}
.game-container .game-message a.keep-playing-button { display: none; }
.game-container .game-message.game-won {
  background: rgba(255,215,0,0.15);
}
.game-container .game-message.game-won a.keep-playing-button { display: inline-block; }
.game-container .game-message.game-won,
.game-container .game-message.game-over { display: block; }

/* ===== Grid ===== */
.grid-container { position: absolute; z-index: 1; }

.grid-row { margin-bottom: 15px; }
.grid-row:last-child { margin-bottom: 0; }
.grid-row:after { content:""; display:block; clear:both; }

.grid-cell {
  width: 106.25px;
  height: 106.25px;
  margin-right: 15px;
  float: left;
  border-radius: 8px;
  background: rgba(255,215,0,0.06);
  border: 1px solid rgba(255,215,0,0.1);
}

.grid-cell:last-child { margin-right: 0; }

.tile-container { position: absolute; z-index: 2; }

/* ===== Tile Positions ===== */
.tile, .tile .tile-inner { width: 107px; height: 107px; line-height: 107px; }
.tile.tile-position-1-1 { transform: translate(0px, 0px); }
.tile.tile-position-1-2 { transform: translate(0px, 121px); }
.tile.tile-position-1-3 { transform: translate(0px, 242px); }
.tile.tile-position-1-4 { transform: translate(0px, 363px); }
.tile.tile-position-2-1 { transform: translate(121px, 0px); }
.tile.tile-position-2-2 { transform: translate(121px, 121px); }
.tile.tile-position-2-3 { transform: translate(121px, 242px); }
.tile.tile-position-2-4 { transform: translate(121px, 363px); }
.tile.tile-position-3-1 { transform: translate(242px, 0px); }
.tile.tile-position-3-2 { transform: translate(242px, 121px); }
.tile.tile-position-3-3 { transform: translate(242px, 242px); }
.tile.tile-position-3-4 { transform: translate(242px, 363px); }
.tile.tile-position-4-1 { transform: translate(363px, 0px); }
.tile.tile-position-4-2 { transform: translate(363px, 121px); }
.tile.tile-position-4-3 { transform: translate(363px, 242px); }
.tile.tile-position-4-4 { transform: translate(363px, 363px); }

.tile {
  position: absolute;
  transition: 100ms ease-in-out;
  transition-property: transform;
}

/* ===== Tile 内部 — 红金渐变质感 ===== */
.tile .tile-inner {
  border-radius: 8px;
  text-align: center;
  font-weight: 900;
  z-index: 10;
  font-size: 55px;
  position: relative;
  overflow: hidden;
}

/* 瓷砖光泽伪元素 */
.tile .tile-inner::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%);
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

.tile.tile-2 .tile-inner {
  background: linear-gradient(135deg, #a52a2a, #7a1a1a);
  color: var(--gold);
  box-shadow: 0 3px 0 #5a0a0a, 0 6px 16px rgba(0,0,0,0.3);
  border: 2px solid rgba(255,215,0,0.2);
}
.tile.tile-4 .tile-inner {
  background: linear-gradient(135deg, #b83030, #8b2020);
  color: var(--gold);
  box-shadow: 0 3px 0 #600e0e, 0 6px 16px rgba(0,0,0,0.3);
  border: 2px solid rgba(255,215,0,0.25);
}
.tile.tile-8 .tile-inner {
  background: linear-gradient(135deg, #c41e3a, #a01020);
  color: var(--gold);
  box-shadow: 0 3px 0 #701018, 0 6px 18px rgba(0,0,0,0.35);
  border: 2px solid rgba(255,215,0,0.3);
}
.tile.tile-16 .tile-inner {
  background: linear-gradient(135deg, #d4372c, #b01c1c);
  color: var(--white);
  box-shadow: 0 3px 0 #801010, 0 8px 20px rgba(0,0,0,0.35);
  border: 2px solid rgba(255,215,0,0.35);
}
.tile.tile-32 .tile-inner {
  background: linear-gradient(135deg, #e04030, #c42020);
  color: var(--white);
  box-shadow: 0 3px 0 #901818, 0 8px 22px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,215,0,0.4);
}
.tile.tile-64 .tile-inner {
  background: linear-gradient(135deg, #ff4500, #cc2200);
  color: var(--white);
  box-shadow: 0 4px 0 #991800, 0 8px 24px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,215,0,0.5);
}
.tile.tile-128 .tile-inner {
  background: linear-gradient(135deg, #daa520, #b8860b);
  color: var(--crimson);
  font-size: 45px;
  box-shadow: 0 0 24px rgba(255,215,0,0.3), 0 4px 0 #8a6508, 0 8px 24px rgba(0,0,0,0.4);
  border: 2px solid var(--gold);
}
.tile.tile-256 .tile-inner {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--crimson);
  font-size: 45px;
  box-shadow: 0 0 30px rgba(255,215,0,0.4), 0 4px 0 #a0800a, 0 8px 28px rgba(0,0,0,0.4);
  border: 2px solid var(--white);
}
.tile.tile-512 .tile-inner {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--crimson);
  font-size: 45px;
  box-shadow: 0 0 36px rgba(255,215,0,0.5), 0 4px 0 var(--gold-dark), 0 8px 28px rgba(0,0,0,0.4);
  border: 2px solid var(--white);
  animation: tile512Glow 2s ease-in-out infinite;
}
@keyframes tile512Glow {
  0%, 100% { box-shadow: 0 0 36px rgba(255,215,0,0.5), 0 4px 0 var(--gold-dark), 0 8px 28px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 50px rgba(255,215,0,0.8), 0 4px 0 var(--gold-dark), 0 8px 28px rgba(0,0,0,0.4); }
}
.tile.tile-1024 .tile-inner {
  background: linear-gradient(135deg, var(--gold), #ff8c00);
  color: var(--crimson);
  font-size: 35px;
  box-shadow: 0 0 45px rgba(255,215,0,0.6), 0 4px 0 #b0700a, 0 8px 30px rgba(0,0,0,0.4);
  border: 3px solid var(--white);
  animation: tile1024Glow 1.5s ease-in-out infinite;
}
@keyframes tile1024Glow {
  0%, 100% { box-shadow: 0 0 45px rgba(255,215,0,0.6), 0 4px 0 #b0700a, 0 8px 30px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 70px rgba(255,215,0,1), 0 4px 0 #b0700a, 0 8px 30px rgba(0,0,0,0.4); }
}
.tile.tile-2048 .tile-inner {
  background: linear-gradient(135deg, var(--gold), #ff4500);
  color: var(--white);
  font-size: 35px;
  box-shadow: 0 0 55px rgba(255,215,0,0.8), 0 4px 0 #b0700a, 0 8px 30px rgba(0,0,0,0.4);
  border: 3px solid var(--white);
}
.tile.tile-super .tile-inner {
  background: linear-gradient(135deg, var(--gold), #ff4500);
  color: var(--white);
  font-size: 30px;
  border: 3px solid var(--white);
}

/* ===== Tile 出现 / 合并动画 ===== */
@keyframes appear {
  0%   { opacity:0; transform: scale(0); }
  100% { opacity:1; transform: scale(1); }
}
@keyframes pop {
  0%   { transform: scale(0); }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.tile-new .tile-inner {
  animation: appear 200ms ease 100ms;
  animation-fill-mode: backwards;
}
.tile-merged .tile-inner {
  z-index: 20;
  animation: pop 200ms ease 100ms;
  animation-fill-mode: backwards;
}

/* ===== Above-game 按钮区 ===== */
.above-game:after { content:""; display:block; clear:both; }
.game-intro { float: left; line-height: 42px; margin-bottom: 0; font-size: 15px; color: rgba(249,228,200,0.8); }
.game-intro strong { color: var(--gold); }

.btn-group { float: right; display: flex; gap: 8px; align-items: center; }

.restart-button, .undo-button {
  display: inline-block;
  border-radius: 8px;
  padding: 0 18px;
  text-decoration: none;
  height: 40px;
  line-height: 42px;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.restart-button {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--crimson);
  box-shadow: 0 2px 0 var(--gold-dark), 0 4px 12px rgba(0,0,0,0.3);
}
.restart-button:hover {
  box-shadow: 0 2px 0 var(--gold-dark), 0 0 20px rgba(255,215,0,0.4);
  transform: translateY(-1px);
}
.restart-button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--gold-dark);
}

.undo-button {
  background: linear-gradient(135deg, var(--red), var(--crimson-mid));
  color: var(--gold);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 0 var(--crimson-dark), 0 4px 12px rgba(0,0,0,0.3);
  animation: undoPulse 3s ease-in-out infinite;
}
@keyframes undoPulse {
  0%, 100% { box-shadow: 0 2px 0 var(--crimson-dark), 0 4px 12px rgba(0,0,0,0.3); }
  50%      { box-shadow: 0 2px 0 var(--crimson-dark), 0 0 20px rgba(255,215,0,0.3); }
}
.undo-button:hover {
  box-shadow: 0 2px 0 var(--crimson-dark), 0 0 25px rgba(255,215,0,0.5);
  transform: translateY(-1px);
}
.undo-button.hidden { display: none !important; }

.footer-info { margin-top: 30px; }
.game-explanation { color: rgba(249,228,200,0.7); font-size: 15px; }
.game-explanation strong { color: var(--gold); }

/* ===== 512 圣旨卷轴 ===== */
.scroll-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(61,4,16,0.9);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fade-in 0.4s ease;
  backdrop-filter: blur(6px);
}
.scroll-overlay.hidden { display: none; }

.scroll-wrapper { perspective: 800px; }

.scroll-box {
  background:
    linear-gradient(180deg, #8b0000 0%, var(--red) 8%, var(--red) 92%, #8b0000 100%);
  border: 4px solid var(--gold);
  border-radius: 10px;
  padding: 30px 50px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,215,0,0.3), inset 0 0 40px rgba(0,0,0,0.3);
  min-width: 400px;
  position: relative;
  animation: scrollUnroll 0.8s cubic-bezier(0.22,1,0.36,1) forwards;
  transform-origin: center top;
}
@keyframes scrollUnroll {
  0%   { transform: scaleY(0); opacity: 0; }
  100% { transform: scaleY(1); opacity: 1; }
}

.scroll-seal {
  position: absolute;
  top: -16px; left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: var(--crimson);
  font-size: 14px;
  font-weight: 900;
  padding: 3px 16px;
  border-radius: 4px;
  letter-spacing: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 1px solid var(--gold-dark);
}

.scroll-top-rod, .scroll-bottom-rod {
  width: 110%;
  height: 14px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark), var(--gold));
  border-radius: 7px;
  margin-left: -5%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.scroll-top-rod { margin-bottom: 24px; }
.scroll-bottom-rod { margin-top: 24px; }

.scroll-divider {
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 12px auto;
}

.scroll-main-text {
  font-size: 34px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  animation: glowPulse 1.5s ease-in-out infinite;
  margin-bottom: 8px;
}
.scroll-sub-text {
  font-size: 28px;
  color: var(--white);
  margin-bottom: 6px;
  text-shadow: 0 0 10px rgba(255,255,255,0.3);
}
.scroll-sub-text2 {
  font-size: 22px;
  color: var(--cream);
}
.scroll-hint {
  margin-top: 30px;
  color: var(--gold-dark);
  font-size: 14px;
  animation: blink 1.2s ease-in-out infinite;
  letter-spacing: 2px;
}

@keyframes glowPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(255,215,0,0.5); }
  50%      { text-shadow: 0 0 40px rgba(255,215,0,0.9), 0 0 80px rgba(255,215,0,0.3); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ===== 1024 福袋 ===== */
.lucky-bag {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10002;
  cursor: pointer;
  animation: bagAppear 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.lucky-bag.hidden { display: none; }
@keyframes bagAppear {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

.bag-inner {
  width: 160px; height: 180px;
  background: linear-gradient(180deg, #ff4500 0%, var(--red) 35%, var(--crimson-mid) 100%);
  border: 4px solid var(--gold);
  border-radius: 18px 18px 50% 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 0 50px rgba(255,215,0,0.4), 0 12px 40px rgba(0,0,0,0.6);
}
.bag-text {
  font-size: 72px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 25px rgba(255,215,0,0.7), 0 2px 0 var(--gold-dark);
}
.bag-inner::before {
  content: '';
  position: absolute;
  top: -18px; left: 50%; transform: translateX(-50%);
  width: 70px; height: 28px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  border-radius: 50% 50% 0 0;
  box-shadow: 0 -4px 12px rgba(255,215,0,0.4);
}
.bag-ribbon-l, .bag-ribbon-r {
  position: absolute;
  top: -8px;
  width: 40px; height: 8px;
  background: var(--gold);
  border-radius: 2px;
}
.bag-ribbon-l { left: -15px; transform: rotate(-25deg); }
.bag-ribbon-r { right: -15px; transform: rotate(25deg); }

/* ===== 最终贺卡 ===== */
.final-card {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(61,4,16,0.94);
  z-index: 10003;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: fade-in 0.5s ease;
  backdrop-filter: blur(6px);
}
.final-card.hidden { display: none; }

.card-border-glow {
  position: absolute;
  width: 520px; height: 360px;
  border-radius: 20px;
  background: conic-gradient(from 0deg, var(--gold), var(--red), var(--gold), var(--red), var(--gold));
  filter: blur(20px);
  opacity: 0.4;
  animation: cardGlowRotate 4s linear infinite;
}
@keyframes cardGlowRotate {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.card-content {
  background: linear-gradient(135deg, var(--red) 0%, var(--crimson-mid) 50%, var(--crimson) 100%);
  border: 4px solid var(--gold);
  border-radius: 16px;
  padding: 45px 55px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,215,0,0.4), 0 20px 60px rgba(0,0,0,0.6);
  animation: cardAppear 0.7s cubic-bezier(0.34,1.56,0.64,1) forwards;
  position: relative;
  z-index: 1;
}
@keyframes cardAppear {
  0%   { transform: scale(0) rotate(-8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.card-top-deco {
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 8px;
  margin-bottom: 16px;
  opacity: 0.6;
}
.card-gold-line {
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 14px auto;
}
.card-line1 {
  font-size: 32px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.5);
  margin-bottom: 4px;
  animation: glowPulse 2s ease-in-out infinite;
}
.card-line2 {
  font-size: 32px;
  font-weight: 900;
  color: var(--white);
  text-shadow: 0 0 15px rgba(255,255,255,0.3);
  animation: glowPulse 2s ease-in-out infinite;
  animation-delay: 0.4s;
}
.card-bottom-deco {
  margin-top: 18px;
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 4px;
  opacity: 0.7;
}
.card-hint {
  margin-top: 24px;
  font-size: 13px;
  color: var(--gold-dark);
  animation: blink 1.2s ease-in-out infinite;
  letter-spacing: 2px;
}

/* ===== 移动端适配 ===== */
@media screen and (max-width: 520px) {
  html, body { font-size: 15px; }
  body { margin: 10px 0 20px; padding: 0 8px; }

  h1.title { font-size: 36px; float: none; text-align: center; }
  .title-icon { font-size: 28px; }
  .title-sub { font-size: 14px; }

  .heading { text-align: center; margin-bottom: 8px; }
  .scores-container { float: none; justify-content: center; margin-top: 8px; }
  .score-container, .best-container { padding: 8px 12px; min-width: 60px; }
  .score-inner, .best-inner { font-size: 20px; }

  .container { width: 300px; }
  .game-intro { width: 100%; float: none; text-align: center; font-size: 13px; margin-bottom: 8px; line-height: 1.4; }
  .btn-group { width: 100%; justify-content: center; float: none; }

  .game-container {
    margin-top: 12px;
    padding: 8px;
    border-width: 2px;
    border-radius: 8px;
    width: 290px;
    height: 290px;
  }
  .game-container .game-message p {
    font-size: 28px !important;
    height: 30px !important;
    line-height: 30px !important;
    margin-top: 85px !important;
  }
  .game-container .game-message .lower { margin-top: 25px !important; }
  .game-container .game-message a { height: 34px; line-height: 36px; font-size: 13px; padding: 0 14px; }

  .grid-row { margin-bottom: 8px; }
  .grid-cell { width: 60.25px; height: 60.25px; margin-right: 8px; }

  .tile, .tile .tile-inner { width: 61px; height: 61px; line-height: 61px; }
  .tile.tile-position-1-1 { transform: translate(0px, 0px); }
  .tile.tile-position-1-2 { transform: translate(0px, 69px); }
  .tile.tile-position-1-3 { transform: translate(0px, 138px); }
  .tile.tile-position-1-4 { transform: translate(0px, 207px); }
  .tile.tile-position-2-1 { transform: translate(69px, 0px); }
  .tile.tile-position-2-2 { transform: translate(69px, 69px); }
  .tile.tile-position-2-3 { transform: translate(69px, 138px); }
  .tile.tile-position-2-4 { transform: translate(69px, 207px); }
  .tile.tile-position-3-1 { transform: translate(138px, 0px); }
  .tile.tile-position-3-2 { transform: translate(138px, 69px); }
  .tile.tile-position-3-3 { transform: translate(138px, 138px); }
  .tile.tile-position-3-4 { transform: translate(138px, 207px); }
  .tile.tile-position-4-1 { transform: translate(207px, 0px); }
  .tile.tile-position-4-2 { transform: translate(207px, 69px); }
  .tile.tile-position-4-3 { transform: translate(207px, 138px); }
  .tile.tile-position-4-4 { transform: translate(207px, 207px); }

  .tile .tile-inner { font-size: 30px; border-radius: 6px; }
  .tile.tile-128 .tile-inner, .tile.tile-256 .tile-inner, .tile.tile-512 .tile-inner { font-size: 22px; }
  .tile.tile-1024 .tile-inner, .tile.tile-2048 .tile-inner { font-size: 16px; }

  .scroll-box { min-width: 260px; padding: 20px 24px; }
  .scroll-main-text { font-size: 22px; }
  .scroll-sub-text { font-size: 18px; }
  .scroll-sub-text2 { font-size: 16px; }

  .card-content { padding: 28px 20px; }
  .card-line1, .card-line2 { font-size: 20px; }

  .lantern { display: none; }
}
