/* =========================================================
   Space Micro:Shooter — 視覺系統
   深空機台 / 單一青色強調 / 金幣用金色 / 其餘靠對比與間距
   ========================================================= */

:root {
  --bg: #07040d;
  --bg-glow: #150a24;
  --surface: #100918;
  --surface-2: #170d24;
  --surface-3: #1e1130;
  --line: #31204a;
  --line-strong: #4a2f6b;
  --ink: #f3ecff;
  --muted: #a795c2;
  --dim: #7d6b99;
  --cyan: #3fd0ff;
  --cyan-deep: #1487b8;
  --gold: #ffc83d;
  --magenta: #ff3b8d;
  --green: #5cff9d;
  --danger: #ff5c74;

  --font-ui: "Helvetica Neue", "PingFang HK", "Hiragino Sans", "Microsoft JhengHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --shadow-panel: 0 18px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 50% -8%, #1d0f31 0%, transparent 62%),
    radial-gradient(700px 420px at 88% 108%, #101b2a 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 背景細網格：只是一個很低調的機台質感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px 26px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------- Header ---------------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 2px 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--cyan);
  background: linear-gradient(160deg, #1a0f2b, #0d0718);
  box-shadow: inset 0 0 18px rgba(63, 208, 255, .12);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ink);
}
.brand-text h1 span { color: var(--cyan); }
.brand-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  letter-spacing: .22em;
  color: var(--dim);
  text-transform: uppercase;
}

.link-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 9, 24, .8);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.link-state .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 3px rgba(125, 107, 153, .12);
}
.link-state[data-state="on"] { border-color: rgba(92, 255, 157, .45); color: var(--green); }
.link-state[data-state="on"] .dot { background: var(--green); box-shadow: 0 0 10px rgba(92, 255, 157, .8); }
.link-state[data-state="error"] { border-color: rgba(255, 92, 116, .45); color: var(--danger); }
.link-state[data-state="error"] .dot { background: var(--danger); }

/* ---------------- Layout ---------------- */

.rig {
  display: grid;
  grid-template-columns: auto 348px;
  gap: 26px;
  align-items: start;
  justify-content: center;
}

/* ---------------- Cabinet ---------------- */

.cabinet { display: flex; flex-direction: column; gap: 10px; }

.bezel {
  padding: 9px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #1b1029, #0d0716);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .6),
    0 30px 70px rgba(0, 0, 0, .55),
    0 0 60px rgba(63, 208, 255, .06),
    inset 0 1px 0 rgba(255, 255, 255, .05);
}

.screen {
  position: relative;
  height: min(78vh, 800px);
  aspect-ratio: 9 / 16;
  container-type: size;
  border-radius: 10px;
  overflow: hidden;
  background: #120820;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .8), inset 0 0 50px rgba(0, 0, 0, .6);
  touch-action: none;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}
canvas#game:focus { outline: none; }
canvas#game:focus-visible { outline: 2px solid var(--cyan); outline-offset: -3px; }

/* 畫面右下角的暫停掣（手機用） */
.pause-btn {
  position: absolute;
  right: 9px;
  bottom: 9px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 50%;
  border: 1px solid rgba(63, 208, 255, .35);
  background: rgba(8, 4, 15, .72);
  color: var(--cyan);
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.pause-btn span { width: 3px; height: 12px; border-radius: 1px; background: currentColor; }
.pause-btn:hover { border-color: var(--cyan); background: rgba(20, 12, 32, .92); }
.pause-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (pointer: coarse) {
  .pause-btn { width: 44px; height: 44px; right: 12px; bottom: 12px; }
  .pause-btn span { width: 4px; height: 14px; }
}

/* CRT 掃描線 + 暗角，靜態不逐幀畫 */
.crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px),
    radial-gradient(120% 80% at 50% 50%, transparent 55%, rgba(0, 0, 0, .5) 100%);
  mix-blend-mode: multiply;
  opacity: .55;
}

