:root {
  color-scheme: dark;
  --background: #141813;
  --panel: #22281d;
  --panel-dark: #1b2119;
  --border: #434b35;
  --ink: #f4efd9;
  --muted: #baaF92;
  --green: #bfe78b;
  --gold: #f3c978;
  --mono: 'Cascadia Mono', Consolas, monospace;
  --sans: 'Microsoft YaHei UI', 'PingFang SC', 'Noto Sans CJK SC', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  font: 1rem/1.45 var(--sans);
  background:
    repeating-linear-gradient(90deg, #97af7207 0 1px, transparent 1px 24px),
    repeating-linear-gradient(0deg, #97af7207 0 1px, transparent 1px 24px),
    radial-gradient(ellipse at 27% 0%, #293520, transparent 59%),
    var(--background);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; }
button:enabled { cursor: pointer; }
button:focus-visible { outline: 2px solid #fff0b6; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
canvas { image-rendering: pixelated; }
.shell { width: min(calc(100% - 64px), 1264px); margin: 0 auto; }
.topbar { display: flex; min-height: 90px; align-items: center; justify-content: space-between; gap: 12px; }
.brand, .header-actions, .resource, .station-heading, .sector { display: flex; align-items: center; }
.brand { gap: 13px; }
.brand-icon, .resource-icon, .station-icon, .mission-icon, .upgrade-icon { display: grid; place-items: center; flex: none; }
.brand-icon { width: 47px; height: 47px; background: #354129; border: 1px solid #65764b; box-shadow: 3px 3px #0f150d, inset 0 0 0 3px #242c20; }
.brand-icon canvas { width: 39px; }
.brand h1 { font-size: 1.62rem; line-height: 1.12; letter-spacing: .06em; }
.brand p { margin-top: 6px; color: #bece8c; font: 700 .71rem/1 var(--mono); letter-spacing: .23em; }
.header-actions { gap: 9px; }
.save-status { display: inline-flex; align-items: center; gap: 7px; margin-right: 5px; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.save-status i, .mine-dot { width: 6px; height: 6px; background: #a8d776; box-shadow: 0 0 9px #a8d77a65; }
.save-status[data-error] i { background: #f5c373; }
.icon-button { display: grid; width: 39px; height: 39px; place-items: center; padding: 0; background: #282f22; border: 1px solid #505b43; font: 800 1rem var(--mono); }
.icon-button:hover { background: #414b34; }
.icon-button canvas { width: 25px; }

.resource-bar { display: grid; grid-template-columns: 1.2fr 1fr .97fr .9fr; margin-bottom: 17px; border: 1px solid var(--border); background: #23271d; box-shadow: 0 4px #0e110c; }
.resource { min-width: 0; min-height: 77px; padding: 9px clamp(10px, 1.7vw, 23px); gap: 12px; }
.resource + .resource { border-left: 1px solid var(--border); }
.resource.primary { background: linear-gradient(110deg, #353e25, #2b3423); }
.resource-icon { width: 40px; height: 40px; background: #171c16; border: 1px solid #48513b; }
.resource-icon canvas { width: 33px; }
.resource div > span { display: block; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.resource strong { display: block; color: var(--ink); font: 700 clamp(1.24rem, 2.25vw, 1.8rem)/1 var(--mono); white-space: nowrap; margin-top: 6px; }
.resource.primary strong { color: var(--green); }
.resource:last-child strong { color: #d6b4fc; }
.resource small { color: #bdb79d; font: 400 .76rem var(--sans); }
#balance.gain { animation: tally .26s steps(4, end); }
@keyframes tally { 25% { color: #fffbe8; transform: translateY(-2px); } }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(335px, .52fr); align-items: stretch; gap: 17px; }
.mining-frame, .station-frame { min-width: 0; border: 1px solid var(--border); background: var(--panel); box-shadow: 0 4px #0e110c; }
.mining-frame { display: flex; flex-direction: column; }
.mine-top { display: flex; min-height: 69px; padding: 10px 16px; align-items: center; justify-content: space-between; background: linear-gradient(95deg, #343e29, #262d22); }
.sector { gap: 12px; }
.mine-dot { width: 8px; height: 8px; margin-left: 3px; }
.mine-top p { color: #c1ca9e; font-size: .78rem; letter-spacing: .08em; }
.mine-top h2 { margin-top: 2px; font-size: 1.32rem; letter-spacing: .07em; line-height: 1.18; }
.depth { padding: 5px 9px; color: #e0d1ac; background: #1a2219; border: 1px solid #576246; font: 700 .86rem var(--mono); }

.mine-view { aspect-ratio: 16 / 9; position: relative; overflow: hidden; isolation: isolate; border-block: 1px solid #59624a; background: #415941; }
#cave, #effects { position: absolute; width: 100%; height: 100%; inset: 0; }
#effects { z-index: 3; pointer-events: none; }
.vein { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.ore-tile { position: absolute; top: 68.15%; left: var(--slot); width: 11.2%; aspect-ratio: 1; padding: 0; border: 0; background: transparent; transform: translate(-50%, -50%); pointer-events: auto; touch-action: none; }
.ore-tile canvas { display: block; width: 100%; }
.ore-tile[data-active] { filter: drop-shadow(0 0 5px #dff8aab3); }
.ore-tile[data-active]::after { position: absolute; inset: 11% 7% 8%; content: ''; pointer-events: none; background:
  linear-gradient(#f3f8be, #f3f8be) left top / 8px 2px,
  linear-gradient(#f3f8be, #f3f8be) left top / 2px 8px,
  linear-gradient(#f3f8be, #f3f8be) right top / 8px 2px,
  linear-gradient(#f3f8be, #f3f8be) right top / 2px 8px,
  linear-gradient(#f3f8be, #f3f8be) left bottom / 8px 2px,
  linear-gradient(#f3f8be, #f3f8be) left bottom / 2px 8px,
  linear-gradient(#f3f8be, #f3f8be) right bottom / 8px 2px,
  linear-gradient(#f3f8be, #f3f8be) right bottom / 2px 8px;
  background-repeat: no-repeat;
}
.ore-tile:hover { filter: brightness(1.18); }
.ore-tile[data-broken] canvas, .ore-tile[data-broken]::after { opacity: 0; }
.ore-tile.hit canvas { animation: block-hit .15s steps(5, end); }
@keyframes block-hit { 25% { transform: translate(2px, 2px) scale(.94); filter: brightness(1.45); } 64% { transform: translate(-2px, -1px) scale(1.03); } }
.scene-hud { position: absolute; z-index: 4; top: 10px; left: 10px; pointer-events: none; display: grid; gap: 4px; min-width: 100px; padding: 5px 8px; color: #faf3d2; border: 1px solid #9ea27780; background: #171d17eb; }
.combo { font: 800 .87rem var(--mono); }
.combo[data-hot] { color: #ffda83; }
.chain-track, .charge-track { display: block; height: 4px; background: #d0bf9250; }
.chain-track > span, .charge-track > span { display: block; width: 0; height: 100%; background: #c3e294; }
.scene-label { position: absolute; z-index: 4; bottom: 9px; left: 10px; padding: 5px 8px; background: #171b14ed; color: #f4e9c7; border: 1px solid #7d88615c; pointer-events: none; font-size: .8125rem; }
.float-layer { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.float-label { position: absolute; transform: translate(-50%, -50%); max-width: 90%; color: #f7f5d7; text-align: center; white-space: nowrap; text-shadow: 2px 2px #26261a, -1px -1px #26261a; font: 900 clamp(.87rem, 2.7vw, 1.65rem) var(--mono); animation: float-rise .83s steps(16, end) forwards; }
.float-label.rare { color: #ffe183; }
.float-label.blast { color: #c9fff3; font-size: clamp(1rem, 3.5vw, 2rem); }
.float-label.machine { color: #c5e994; font-size: clamp(.8rem, 2.3vw, 1.15rem); }
@keyframes float-rise { 0% { opacity: 1; } 65% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -71px); } }

.mine-controls { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; background: #20261c; }
.mine-button, .pulse-button { display: flex; min-width: 0; min-height: 48px; align-items: center; justify-content: center; gap: 9px; padding: 5px 12px; touch-action: none; }
.mine-button { position: relative; border: 1px solid #e2f3a7; background: #b9de82; box-shadow: 0 3px #5b773c, inset 0 -3px #97bd64; color: #26331b; font-weight: 900; letter-spacing: .06em; }
.mine-button:hover { background: #cdea94; }
.mine-button:active, .mine-button.pressed { transform: translateY(2px); box-shadow: 0 1px #5b773c; }
.mine-button canvas, .pulse-button canvas { width: 28px; flex: none; }
.mine-button kbd, .pulse-button kbd { position: absolute; right: 9px; }
kbd { padding: 2px 4px; background: #171d1654; border: 1px solid #171d164d; color: inherit; font: .67rem var(--mono); }
.mine-button kbd { background: #6e954936; }
.touch-hint { display: none; font-size: .68rem; font-weight: 600; white-space: nowrap; letter-spacing: 0; }
.pulse-button { position: relative; text-align: left; border: 1px solid #546050; background: #31392d; box-shadow: 0 3px #161d14, inset 0 -3px #272e25; justify-content: start; padding-right: 32px; }
.pulse-button[aria-disabled='true'] { cursor: default; }
.pulse-button[data-ready] { color: #e3fff1; border-color: #a3e6bc; background: #37634b; box-shadow: 0 3px #102c24, inset 0 0 0 2px #78c99c; }
.pulse-button[data-ready]:hover { background: #427e5d; }
.pulse-copy { display: grid; flex: auto; gap: 4px; white-space: nowrap; }
.pulse-copy strong { font-size: .88rem; }
.charge-track > span { background: repeating-linear-gradient(90deg, #a4ecba 0 8px, #6fbd90 8px 10px); transition: width .14s steps(6, end); }
#chargeValue { color: #d8e5c3; font: 700 .82rem var(--mono); }

.station-frame { display: flex; flex-direction: column; }
.station-heading { gap: 11px; padding: 12px 12px 10px; }
.station-heading h2 { font-size: 1.11rem; letter-spacing: .06em; }
.station-heading p { color: var(--muted); font-size: .8rem; margin-top: 1px; }
.station-icon { width: 38px; height: 38px; background: #383e2a; border: 1px solid #5f6648; }
.station-icon canvas, .mission-icon canvas { width: 29px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 0 12px; border-bottom: 1px solid #4c543f; }
.tabs button { min-height: 40px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #d0c6a7; font-size: .875rem; }
.tabs button:hover { background: #3a4332; }
.tabs [aria-selected='true'] { background: #414b32; border-color: #b6d97e; color: #e9f6c8; font-weight: 800; }
.station-content { display: grid; align-content: start; gap: 8px; padding: 10px 12px 12px; }
.upgrade { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; min-height: 66px; gap: 8px; padding: 7px; border: 1px solid #4c553e; background: #2b3326; }
.upgrade[data-locked] { background: #242b21; }
.upgrade[data-running] { border-left-color: #a5d570; }
.upgrade-icon { position: relative; width: 42px; height: 42px; background: #1e251c; border: 1px solid #5d654c; }
.upgrade-icon canvas { width: 36px; }
.upgrade[data-locked] .upgrade-icon { filter: saturate(.5); }
.upgrade h3 { overflow-wrap: anywhere; font-size: .91rem; line-height: 1.2; }
.upgrade p { margin-top: 4px; color: #d0c7ac; font-size: .8125rem; line-height: 1.2; }
.upgrade-meter { display: none; position: absolute; left: 3px; right: 3px; bottom: 2px; height: 2px; background: #5c6746; }
.upgrade-meter > span { display: block; height: 100%; width: 0; background: #c3e68a; }
.upgrade[data-running] .upgrade-meter { display: block; }
.buy { min-width: 65px; min-height: 35px; padding: 4px 6px; border: 1px solid #6a8052; background: #435735; color: #eff8ce; font: 800 .87rem var(--mono); }
.buy:hover:enabled { background: #637b4c; }
.buy:disabled { background: #293125; border-color: #4c5844; color: #bcbda4; }
.sector-action { min-width: 66px; font: 700 .78rem var(--sans); }
.beacon-button { border-color: #836b8e; background: #4e3e64; color: #ecd9ff; }
.beacon-button:hover:enabled { background: #634e7f; }
#exploration .upgrade { min-height: 54px; }
#exploration .upgrade-icon { height: 35px; }
#exploration .upgrade-icon canvas { width: 31px; }

.mission { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(116px, 29%); align-items: center; gap: 12px; margin-top: 17px; padding: 10px 13px; border: 1px solid #534e39; background: #2c2c23; box-shadow: 0 4px #0e110c; }
.mission-icon { width: 39px; height: 39px; background: #3b3727; border: 1px solid #6b6046; }
.mission h2 { font-size: .9rem; letter-spacing: .06em; }
.mission p { margin-top: 3px; color: #d9ccb0; font-size: .875rem; }
.mission-meter { display: grid; gap: 6px; }
.mission-meter > span { justify-self: end; color: #f4d48e; font: 700 .81rem var(--mono); }
.progress { height: 9px; border: 1px solid #766546; padding: 1px; background: #1a1b14; }
.progress > div { width: 0; height: 100%; background: repeating-linear-gradient(90deg, #f2c771 0 8px, #c39758 8px 10px); transition: width .12s; }
footer { display: flex; justify-content: space-between; gap: 14px; padding: 12px 2px 19px; color: #bfb497; font-size: .8125rem; }
footer > span:last-child { white-space: nowrap; }
footer b { font-family: var(--mono); color: #f5deb1; }

dialog { width: min(calc(100% - 26px), 460px); padding: 0; color: var(--ink); background: #252b21; border: 2px solid #697551; box-shadow: 6px 6px #0c110b; }
dialog::backdrop { background: #10160ed0; }
.dialog-title, .dialog-actions { display: flex; align-items: center; padding: 12px 15px; gap: 9px; }
.dialog-title { justify-content: space-between; border-bottom: 1px solid #515d43; background: #343e2b; }
.dialog-title h2 { font-size: 1.17rem; }
.dialog-title button { font-size: 1.2rem; }
#dialogBody { padding: 13px 15px 0; color: #e4dcbf; }
#dialogBody p + p { margin-top: 9px; }
.dialog-actions { justify-content: end; flex-wrap: wrap; }
.dialog-actions button { padding: 6px 13px; }
.dialog-dismiss { background: #393f30; border: 1px solid #717a56; }
.dialog-confirm { border: 1px solid #c7e89b; background: #b9de82; color: #26331b; font-weight: 800; }

@media (min-width: 1080px) {
  .station-content { gap: 10px; }
  .upgrade { min-height: 74px; padding-inline: 10px; }
}
@media (max-width: 900px) {
  .shell { width: calc(100% - 32px); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(288px, .65fr); gap: 12px; }
  .mine-controls { gap: 8px; padding: 9px; }
  .station-content { padding-inline: 9px; }
  .resource { gap: 7px; }
}
@media (max-width: 690px) {
  .shell { width: calc(100% - 20px); }
  .topbar { min-height: 69px; }
  .brand { gap: 8px; }
  .brand-icon { width: 36px; height: 36px; }
  .brand-icon canvas { width: 29px; }
  .brand h1 { font-size: 1.24rem; }
  .brand p { margin-top: 4px; }
  .header-actions { gap: 6px; }
  .icon-button { width: 33px; height: 33px; }
  .save-status { margin-right: 2px; gap: 4px; font-size: .73rem; }
  .resource-bar { grid-template-columns: repeat(2, minmax(0,1fr)); margin-bottom: 11px; }
  .resource { min-height: 57px; padding: 6px 8px; }
  .resource:nth-child(3) { border-left: 0; }
  .resource:nth-child(n+3) { border-top: 1px solid var(--border); }
  .resource-icon { width: 33px; height: 33px; }
  .resource-icon canvas { width: 29px; }
  .resource strong { margin-top: 4px; font-size: 1.15rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .mine-top { min-height: 56px; padding: 6px 10px; }
  .mine-top h2 { font-size: 1.16rem; }
  .scene-label { font-size: .72rem; bottom: 5px; left: 5px; padding: 2px 5px; }
  .scene-hud { min-width: 76px; top: 5px; left: 5px; padding: 3px 5px; }
  .combo { font-size: .75rem; }
  .mission { margin-top: 12px; }
}
@media (pointer: coarse), (max-width: 767px) {
  .mine-controls kbd { display: none; }
  .touch-hint { display: inline; }
  .ore-tile { width: 12.3%; }
  .pulse-button { padding-right: 10px; }
}
@media (max-width: 400px) {
  .mission { grid-template-columns: auto minmax(0, 1fr); }
  .mission-meter { grid-column: 1 / -1; }
  .resource small { font-size: .68rem; }
  .resource strong { font-size: 1rem; }
  .pulse-button { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .ore-tile.hit canvas, #balance.gain { animation: none; }
  .charge-track > span, .progress > div { transition: none; }
  .float-label { animation-duration: .52s; animation-name: float-fade; }
  @keyframes float-fade { to { opacity: 0; } }
}
