:root {
  color-scheme: dark;
  --gold: #ffd553;
  --gold-deep: #d99715;
  --cyan: #42dbe2;
  --text: #fff7e7;
  --muted: #d1bda5;
  --glass: rgba(42, 20, 12, .84);
  --line: rgba(255, 227, 183, .2);
  --ui: 'Trebuchet MS', 'Microsoft YaHei UI', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100vh; min-height: 100dvh; overflow: hidden; color: var(--text); background: #28150f; font-family: var(--ui); }
button { color: inherit; font: inherit; }
.game { position: relative; width: 100vw; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at 50% 48%, #311a11 0, #24120d 55%, #1b0e0a 100%); }
#mine-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.shade { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(180deg, rgba(20, 9, 6, .08), transparent 35%, rgba(12, 6, 4, .14)); }
.loading-screen { position: absolute; z-index: 12; inset: 0; display: grid; place-items: center; padding: 28px; color: var(--text); background: radial-gradient(ellipse at 50% 46%, #321811 0, #29130e 54%, #1d0e0a 100%); opacity: 1; transition: opacity .32s ease; }
.loading-screen.is-done { opacity: 0; pointer-events: none; }
.loading-screen[hidden] { display: none; }
.loading-content { width: min(100%, 430px); text-align: center; transform: translateY(-2%); }
.loading-pickaxe { margin-bottom: 36px; font-size: 46px; line-height: 1; filter: drop-shadow(0 5px 8px rgba(0, 0, 0, .35)); animation: pickaxe-float 1.6s ease-in-out infinite; }
@keyframes pickaxe-float { 50% { transform: translateY(-5px) rotate(-5deg); } }
.loading-title { margin: 0; color: #fff4e5; font-size: clamp(30px, 8vw, 46px); line-height: 1; font-weight: 900; }
.loading-title span { color: var(--gold); }
.loading-subtitle { margin: 11px 0 42px; color: #d3bca9; font-size: 11px; font-weight: 700; letter-spacing: 3px; }
.loading-track { width: 100%; height: 18px; overflow: hidden; border: 1px solid rgba(255, 227, 183, .28); border-radius: 999px; background: rgba(15, 8, 6, .5); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .38); }
.loading-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffc12f, #ffdb59); box-shadow: 0 0 16px rgba(255, 197, 55, .4); transition: width .12s linear; }
.loading-percent { margin: 22px 0 0; color: var(--gold); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.loading-message { min-height: 24px; margin: 26px 0 0; color: #d6c6b8; font-size: 14px; }
.ready-cue { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; color: var(--gold); font-size: clamp(54px, 16vw, 76px); font-weight: 900; line-height: 1; text-shadow: 0 5px 0 rgba(153, 91, 13, .72), 0 0 24px rgba(255, 197, 55, .28); pointer-events: none; }
.ready-cue.is-popping { animation: ready-in .32s ease-out both; }
.ready-cue[hidden] { display: none; }
@keyframes ready-in { from { opacity: 0; transform: scale(.82); } to { opacity: 1; transform: scale(1); } }
.scene-banner { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; padding: 0 16px; color: #fff0d6; font-size: clamp(20px, 6vw, 34px); font-weight: 900; line-height: 1.15; text-align: center; text-shadow: 0 3px 0 rgba(26, 12, 19, .8), 0 0 18px rgba(255, 227, 191, .22); pointer-events: none; }
.scene-banner[hidden] { display: none; }
.scene-banner.is-entering { animation: scene-banner-in 2.2s ease both; }
@keyframes scene-banner-in { 0% { opacity: 0; transform: translateY(9px) scale(.96); } 12%, 78% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-5px) scale(1.02); } }
.damage-flash { position: absolute; z-index: 4; inset: 0; background: rgba(255, 54, 48, .3); opacity: 0; pointer-events: none; }
.damage-flash.is-visible { animation: damage-flash .38s ease-out both; }
@keyframes damage-flash { 0%, 100% { opacity: 0; } 16% { opacity: 1; } }
.damage-alert { position: absolute; z-index: 4; top: 13%; left: 0; right: 0; color: #ff554d; font-size: clamp(18px, 5vw, 25px); font-weight: 900; line-height: 1; text-align: center; text-shadow: 0 2px 0 rgba(30, 8, 8, .9), 0 0 14px rgba(255, 66, 55, .4); opacity: 0; pointer-events: none; }
.damage-alert.is-visible { animation: damage-alert .9s ease-out both; }
@keyframes damage-alert { 0% { opacity: 0; transform: translateY(8px) scale(.92); } 14%, 68% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-16px) scale(1.04); } }
.pickup-effects { position: absolute; z-index: 5; inset: 0; overflow: hidden; pointer-events: none; }
.pickup-popup { position: absolute; font-size: clamp(16px, 4.5vw, 22px); font-weight: 900; line-height: 1; white-space: nowrap; animation: pickup-rise .82s cubic-bezier(.2, .75, .3, 1) both; }
.pickup-gem { color: #62efff; text-shadow: 0 2px 0 rgba(5, 48, 61, .8), 0 0 12px rgba(79, 231, 255, .6); }
.pickup-gold { color: #ffd553; text-shadow: 0 2px 0 rgba(93, 52, 4, .8), 0 0 12px rgba(255, 197, 55, .55); }
@keyframes pickup-rise { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.78); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 72% { opacity: 1; transform: translate(-50%, -28px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -44px) scale(.96); } }
.hud-lives.is-damaged { animation: heart-hit .36s ease-out; }
@keyframes heart-hit { 20% { transform: translateX(-4px) scale(1.18); } 45% { transform: translateX(4px) scale(.92); } 70% { transform: translateX(-2px); } }
.game.is-shaking #mine-canvas { animation: damage-shake .18s linear 2; }
@keyframes damage-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.game.is-collapsing #mine-canvas { animation: cave-quake .85s cubic-bezier(.36, .07, .19, .97) both; }
.game.is-collapsing .shade { animation: cave-dust .85s ease-out both; }
@keyframes cave-quake { 0%, 100% { transform: translate(0, 0) rotate(0); } 10% { transform: translate(-9px, 3px) rotate(-.7deg); } 23% { transform: translate(8px, -4px) rotate(.6deg); } 38% { transform: translate(-7px, 5px) rotate(-.4deg); } 54% { transform: translate(6px, -3px) rotate(.35deg); } 72% { transform: translate(-3px, 2px); } }
@keyframes cave-dust { 0%, 100% { opacity: 1; } 28% { opacity: .48; } 62% { opacity: .82; } }
.icon-button { position: absolute; z-index: 4; display: grid; width: 50px; height: 50px; place-items: center; padding: 0; border: 1px solid rgba(255, 230, 188, .13); border-radius: 50%; color: #fff2df; background: rgba(55, 30, 20, .74); box-shadow: 0 6px 18px rgba(0, 0, 0, .28); font-size: 19px; cursor: pointer; transition: transform .18s, background .18s; }
.icon-button:hover { transform: translateY(-2px); background: rgba(83, 44, 27, .92); }
#sound-button { top: 18px; left: 18px; }
.game.is-playing #sound-button { display: none; }
.hud { position: absolute; z-index: 3; top: 16px; right: 15px; display: grid; justify-items: end; gap: 5px; pointer-events: none; }
#pause-button { position: fixed; z-index: 6; top: 18px; left: 18px; pointer-events: auto; }
.hud-depth { display: grid; justify-items: center; min-width: 96px; padding: 3px 8px 6px; color: var(--text); text-shadow: 0 2px 6px #140906; }
.hud-depth strong { font-size: 18px; line-height: 1; font-weight: 800; }
.hud-depth span { margin-top: 2px; color: #d0bfae; font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.hud-pill { display: flex; min-width: 58px; min-height: 28px; align-items: center; justify-content: center; gap: 6px; padding: 3px 9px; border: 1px solid rgba(255, 213, 83, .23); border-radius: 20px; background: rgba(33, 17, 11, .6); font-size: 12px; font-weight: 800; text-shadow: 0 2px 5px #140906; }
.hud-lives { display: flex; align-items: center; gap: 5px; color: #ff554d; font-size: 19px; line-height: 1; }
.hud-lives .lost { filter: grayscale(1); opacity: .38; }
.hud-time { display: none; }
.timer-icon { color: #d9c3aa; font-size: 12px; }
.timer-track { width: 40px; height: 6px; overflow: hidden; border-radius: 5px; background: rgba(255, 255, 255, .18); }
.timer-fill { width: 100%; height: 100%; border-radius: inherit; background: var(--cyan); transition: width .1s linear; }
.hud-status { display: flex; min-height: 27px; align-items: center; gap: 5px; color: var(--gold); font-size: 14px; }
.hud-status:empty { display: none; }

.overlay { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(14, 7, 5, .28); opacity: 1; visibility: visible; transition: opacity .2s, visibility .2s; }
.overlay[hidden] { display: none; }
.panel { width: min(100%, 430px); padding: 25px 24px 23px; border: 1px solid rgba(255, 235, 190, .26); border-radius: 18px; background: var(--glass); box-shadow: 0 22px 65px rgba(0, 0, 0, .48), inset 0 1px rgba(255,255,255,.07); text-align: center; backdrop-filter: blur(7px); }
.title { margin: 0; color: #fff9ee; font-size: clamp(29px, 8vw, 42px); line-height: 1; letter-spacing: 0; font-weight: 800; text-shadow: 0 3px 0 rgba(0, 0, 0, .24); }
.title span { color: var(--gold); }
.tagline { margin: 5px 0 17px; color: #d4c2b1; font-size: 11px; font-weight: 700; letter-spacing: 2px; }
.stats { display: flex; justify-content: center; gap: 9px; margin-bottom: 17px; }
.stat-chip { display: flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 5px 13px; border: 1px solid rgba(255, 215, 136, .24); border-radius: 22px; background: rgba(28, 14, 9, .42); color: #f7ebdc; font-size: 12px; font-weight: 700; }
.stat-chip strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.actions { display: grid; gap: 11px; }
.btn { display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 15px; color: #241508; font-size: 15px; font-weight: 800; cursor: pointer; transition: filter .16s, transform .16s; }
.btn:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn-gold { background: linear-gradient(#ffe476, #ffc537 76%, #e8a91c); box-shadow: 0 7px 0 #9c610e, 0 12px 24px rgba(0, 0, 0, .22); }
.btn-cyan { background: linear-gradient(#6aedf0, #34ccd6 76%, #1aaab7); box-shadow: 0 7px 0 #147d87, 0 12px 24px rgba(0, 0, 0, .22); }
.btn-quiet { min-height: 44px; border: 1px solid rgba(255, 231, 195, .23); color: #f2dfc9; background: rgba(255, 255, 255, .06); font-size: 13px; }
.dialog { width: min(100%, 440px); max-height: min(88vh, 720px); overflow: auto; padding: 21px 20px 19px; border: 1px solid rgba(255, 235, 190, .28); border-radius: 18px; background: rgba(42, 21, 13, .94); box-shadow: 0 22px 65px rgba(0, 0, 0, .5); text-align: left; }
.dialog h2 { margin: 0 0 16px; text-align: center; font-size: 23px; }
.help-list { display: grid; gap: 12px; }
.help-item { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 11px; }
.help-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid rgba(255, 223, 172, .2); border-radius: 13px; background: rgba(255, 209, 113, .09); font-size: 22px; }
.help-item h3 { margin: 0 0 3px; font-size: 14px; }
.help-item p { margin: 0; color: #d0bca7; font-size: 11px; line-height: 1.45; }
.dialog .btn { margin-top: 18px; }
.overlay-help { background: rgba(13, 7, 5, .55); }
.result-panel { width: min(100%, 430px); padding: 21px 19px 17px; border-color: rgba(255, 190, 103, .23); border-radius: 20px; background: rgba(74, 34, 24, .96); }
.result-title { margin: 0 0 10px; color: #fff3e5; font-size: 29px; line-height: 1.05; font-weight: 800; }
.result-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 10px; }
.result-stat { display: grid; min-height: 67px; align-content: center; justify-items: center; gap: 2px; border: 1px solid rgba(255, 197, 106, .19); border-radius: 14px; background: rgba(40, 18, 13, .52); }
.result-stat strong { color: var(--gold); font-size: 21px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.result-stat span { color: #d7c1ad; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.result-actions { display: grid; gap: 8px; }
.result-actions .btn { min-height: 51px; border-radius: 15px; }
.result-home { border-color: rgba(255, 202, 132, .2); color: #f5e5d7; background: rgba(38, 17, 13, .68); box-shadow: 0 5px 0 rgba(26, 10, 7, .8); }
.pause-title { margin: 0 0 18px; font-size: 28px; }
.hud.is-hidden { display: none; }

@media (max-width: 600px) {
  #sound-button { top: 16px; left: 16px; width: 49px; height: 49px; }
  #pause-button { top: 16px; left: 16px; }
  .hud { top: 15px; right: 14px; gap: 6px; }
  .hud-depth strong { font-size: 23px; }
  .overlay { padding: 20px 24px; }
  .panel { padding: 25px 18px 22px; border-radius: 18px; }
  .title { font-size: 34px; }
  .btn { min-height: 51px; }
  .result-panel { padding: 19px 17px 15px; }
  .result-title { margin-bottom: 9px; font-size: 27px; }
  .result-stat { min-height: 65px; }
  .result-stat strong { font-size: 20px; }
  .dialog { padding: 17px 15px 16px; }
  .help-list { gap: 10px; }
  .help-item { grid-template-columns: 44px 1fr; gap: 9px; }
  .help-icon { width: 42px; height: 42px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