.cabinet-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--dim);
}
.bar-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bar-right { margin-left: auto; color: var(--muted); }
.led { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.led.cyan { background: var(--cyan); box-shadow: 0 0 8px rgba(63, 208, 255, .8); }
.led.gold { background: var(--gold); box-shadow: 0 0 8px rgba(255, 200, 61, .7); }

/* ---------------- 畫面內覆蓋層 ---------------- */

.layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3.2cqw;
  padding: 7cqw 6.4cqw;
  text-align: center;
  background:
    radial-gradient(85% 60% at 50% 42%, rgba(34, 14, 54, .93), rgba(6, 3, 12, .98) 74%);
  animation: layer-in .22s ease-out;
}
.layer[hidden] { display: none; }

/* 標題畫面半透明，讓背景星場透出來 */
.layer-title {
  background:
    radial-gradient(85% 60% at 50% 40%, rgba(34, 14, 54, .74), rgba(6, 3, 12, .9) 74%);
}

/* 任務完成 */
.layer-win {
  background:
    radial-gradient(80% 60% at 50% 42%, rgba(58, 38, 8, .9), rgba(6, 3, 12, .97) 74%);
}
.win-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(30px, 11.5cqw, 46px);
  letter-spacing: .14em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 200, 61, .38), 0 0 44px rgba(255, 200, 61, .16);
  animation: win-pop .5s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes win-pop {
  from { transform: scale(.82); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.win-sub {
  margin: 0;
  font-size: clamp(10px, 3.1cqw, 12.5px);
  color: #ffe9a8;
  letter-spacing: .04em;
}
.win-rank {
  width: clamp(46px, 14cqw, 64px);
  height: clamp(46px, 14cqw, 64px);
  border: 2px solid rgba(255, 200, 61, .7);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(255, 200, 61, .18), transparent 70%);
  box-shadow: 0 0 22px rgba(255, 200, 61, .15), inset 0 0 12px rgba(255, 200, 61, .08);
}
.win-rank b {
  font-family: var(--font-mono);
  font-size: clamp(20px, 6.4cqw, 28px);
  line-height: 1;
  color: var(--gold);
}
.win-rank small {
  font-family: var(--font-mono);
  font-size: clamp(6px, 1.8cqw, 8px);
  letter-spacing: .22em;
  color: #c9a227;
  margin-top: 2px;
}
.win-grid { max-width: 82%; }
.win-actions { display: flex; gap: 2.4cqw; }
.win-actions .btn {
  font-size: clamp(11px, 3.2cqw, 13px);
  padding: 2.6cqw 4.6cqw;
}

/* 暫停 */
.layer-pause {
  background:
    radial-gradient(80% 60% at 50% 42%, rgba(12, 24, 38, .88), rgba(6, 3, 12, .97) 74%);
}
.pause-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(28px, 10cqw, 40px);
  letter-spacing: .18em;
  color: var(--ink);
}
.pause-sub {
  margin: 0;
  font-size: clamp(10px, 3.2cqw, 12.5px);
  color: var(--muted);
}
.pause-actions { display: flex; gap: 2.4cqw; margin-top: 1cqw; }
.pause-actions .btn {
  font-size: clamp(11px, 3.2cqw, 13px);
  padding: 2.6cqw 4.6cqw;
}
.pause-hint {
  margin: 0;
  font-size: clamp(8.5px, 2.6cqw, 10px);
  color: var(--dim);
}

@keyframes layer-in { from { opacity: 0; } to { opacity: 1; } }

.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(8px, 2.6cqw, 10.5px);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--cyan);
  opacity: .85;
}

.game-title {
  margin: 1cqw 0 0;
  font-family: var(--font-mono);
  font-size: clamp(20px, 8cqw, 32px);
  line-height: .98;
  letter-spacing: .02em;
  color: #fff;
  text-shadow: 0 0 26px rgba(63, 208, 255, .35);
}
.game-title span { color: var(--cyan); font-size: .8em; letter-spacing: .01em; }

