@font-face {
  font-family: 'Mojang';
  src: url('../font/mojang.woff2') format('woff2'),
       local('Courier New'), local('Monospace');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* { 
  box-sizing: border-box; 
  user-select: none; 
  -webkit-tap-highlight-color: transparent; 
  font-family: 'Mojang', 'Courier New', monospace !important; 
}

html { overscroll-behavior: none; overflow-x: hidden; }

body {
  margin: 0; min-height: 100vh;
  background-color: #1a1a1a;
  background-image: url('../pictures/homebackground.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  display: flex; justify-content: center; align-items: center;
  padding: 10px; overflow-y: auto; overflow-x: hidden;
  position: relative;
  overscroll-behavior: none;
  touch-action: pan-y;
}

body::before { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 0; pointer-events: none; }
.hidden { display: none !important; }

.particle-bg { position: fixed; background: rgba(255, 255, 200, 0.9); pointer-events: none; z-index: 1; animation: floatUp linear infinite; will-change: transform; transform: translateZ(0); }
@keyframes floatUp {
  0% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); opacity: 0; }
  20% { opacity: 0.8; }
  80% { opacity: 0.8; }
  100% { transform: translate3d(0, -100vh, 0) scale(1.2) rotate(45deg); opacity: 0; }
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 4px); }
  40% { transform: translate(4px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}
.screen-shake { animation: screenShake 0.25s cubic-bezier(.36,.07,.19,.97) both; }

.top-actions {
  position: absolute; top: 20px; left: 20px; right: 20px;
  display: flex; justify-content: space-between; align-items: flex-start;
  z-index: 9999; pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}
.left-actions, .right-actions { display: flex; gap: 10px; pointer-events: auto; }
.float-btn {
  background: #6c6c6c; border: 2px solid #000; color: #fff;
  height: 44px; padding: 0 16px; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000;
  transition: all 0.05s; font-size: 16px; font-weight: bold; text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}
.float-btn:active { background: #fff; color: #000; transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; text-shadow: none; }
.icon-btn { width: 44px; padding: 0; font-size: 22px; }
.icon-btn img { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.icon-btn:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; transform: none; }

.global-energy {
  height: 44px; display: flex; align-items: center; gap: 8px;
  padding: 0 14px; border-radius: 4px; background: rgba(32, 32, 32, 0.9);
  border: 2px solid #000; box-shadow: 0 0 0 2px #555;
  font-weight: bold; color: #fff; font-size: 15px; text-shadow: 1px 1px 0 #000;
}
.energy-icon { width: 24px; height: 24px; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.energy-info { display: flex; flex-direction: column; line-height: 1.2; }
.energy-val { color: #ffd93d; font-size: 15px; }
.energy-timer { font-size: 10px; color: #aaa; margin-top: 2px; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.shake { animation: shake 0.3s ease; }

.main-wrapper {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 520px; z-index: 2;
  margin-top: 75px; margin-bottom: 30px;
}

.menu-title-wrap {
  position: relative; display: flex; justify-content: center; align-items: center;
  width: 90%; max-width: 360px; margin: 0 auto 20px;
}
.menu-title-wrap::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: 115%; height: 130%;
  background: radial-gradient(ellipse at center, rgba(255, 220, 100, 0.55), transparent 70%);
  z-index: 0; opacity: 0.5; animation: titleGlow 2.5s ease-in-out infinite;
  pointer-events: none; will-change: opacity;
}
@keyframes titleGlow { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.menu-title-img {
  position: relative; z-index: 1; max-width: 100%; height: auto; display: block;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 #000) drop-shadow(-2px -2px 0 #000) drop-shadow(2px -2px 0 #000) drop-shadow(-2px 2px 0 #000);
}

.mc-panel {
  position: relative; background: rgba(32, 32, 32, 0.85); 
  border-radius: 4px; border: 2px solid #000;
  box-shadow: 0 0 0 2px #555, 0 10px 30px rgba(0, 0, 0, 0.8), inset 0 0 0 2px #111;
  width: 100%; display: flex; flex-direction: column; overflow: hidden;
}
#gamePage .mc-panel { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#homePage .mc-panel { background: rgba(26, 26, 26, 0.96); }

.panel-title {
  position: relative; background: #4a4a4a; color: #fff; text-align: center; padding: 12px;
  font-size: 1.3rem; font-weight: bold; letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000; border-bottom: 2px solid #111; box-shadow: inset 0 2px 0 #7a7a7a;
}

.panel-body { padding: 12px 10px; display: flex; flex-direction: column; gap: 12px; }
#homePage .panel-body { padding: 16px 12px 12px 12px; gap: 10px; }

.continue-btn {
  width: 100%; padding: 14px 0;
  background: linear-gradient(180deg, #6fddab, #3ec98a);
  border: 2px solid #000; border-radius: 4px; color: #fff;
  font-size: 16px; font-weight: bold; text-shadow: 1px 1px 0 #000; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000;
  transition: all 0.05s; font-family: inherit; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.continue-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; }

/* PVP 按钮 */
.pvp-btn {
  width: 100%; padding: 12px 0;
  background: linear-gradient(180deg, #e06666, #c0392b);
  border: 2px solid #000; border-radius: 4px; color: #fff;
  font-size: 15px; font-weight: bold; text-shadow: 1px 1px 0 #000; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000;
  transition: all 0.05s; font-family: inherit; letter-spacing: 1px;
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px;
  position: relative; 
  overflow: hidden;
  min-height: 48px;
}
.pvp-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; }

.pvp-gif-cover {
  position: absolute;
  top: 0; 
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none; 
  z-index: 1; 
  image-rendering: pixelated;
}

.pvp-text {
  position: relative;
  z-index: 2;
  pointer-events: none;
  text-shadow: 1px 1px 2px #000, -1px -1px 2px #000;
}

.home-total-progress {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: rgba(16, 16, 16, 0.7); border: 2px solid #000; border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 1px #333; flex-shrink: 0;
}
.home-total-label {
  font-size: 12px; font-weight: bold; color: #ffd93d; text-shadow: 1px 1px 0 #000;
  white-space: nowrap; display: flex; align-items: center; gap: 4px;
}
.home-total-bar {
  flex: 1; height: 6px; background: rgba(0,0,0,0.7); border: 1px solid #333;
  border-radius: 0; overflow: hidden; min-width: 40px;
}
.home-total-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #ffd93d, #ff9f43);
  box-shadow: 0 0 6px rgba(255, 200, 60, 0.7);
  transition: width 0.5s cubic-bezier(0.2, 0.9, 0.3, 1); border-radius: 0;
}
.home-total-text {
  font-size: 12px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000;
  white-space: nowrap; display: flex; align-items: center; gap: 2px;
}

.inline-star { width: 1em; height: 1em; object-fit: contain; image-rendering: pixelated; vertical-align: middle; display: inline-block; margin: 0 1px; margin-top: -2px; pointer-events: none; }
.inline-icon { width: 1.2em; height: 1.2em; object-fit: contain; image-rendering: pixelated; vertical-align: middle; display: inline-block; margin: 0 2px; margin-top: -2px; pointer-events: none; filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.6)); }
.inline-confirm { width: 1em; height: 1em; object-fit: contain; image-rendering: pixelated; vertical-align: middle; display: inline-block; margin-left: 3px; margin-top: -3px; pointer-events: none; filter: drop-shadow(0 0 4px rgba(111, 221, 171, 0.9)); }
.inline-lock { width: 1em; height: 1em; object-fit: contain; image-rendering: pixelated; vertical-align: middle; display: inline-block; margin-left: 4px; margin-top: -2px; pointer-events: none; }

#chapterView { display: flex; flex-direction: column; }

.chapter-nav { display: flex; align-items: center; gap: 8px; padding: 2px 0 0 0; }
.chapter-nav-btn {
  flex: 1; padding: 4px 0; background: #6c6c6c; border: 2px solid #000; border-radius: 4px;
  color: #fff; font-size: 13px; font-weight: bold; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 3px 0 #000;
  transition: all 0.05s; font-family: inherit; text-shadow: 1px 1px 0 #000;
}
.chapter-nav-btn:active:not(:disabled) {
  transform: translateY(3px); background: #fff; color: #000;
  box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; text-shadow: none;
}
.chapter-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chapter-nav-indicator {
  min-width: 52px; text-align: center; color: #fff; font-size: 12px; font-weight: bold;
  text-shadow: 1px 1px 0 #000; background: rgba(0,0,0,0.4); padding: 4px 8px;
  border-radius: 4px; border: 2px solid #222; box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.chapter-card {
  background: rgba(24, 24, 24, 0.85); border: 2px solid #444; border-radius: 6px; padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: border-color 0.2s;
}

.chapter-card[data-theme="base"]    { border-color: rgba(120, 200, 120, 0.55); }
.chapter-card[data-theme="base"]    .chapter-header { background: linear-gradient(90deg, #5a9a5a, #3a7a3a); }
.chapter-card[data-theme="ice"]     { border-color: rgba(100, 180, 255, 0.55); }
.chapter-card[data-theme="ice"]     .chapter-header { background: linear-gradient(90deg, #4a90e2, #2c5f8a); }
.chapter-card[data-theme="lava"]    { border-color: rgba(255, 120, 80, 0.55); }
.chapter-card[data-theme="lava"]    .chapter-header { background: linear-gradient(90deg, #d9553a, #8a3520); }
.chapter-card[data-theme="diamond"] { border-color: rgba(170, 120, 255, 0.55); }
.chapter-card[data-theme="diamond"] .chapter-header { background: linear-gradient(90deg, #8a5fd9, #5a3fa0); }

.chapter-card.locked-chapter[data-theme="base"]    { border-color: rgba(120, 200, 120, 0.18); }
.chapter-card.locked-chapter[data-theme="ice"]     { border-color: rgba(100, 180, 255, 0.18); }
.chapter-card.locked-chapter[data-theme="lava"]    { border-color: rgba(255, 120, 80, 0.18); }
.chapter-card.locked-chapter[data-theme="diamond"] { border-color: rgba(170, 120, 255, 0.18); }

.chapter-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; margin-bottom: 8px; border: 2px solid #000; border-radius: 4px;
  color: #fff; font-weight: bold; font-size: 15px; text-shadow: 1px 1px 0 #000;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
.chapter-title { display: inline-flex; align-items: center; gap: 6px; }
.chapter-icon { width: 1.4em; height: 1.4em; object-fit: contain; image-rendering: pixelated; pointer-events: none; filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.7)); flex-shrink: 0; }
.chapter-progress {
  color: #ffd93d; font-size: 12px; background: rgba(0,0,0,0.4); padding: 2px 8px; border-radius: 10px;
  display: flex; align-items: center; gap: 2px;
}

.chapter-progress-bar {
  height: 4px; background: rgba(0,0,0,0.55); border-radius: 0; margin: 0 4px 10px 4px;
  overflow: hidden; position: relative;
}
.chapter-progress-fill {
  height: 100%; background: linear-gradient(90deg, #ffd93d, #ff9f43); border-radius: 0;
  transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1); box-shadow: 0 0 4px rgba(255, 200, 60, 0.6);
}

.locked-chapter { opacity: 0.6; }
.locked-chapter .chapter-header { background: linear-gradient(90deg, #333, #222) !important; }
.chapter-lock-msg {
  color: #999; font-size: 12px; text-align: center; padding: 14px 8px;
  text-shadow: 1px 1px 0 #000; display: flex; align-items: center; justify-content: center;
}

.grid-container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grid-item {
  background: #6c6c6c; border: 2px solid #000; color: #fff; padding: 10px 2px; border-radius: 4px;
  font-weight: bold; cursor: pointer; text-align: center; position: relative;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000;
  text-shadow: 1px 1px 0 #000; transition: all 0.05s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1.2;
}
.grid-item:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2); background: #fff; color: #000; text-shadow: none; }
.grid-item.locked { background: #333; color: #777; box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 4px 0 #111; cursor: not-allowed; }
.grid-item.locked:active { transform: none; box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 4px 0 #111; }
.grid-item .lock-icon { font-size: 20px; }

.grid-item .stars { display: flex; gap: 2px; height: 16px; margin-top: 4px; justify-content: center; }
.grid-item .stars img { width: 14px; height: 14px; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.grid-item .stars .star-gray { filter: grayscale(1) opacity(0.3); }

.hud-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 2px; }
.goal-box {
  flex: 1.2; background: #222; border: 2px solid #000; border-radius: 4px; padding: 6px 10px;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.1); display: flex; flex-direction: column; justify-content: center;
}
.goal-box.hidden-goal { display: none; }
.goal-title { font-size: 11px; color: #aaa; line-height: 1.1; margin-bottom: 4px; }
.goal-data { display: flex; align-items: center; gap: 6px; }
.goal-icon { width: 26px; height: 26px; background-size: contain; background-position: center; background-repeat: no-repeat; image-rendering: pixelated; }
.goal-num { font-size: 18px; font-weight: bold; color: #fff; line-height: 1; display: flex; align-items: center; }
.goal-num.goal-complete { color: #6fddab !important; animation: goalCompletePulse 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.5) 1; }
@keyframes goalCompletePulse {
  0% { transform: scale(1); text-shadow: none; }
  45% { transform: scale(1.22); text-shadow: 0 0 12px #6fddab, 0 0 4px #fff; }
  100% { transform: scale(1); text-shadow: 0 0 4px rgba(111, 221, 171, 0.6); }
}

.stats-group { flex: 1; display: flex; gap: 8px; }
.stat-box {
  flex: 1; background: #222; border: 2px solid #000; border-radius: 4px;
  color: #aaa; font-size: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 0; box-shadow: inset 0 2px 0 rgba(255,255,255,0.1); transition: transform 0.2s;
}
.stat-box span { font-size: 18px; font-weight: bold; color: #fff; margin-top: 2px; transition: color 0.2s; }

#movesBox.moves-warn span { color: #ff9f43 !important; }
#movesBox.moves-danger span { color: #ff5555 !important; animation: movesPulse 0.8s ease-in-out infinite; }
@keyframes movesPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.65; } }

.progress-bar-wrap { display: flex; align-items: center; gap: 6px; }
.progress-bar { flex: 1; position: relative; height: 20px; background: #222; border: 2px solid #000; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #6fddab, #3ec98a); transition: width 0.25s; position: relative; z-index: 1; }
.progress-star { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 15px; height: 15px; object-fit: contain; image-rendering: pixelated; z-index: 2; pointer-events: none; filter: grayscale(1) brightness(0.4) opacity(0.55); transition: filter 0.3s; }
.progress-star.reached { filter: none; animation: starReach 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.5); }
@keyframes starReach { 0% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.6); } 100% { transform: translate(-50%, -50%) scale(1); } }
.progress-text {
  flex-shrink: 0; font-size: 11px; font-weight: bold; color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  line-height: 1; white-space: nowrap; pointer-events: none;
}

/* PVP 对手 HUD */
.pvp-hud {
  display: none; background: rgba(255, 85, 85, 0.2); border: 2px solid #ff5555; border-radius: 4px;
  padding: 4px 8px; font-size: 12px; color: #fff; text-shadow: 1px 1px 0 #000;
  justify-content: space-between; align-items: center; margin-bottom: 4px;
}
.pvp-hud.active { display: flex; }
.pvp-hud span { font-size: 16px; font-weight: bold; color: #ffd93d; transition: transform 0.2s; }
.pvp-score-bump { animation: scoreBump 0.3s ease; }
@keyframes scoreBump { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }

#board-wrap { 
  display: flex; justify-content: center; margin: 4px auto; background-color: #101010; border-radius: 4px; border: 2px solid #000;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.9), 0 0 0 2px #555; padding: 4px; width: fit-content;
}
#board { position: relative; background-color: transparent; overflow: hidden; touch-action: none; }

.tile {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); will-change: transform;
}
.tile .face {
  position: absolute; inset: 2px; border-radius: 4px; background-color: #2c2c2c; cursor: pointer; overflow: hidden;
  box-shadow: inset 1px 1px 0 rgba(255,255,255,0.1), inset -1px -1px 0 rgba(0,0,0,0.6), 0 1px 0 rgba(0,0,0,0.8);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.tile.drag-target .face { box-shadow: inset 1px 1px 0 rgba(255,255,255,0.1), inset -1px -1px 0 rgba(0,0,0,0.6), 0 1px 0 rgba(0,0,0,0.8), 0 0 0 2px #55aaff, 0 0 12px rgba(85,170,255,0.9); transform: scale(1.04); }
.tile.forming .face { animation: formTile 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4) both; }
@keyframes formTile { 0% { transform: scale(0.3); opacity: 0.4; filter: brightness(2.5) drop-shadow(0 0 20px #fff); } 50% { transform: scale(1.25); opacity: 1; filter: brightness(1.8) drop-shadow(0 0 12px #ffd93d); } 100% { transform: scale(1); opacity: 1; filter: brightness(1); } }

.tile.colorblind .face::after { display: flex !important; position: absolute; inset: 0; align-items: center; justify-content: center; font-size: calc(var(--cell) * 0.5); font-weight: 900; pointer-events: none; z-index: 4; text-shadow: 0 0 4px #000, 0 0 2px #000; }
.tile.colorblind[data-mark="0"] .face::after { content: '●'; color: rgba(255,255,255,0.85); }
.tile.colorblind[data-mark="1"] .face::after { content: '▲'; color: rgba(255,140,50,0.95); }
.tile.colorblind[data-mark="2"] .face::after { content: '★'; color: rgba(80,230,255,0.95); }
.tile.colorblind[data-mark="3"] .face::after { content: '◆'; color: rgba(255,215,61,0.95); }
.tile.colorblind[data-mark="4"] .face::after { content: '■'; color: rgba(220,220,220,0.9); }
.tile.colorblind[data-mark="5"] .face::after { content: '✦'; color: rgba(170,120,255,0.95); }

.tile-img { position: absolute; width: 85%; height: 85%; top: 50%; left: 50%; transform: translate(-50%, -50%); object-fit: contain; image-rendering: pixelated; pointer-events: none; filter: drop-shadow(1px 2px 0 rgba(0,0,0,0.5)); transition: opacity 0.2s; display: none; }

.tile.dir-h .tile-img, .tile.dir-v .tile-img { animation: lineGoldPulse 1.4s ease-in-out infinite alternate; }
@keyframes lineGoldPulse { 0% { filter: drop-shadow(1px 2px 0 rgba(0,0,0,0.5)) drop-shadow(0 0 1px rgba(255,215,61,0.4)) brightness(0.98); } 100% { filter: drop-shadow(1px 2px 0 rgba(0,0,0,0.5)) drop-shadow(0 0 6px rgba(255,215,61,1)) drop-shadow(0 0 10px rgba(255,180,60,0.75)) brightness(1.15); } }

.tile.dir-h::after, .tile.dir-v::after {
  position: absolute; left: 50%; bottom: 1px; transform: translateX(-50%); pointer-events: none; z-index: 6;
  font-family: 'Mojang', monospace; font-weight: 900; font-size: calc(var(--cell) * 0.22); line-height: 1; letter-spacing: 0; color: #fff;
  text-shadow: 0 0 4px rgba(255,255,255,0.9), 0 0 8px rgba(255,255,255,0.6), 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  animation: arrowFlash 0.85s ease-in-out infinite alternate; white-space: nowrap;
}
.tile.dir-h::after { content: '◀▶'; }
.tile.dir-v::after { content: '▲▼'; }
@keyframes arrowFlash { 0% { opacity: 0.4; } 100% { opacity: 1; } }

.tile .face.type-bomb::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(circle at 50% 50%, #ffffff 0%, #ffe066 20%, #ff7043 46%, rgba(60,20,0,0.42) 66%, transparent 72%); animation: bombPulse 0.85s infinite alternate; }
@keyframes bombPulse { 0% { opacity: 0.7; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1.1); } }
.tile .face.type-rainbow { background: conic-gradient(from 0deg, #ff6b6b, #ffd93d, #51cf66, #4ecdc4, #a78bfa, #ff9f43, #ff6b6b); animation: rainbowHue 2.4s linear infinite; }
@keyframes rainbowHue { 0% { filter: hue-rotate(0deg) saturate(1.15); } 100% { filter: hue-rotate(360deg) saturate(1.15); } }

.tile.shuffling .face { animation: shuffleAnim 0.5s cubic-bezier(0.4, 0.0, 0.2, 1); }
@keyframes shuffleAnim { 0% { transform: scale(1) rotate(0deg); } 50% { transform: scale(0.55) rotate(180deg); opacity: 0.4; } 100% { transform: scale(1) rotate(360deg); opacity: 1; } }

.tile .ice { position: absolute; inset: 2px; border-radius: 4px; pointer-events: none; z-index: 3; border: 1px solid rgba(255,255,255,0.4); background: linear-gradient(135deg, rgba(200,240,255,0.6), rgba(100,180,255,0.8)); box-shadow: inset 0 0 10px #fff; }
.tile .ice.double { background: linear-gradient(135deg, rgba(150,210,255,0.9), rgba(50,120,200,0.9)); }
.tile.ice-hit .ice { animation: shake 0.3s ease; }
.tile .ice.melt { opacity: 0 !important; transform: scale(1.2); transition: all 0.3s; }

.blocked-cell { position: absolute; inset: 2px; border-radius: 4px; z-index: 2; pointer-events: none; background: linear-gradient(140deg, #777, #444); border: 2px solid #000; box-shadow: inset 0 2px 0 rgba(255,255,255,0.2), inset 0 -2px 0 rgba(0,0,0,0.5); }

.poison-cell {
  position: absolute; border-radius: 4px; background: radial-gradient(circle at 35% 30%, #5a2e8a 0%, #341a5c 42%, #170a30 100%);
  border: 2px solid #000; box-shadow: inset 0 0 12px rgba(168,85,247,0.75), 0 0 10px rgba(168,85,247,0.5);
  z-index: 2; pointer-events: none; overflow: hidden; opacity: 1; transform: scale(1); transition: transform 0.25s ease, opacity 0.25s ease;
}
.poison-cell::before { content: ''; position: absolute; inset: 18%; background: radial-gradient(circle, rgba(190,120,255,0.75) 0%, rgba(140,60,220,0.3) 45%, transparent 72%); border-radius: 50%; animation: poisonBubble 1.5s ease-in-out infinite; }
.poison-cell::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 22% 70%, rgba(168,85,247,0.55) 0%, transparent 16%), radial-gradient(circle at 72% 28%, rgba(200,140,255,0.5) 0%, transparent 13%), radial-gradient(circle at 55% 82%, rgba(139,92,246,0.45) 0%, transparent 14%); animation: poisonSwirl 3s ease-in-out infinite; }
@keyframes poisonBubble { 0%, 100% { transform: scale(0.9); opacity: 0.55; } 50% { transform: scale(1.12); opacity: 0.95; } }
@keyframes poisonSwirl { 0%, 100% { opacity: 0.7; transform: rotate(0deg); } 50% { opacity: 1; transform: rotate(8deg); } }
.poison-cell.poison-hit { animation: poisonHitShake 0.3s ease; }
@keyframes poisonHitShake { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.8); } }
.poison-cell.poison-burst { animation: poisonBurst 0.3s ease forwards; }
@keyframes poisonBurst { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.7); opacity: 0; } }

.tile.selected .face { transform: scale(1.05); z-index: 20; box-shadow: 0 0 0 2px #fff, 0 0 10px #fff; }
.tile.hint .face { animation: hintGlow 0.8s infinite alternate; }
@keyframes hintGlow { 0% { border-color: #111; } 100% { border-color: #55ffff; box-shadow: 0 0 15px #55ffff; } }

.tile.pop { pointer-events: none; z-index: 30; }
.tile.pop .face { animation: popOut 0.25s ease-out forwards; }
@keyframes popOut { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.1); opacity: 0.8; } 100% { transform: scale(0); opacity: 0; } }
.tile.invalid .face { animation: shake 0.3s ease; }

.tile.spawn .face { animation: fallIn 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1) both; }
@keyframes fallIn { 0% { transform: translateY(-40px); opacity: 0.2; } 100% { transform: translateY(0); opacity: 1; } }

.ice-tip { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(30, 50, 80, 0.92); border: 2px solid #55c2ff; box-shadow: 0 0 20px rgba(85, 194, 255, 0.9), 0 8px 24px rgba(0,0,0,0.8); color: #fff; font-size: 14px; font-weight: bold; padding: 12px 20px; border-radius: 8px; white-space: nowrap; pointer-events: none; text-shadow: 1px 1px 0 #000; z-index: 100; animation: iceTipFloat 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.5) both; }
@keyframes iceTipFloat { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.score-float {
  position: absolute; pointer-events: none; font-size: 18px; font-weight: 800; color: #ffd93d;
  animation: floatUpScore 0.9s cubic-bezier(0.2, 0.8, 0.4, 1) forwards; transform: translate(-50%, -50%);
  z-index: 60; white-space: nowrap; text-align: center; display: flex; flex-direction: column; align-items: center;
  text-shadow: 1px 1px 0 #000, 0 0 6px rgba(255,217,61,0.6);
}
.score-float.score-float-md { font-size: 20px; color: #ffb84a; text-shadow: 1px 1px 0 #000, 0 0 8px rgba(255, 184, 74, 0.7); }
.score-float.score-float-lg { font-size: 24px; color: #ff5555; text-shadow: 1px 1px 0 #000, 0 0 14px rgba(255, 85, 85, 0.9), 0 0 6px rgba(255, 217, 61, 0.6); }
.score-float .score-main { line-height: 1.1; }
.score-float .score-mult { font-size: 15px; font-weight: 900; color: #ffb84a; text-align: center; margin-top: 1px; letter-spacing: 1px; padding: 1px 6px; border-radius: 4px; background: rgba(30, 15, 0, 0.65); border: 1px solid rgba(255, 150, 60, 0.55); line-height: 1.2; text-shadow: 0 0 8px rgba(255, 150, 60, 1), 1px 1px 0 #000, -1px -1px 0 #000; }
@keyframes floatUpScore { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); } 28% { opacity: 1; transform: translate(-50%, -85%) scale(1.22); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

.combo-big-tip { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.5); font-size: 48px; font-weight: 900; color: #ffd93d; text-shadow: 0 4px 0 #000, 0 0 20px #ff9f43, 0 0 40px #ff7a45; pointer-events: none; z-index: 80; opacity: 0; white-space: nowrap; animation: comboPop 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.5) forwards; }
@keyframes comboPop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-10deg); } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(5deg); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(0.8); } }

.prop-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; justify-content: center; margin-top: 5px; padding: 0 5px; }
.prop-btn { aspect-ratio: 1 / 1; background: #6c6c6c; border: 2px solid #000; border-radius: 4px; color: #fff; cursor: pointer; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000; display: flex; align-items: center; justify-content: center; position: relative; transition: all 0.05s; padding: 0; }
.prop-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; }
.prop-btn.active { background: #5a8a3a; border-color: #ffd93d; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 0 10px #5a8a3a; }
.prop-btn img { width: 65%; height: 65%; object-fit: contain; image-rendering: pixelated; pointer-events: none; }
.prop-count { position: absolute; top: -6px; right: -4px; background: #ff5555; color: #fff; font-size: 12px; font-weight: bold; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #000; display: flex; align-items: center; justify-content: center; text-shadow: 1px 1px 0 #000; }
.prop-btn.disabled { opacity: 0.4; filter: grayscale(1); cursor: not-allowed; }
.prop-btn.disabled:active { transform: none; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000; }

.combo-tip { position: absolute; right: 15px; top: 50%; transform: translateY(-50%) scale(0.6); font-size: 16px; font-weight: bold; color: #ffd93d; opacity: 0; transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4); text-shadow: 2px 2px 0 #000; pointer-events: none; }
.combo-tip.show { opacity: 1; transform: translateY(-50%) scale(1); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background: #3e3e3e; border: 2px solid #000; box-shadow: inset 0 0 0 2px #6c6c6c, 0 10px 30px #000; padding: 20px; border-radius: 4px; text-align: center; transform: scale(0.9); transition: transform 0.2s, box-shadow 0.2s; width: 85%; max-width: 320px; max-height: 90vh; overflow-y: auto; -ms-overflow-style: none; scrollbar-width: none; }
.modal-content::-webkit-scrollbar { display: none; }
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-content.modal-success { box-shadow: inset 0 0 0 2px #6c6c6c, 0 10px 30px #000, 0 0 0 3px rgba(255, 217, 61, 0.65), 0 0 40px rgba(255, 217, 61, 0.35); }
.modal-content.modal-success h2 { color: #ffd93d; }
.modal-content.modal-fail { box-shadow: inset 0 0 0 2px #6c6c6c, 0 10px 30px #000, 0 0 0 3px rgba(255, 85, 85, 0.65), 0 0 40px rgba(255, 85, 85, 0.35); }
.modal-content.modal-fail h2 { color: #ff7070; }

.modal-content h2 { color: #fff; margin: 0 0 15px 0; font-size: 1.4rem; text-shadow: 2px 2px 0 #000; }
.modal-content p { color: #ddd; margin-bottom: 20px; text-shadow: 1px 1px 0 #000; line-height: 1.5; font-size: 14px; white-space: pre-line; text-align: left; }

.modal-btn { width: 100%; padding: 12px 0; margin-top: 10px; background: #6c6c6c; color: #fff; border: 2px solid #000; border-radius: 4px; font-size: 1rem; font-weight: bold; cursor: pointer; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -2px 0 rgba(0,0,0,0.4), 0 4px 0 #000; transition: all 0.05s; font-family: inherit; }
.modal-btn:active { background: #fff; color: #000; transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(0,0,0,0.2), 0 0 0 #000; }
.modal-btn.green { background: #5a8a3a; }

.modal-stars { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; height: 48px; }
.modal-stars .star { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; filter: grayscale(1) opacity(0.3); transition: all 0.3s; }
.modal-stars .star.active { filter: none; animation: starPop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.5) both; }
@keyframes starPop { 0% { transform: scale(0); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

.modal-actions { display: flex; gap: 10px; margin-top: 15px; }
.modal-actions button { flex: 1; margin-top: 0; }

.help-content { font-size: 13px; color: #ddd; line-height: 1.6; text-align: left; max-height: 50vh; overflow-y: auto; margin-bottom: 15px; }
.help-content p { margin-bottom: 8px; }
.help-content strong { color: #ffd93d; }

.inline-energy-icon { width: 16px; height: 16px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; margin-left: 2px; margin-top: -2px; }
.help-icon { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; margin-right: 4px; margin-top: -2px; }

.setting-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; font-size: 14px; color: #fff; border-bottom: 2px solid #222; }
.switch { position: relative; display: inline-block; width: 48px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #444; border: 2px solid #000; transition: .2s; box-shadow: inset 0 2px 0 rgba(0,0,0,0.5); }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background: #aaa; border: 2px solid #000; transition: .2s; }
input:checked + .slider { background: #5a8a3a; }
input:checked + .slider:before { transform: translateX(24px); background: #fff; }

.volume-item { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; font-size: 14px; color: #fff; border-bottom: 2px solid #222; }
.volume-header { display: flex; justify-content: space-between; align-items: center; }
.volume-val { color: #ffd93d; font-size: 13px; font-weight: bold; text-shadow: 1px 1px 0 #000; }
.volume-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; background: #222; border: 2px solid #000; border-radius: 0; outline: none; cursor: pointer; box-shadow: inset 0 2px 0 rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.05); }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; background: #5a8a3a; border: 2px solid #000; border-radius: 0; cursor: pointer; box-shadow: 0 2px 0 #000; }
.volume-slider::-webkit-slider-thumb:active { background: #6fddab; }
.volume-slider::-moz-range-thumb { width: 14px; height: 14px; background: #5a8a3a; border: 2px solid #000; border-radius: 0; cursor: pointer; box-shadow: 0 2px 0 #000; }
.volume-slider::-moz-range-thumb:active { background: #6fddab; }
.volume-slider::-moz-range-track { height: 8px; background: #222; border: 2px solid #000; }

.account-status { font-size: 13px; color: #ffd93d; font-weight: bold; text-shadow: 1px 1px 0 #000; flex: 1; text-align: left; word-break: break-all; line-height: 1.4; padding-right: 4px; min-width: 0; }
.account-status.not-logged { color: #888; }

.auth-input { width: 100%; padding: 10px 12px; margin-bottom: 10px; background: #222; color: #fff; border: 2px solid #000; border-radius: 4px; font-family: inherit; font-size: 14px; outline: none; box-shadow: inset 0 2px 0 rgba(0,0,0,0.6); }
.auth-input:focus { border-color: #5a8a3a; }
.auth-error { color: #ff7070 !important; font-size: 12px !important; min-height: 18px; margin: 4px 0 10px 0 !important; text-align: center !important; text-shadow: 1px 1px 0 #000; }

.toast-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 5000; opacity: 0; transition: opacity 0.2s; }
.toast-overlay.show { opacity: 1; }
.toast-box { background: #3e3e3e; border: 2px solid #000; box-shadow: inset 0 0 0 2px #6c6c6c, 0 10px 30px #000; padding: 16px 24px; border-radius: 4px; color: #fff; font-size: 14px; text-shadow: 1px 1px 0 #000; text-align: center; max-width: 280px; transform: scale(0.9); transition: transform 0.2s; line-height: 1.5; }
.toast-overlay.show .toast-box { transform: scale(1); }

@media (min-width: 768px) {
  .main-wrapper { max-width: 600px; margin-top: 95px; margin-bottom: 50px; }
  #homePage { max-width: 620px; }
  .menu-title-wrap { max-width: 420px; margin-bottom: 26px; }
  .mc-panel { box-shadow: 0 0 0 2px #555, 0 15px 40px rgba(0, 0, 0, 0.9), inset 0 0 0 2px #111; }
  .panel-title { font-size: 1.5rem; padding: 14px; letter-spacing: 3px; }
  .panel-body { padding: 16px 14px; gap: 14px; }
  #homePage .panel-body { padding: 20px 16px 16px 16px; gap: 12px; }
  .continue-btn { padding: 16px 0; font-size: 17px; }
  .home-total-label { font-size: 13px; }
  .home-total-text { font-size: 13px; }
  .home-total-bar { height: 7px; }
  .chapter-card { padding: 14px; }
  .chapter-header { font-size: 16px; padding: 10px 14px; }
  .chapter-progress { font-size: 13px; padding: 3px 10px; }
  .grid-container { gap: 12px; }
  .grid-item { padding: 12px 3px; font-size: 13px; }
  .grid-item .stars { height: 18px; margin-top: 6px; }
  .grid-item .stars img { width: 16px; height: 16px; }
  .chapter-nav-btn { padding: 6px 0; font-size: 14px; }
  .chapter-nav-indicator { font-size: 13px; padding: 6px 10px; min-width: 58px; }
  .top-actions { top: 24px; left: 24px; right: 24px; }
  .float-btn { height: 48px; padding: 0 20px; font-size: 17px; }
  .icon-btn { width: 48px; font-size: 24px; }
  .icon-btn img { width: 28px; height: 28px; }
  .global-energy { height: 48px; padding: 0 16px; }
  .energy-icon { width: 26px; height: 26px; }
  .energy-val { font-size: 16px; }
}

@media (min-width: 1200px) {
  .main-wrapper { max-width: 640px; }
  #homePage { max-width: 680px; }
  .menu-title-wrap { max-width: 460px; }
  .panel-title { font-size: 1.6rem; padding: 16px; }
  .grid-item { padding: 14px 4px; font-size: 14px; }
}

@media (max-width: 430px) {
  .float-btn { height: 44px; padding: 0 12px; font-size: 15px; }
  .icon-btn { width: 44px; padding: 0; font-size: 20px; }
  .menu-title-wrap { max-width: 300px; }
  .grid-container { grid-template-columns: repeat(3, 1fr); }
  .hud-item span { font-size: 16px; }
  .chapter-header { font-size: 13px; padding: 6px 10px; }
  .setting-item { font-size: 13px; }
  .home-total-label { font-size: 11px; }
  .home-total-text { font-size: 11px; }
  .chapter-nav-btn { padding: 3px 0; font-size: 12px; }
  .chapter-nav-indicator { font-size: 11px; padding: 3px 6px; min-width: 46px; }
  .grid-item { font-size: 11px; padding: 8px 1px; }
}