.lede {
  margin: 1.6cqw 0 0;
  font-size: clamp(10.5px, 3.5cqw, 13.5px);
  line-height: 1.7;
  color: var(--muted);
}

.record {
  margin: 0;
  font-size: clamp(9px, 2.9cqw, 11.5px);
  color: var(--dim);
  font-family: var(--font-mono);
}
.record b { color: var(--gold); }
.clear-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border: 1px solid rgba(255, 200, 61, .5);
  border-radius: 3px;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .12em;
  vertical-align: 1px;
}
#over-new {
  color: var(--gold);
  letter-spacing: .18em;
  font-size: clamp(8.5px, 2.7cqw, 10.5px);
  text-transform: uppercase;
}

.title-keys {
  margin-top: 1.6cqw;
  font-size: clamp(8.5px, 2.7cqw, 11px);
  color: var(--dim);
}
.title-note {
  margin: 0;
  font-size: clamp(8px, 2.5cqw, 10px);
  color: var(--dim);
  opacity: .8;
}

kbd {
  font-family: var(--font-mono);
  font-size: .92em;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #1a0f2a;
  color: var(--muted);
}

/* 結算 */
.over-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(18px, 7cqw, 26px);
  letter-spacing: .1em;
  color: var(--danger);
  text-shadow: 0 0 24px rgba(255, 92, 116, .3);
}
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2cqw;
  width: 100%;
  max-width: 74%;
  margin: 0.6cqw 0;
}
.result-grid > div {
  border: 1px solid var(--line);
  background: rgba(23, 13, 36, .75);
  border-radius: 7px;
  padding: 2cqw 2.4cqw;
}
.result-grid dt {
  font-size: clamp(8px, 2.4cqw, 10px);
  letter-spacing: .12em;
  color: var(--dim);
  text-transform: uppercase;
}
.result-grid dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: clamp(14px, 4.6cqw, 19px);
  color: var(--ink);
}

/* ---------------- 按鈕 ---------------- */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #1c1030;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, filter .15s;
}
.btn:hover { background: #261540; border-color: #62408c; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: .45; }

.btn-primary {
  border-color: #2aa9d6;
  background: linear-gradient(180deg, #1b9fd0, #0f6f96);
  color: #04121a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .18);
  box-shadow: 0 6px 18px rgba(20, 135, 184, .28), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { background: linear-gradient(180deg, #34b6e6, #1487b8); }
.btn-soft { background: #1a1029; font-size: 12px; padding: 8px 12px; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); font-size: 12px; }
.btn-danger { color: #ff9aa8; border-color: rgba(255, 92, 116, .4); }
.btn-danger:hover { background: rgba(60, 12, 24, .6); border-color: var(--danger); }
.btn-danger.is-armed {
  background: rgba(255, 92, 116, .18);
  border-color: var(--danger);
  color: #fff;
}
.btn-lg { font-size: clamp(12px, 3.7cqw, 15px); padding: 3cqw 7cqw; letter-spacing: .04em; }
.btn-block { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-glyph { font-size: 16px; line-height: 1; }

.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ---------------- Console ---------------- */

.console { display: flex; flex-direction: column; gap: 12px; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(24, 14, 38, .92), rgba(14, 8, 24, .92));
  padding: 14px;
  box-shadow: var(--shadow-panel);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
}

.tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 3px;
}
.tag-live { color: var(--dim); }
.tag-live[data-on="true"] {
  color: var(--green);
  border-color: rgba(92, 255, 157, .4);
  background: rgba(92, 255, 157, .08);
}

.status {
  margin: 9px 0 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 18px;
}
.status::before {
  content: "";
  flex: none;
  width: 6px; height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--dim);
}
.status[data-tone="ok"] { color: var(--green); }
.status[data-tone="ok"]::before { background: var(--green); box-shadow: 0 0 8px rgba(92, 255, 157, .8); }
.status[data-tone="error"] { color: var(--danger); }
.status[data-tone="error"]::before { background: var(--danger); }
.status[data-tone="busy"] { color: var(--gold); }
.status[data-tone="busy"]::before { background: var(--gold); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

.fineprint {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--dim);
}
.fineprint code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  background: #0c0616;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 3px;
}

/* 軸向儀表 */
.axis { margin-bottom: 9px; }
.axis-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--dim);
  margin-bottom: 4px;
  letter-spacing: .1em;
}
.axis-label b { color: var(--muted); font-weight: 600; }

.axis-track {
  position: relative;
  height: 8px;
  border-radius: 2px;
  background: #0b0615;
  border: 1px solid var(--line);
  overflow: hidden;
}
.axis-zero {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: var(--line-strong);
}
.axis-track i {
  position: absolute;
  top: 1px; bottom: 1px;
  left: 50%;
  width: 0;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(63, 208, 255, .55);
  transition: width .08s linear, left .08s linear;
}
.axis-track i.neg { background: var(--magenta); box-shadow: 0 0 8px rgba(255, 59, 141, .5); }

/* 統計 */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 12px 0 0;
}
.stats > div {
  background: rgba(10, 5, 18, .6);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
}
.stats dt { font-size: 9.5px; letter-spacing: .08em; color: var(--dim); }
.stats dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}

.raw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 9px;
  background: #0a0512;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 10px;
  color: var(--dim);
}
.raw code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 62%;
}

/* 設定 */
.field { display: block; }
.field-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-label b { color: var(--cyan); font-family: var(--font-mono); font-weight: 600; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--cyan), #2a5f8a);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #e8fbff;
  border: 3px solid var(--cyan);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(63, 208, 255, .6);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #e8fbff;
  border: 3px solid var(--cyan);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 11px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
}
.check input {
  appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #0b0615;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input:checked { background: var(--cyan); border-color: var(--cyan); }
.check input:checked::after {
  content: "";
  width: 3px; height: 7px;
  border: solid #04121a;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg) translate(-1px, -1px);
}

/* 協定表 */
.proto { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.proto th {
  text-align: left;
  font-weight: 600;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 6px 6px 0;
  border-bottom: 1px solid var(--line);
}
.proto td {
  padding: 6px 6px 6px 0;
  color: var(--muted);
  border-bottom: 1px solid rgba(49, 32, 74, .5);
}
.proto tr:last-child td { border-bottom: none; }
.proto code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--gold);
}

.tips { margin: 0; padding: 0 0 0 16px; font-size: 11.5px; color: var(--muted); }
.tips li { margin: 6px 0; }
.tips b { color: var(--ink); font-weight: 600; }
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* 頁腳 */
.foot {
  margin-top: auto;
  padding-top: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: #5d4f73;
  text-transform: uppercase;
}
.foot a {
  color: var(--muted);
  text-decoration: none;
  padding: 3px 0;
  border-bottom: 1px dotted var(--line-strong);
}
.foot a:hover { color: var(--cyan); }
.foot-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.foot a.sponsor {
  color: var(--gold);
  border-bottom-color: rgba(255, 200, 61, .35);
}
.foot a.sponsor:hover { color: #ffe08a; border-bottom-color: var(--gold); }

/* ---------------- 補給站 Modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 2, 10, .78);
  backdrop-filter: blur(6px);
  animation: layer-in .18s ease-out;
}
.modal[hidden] { display: none; }

.modal-card {
  width: min(760px, 100%);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 80% at 50% 0%, #24123a 0%, #120a1e 58%, #0c0714 100%);
  box-shadow: 0 40px 90px rgba(0, 0, 0, .7), 0 0 0 1px rgba(0, 0, 0, .6);
  overflow: hidden;
}

.shop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}
.shop-head h2 {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: .02em;
}
.shop-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.wallet {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.wallet b { font-size: 24px; color: var(--gold); }
.wallet small { font-size: 10px; color: var(--dim); letter-spacing: .12em; }
.coin {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3a8, #ffc83d 45%, #b47a00 100%);
  box-shadow: 0 0 10px rgba(255, 200, 61, .4);
  align-self: center;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 22px;
  overflow-y: auto;
  min-height: 0;
}

.item {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(12, 7, 20, .72);
  padding: 12px;
  transition: border-color .15s, background .15s;
}
.item:hover { border-color: #533573; background: rgba(26, 15, 42, .8); }
.item.is-max { opacity: .62; }
.item.is-bought { border-color: rgba(92, 255, 157, .5); }

.item-top { display: flex; align-items: center; gap: 9px; }
.item-meta { min-width: 0; }
.item-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .08em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}
.item.is-bought { border-color: rgba(92, 255, 157, .65); background: rgba(24, 48, 34, .38); }
.item.is-denied { animation: deny .26s ease-in-out; }
@keyframes deny {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.item-icon {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0614;
}
.item-icon canvas { display: block; image-rendering: pixelated; }
.item-name { font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.item-lv {
  display: flex; gap: 3px; margin-top: 3px;
}
.item-lv i {
  width: 12px; height: 3px; border-radius: 2px;
  background: #2c1c42;
}
.item-lv i.on { background: var(--cyan); box-shadow: 0 0 6px rgba(63, 208, 255, .5); }

.item-desc { font-size: 10.5px; line-height: 1.5; color: var(--dim); min-height: 32px; }

.item-buy {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.price {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gold);
}
.price.free { color: var(--green); }
.item-buy .btn { padding: 6px 10px; font-size: 11px; min-width: 58px; }
.item-buy .btn:disabled { opacity: .4; }

.shop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #0c0714;
}
.shop-foot p { margin: 0; font-size: 10.5px; color: var(--dim); }

/* ---------------- Responsive ---------------- */

@media (min-width: 1021px) {
  .console {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
  .console::-webkit-scrollbar { width: 8px; }
  .console::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: content-box;
  }
}

@media (max-width: 1020px) {
  .rig { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .cabinet { width: 100%; max-width: 452px; }
  .screen {
    height: auto;
    width: 100%;
    margin: 0 auto;
  }
  .bezel { width: 100%; }
  .console {
    width: 100%;
    max-width: 720px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .card-connect { grid-column: 1 / -1; }
  .foot { margin-top: 8px; }
}

@media (max-width: 720px) {
  .app { padding: 12px 12px 20px; }
  .masthead { padding-bottom: 12px; }
  .brand-text h1 { font-size: 14px; }
  .brand-text p { font-size: 9.5px; letter-spacing: .14em; }
  .brand-mark { width: 36px; height: 36px; }
  .link-state { font-size: 10.5px; padding: 6px 9px; }

  .screen {
    height: auto;
    width: min(100%, 430px);
    max-width: 100%;
    margin: 0 auto;
  }
  .bezel { width: 100%; }

  .console { grid-template-columns: 1fr; }
  .foot { flex-direction: column; gap: 6px; }

  .shop-grid { grid-template-columns: 1fr 1fr; padding: 12px 14px; }
  .shop-head { padding: 16px 14px 12px; }
  .shop-foot { padding: 12px 14px; }
  .shop-foot p { display: none; }
  .shop-foot .btn { margin-left: 0; width: 100%; }
}

@media (max-width: 430px) {
  .shop-grid { grid-template-columns: 1fr; gap: 8px; }
  .modal-card { max-height: 92vh; }
  .wallet b { font-size: 20px; }
  .item { padding: 10px; gap: 5px; }
  .item-desc { min-height: 0; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .layer, .modal, .status[data-tone="busy"]::before, .win-title { animation: none; }
  .axis-track i { transition: none; }
  * { scroll-behavior: auto; }
}
