* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Press Start 2P', monospace;
  background: #0d0d1a;
  overflow: hidden;
  height: 100dvh;
}

.screen {
  display: none;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.screen.active { display: flex; }

/* HUB SCREEN */
#hub-screen {
  background-color: #5a3fa0;
  background-image:
    radial-gradient(circle, rgba(0,0,0,0.3) 2px, transparent 2px),
    linear-gradient(rgba(0,0,0,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 40px 40px;
}

/* MINE SCREEN */
#mine-screen {
  background-color: #1a4a5a;
  background-image:
    linear-gradient(135deg, rgba(0,0,0,0.15) 25%, transparent 25%),
    linear-gradient(225deg, rgba(0,0,0,0.15) 25%, transparent 25%),
    linear-gradient(315deg, rgba(0,0,0,0.15) 25%, transparent 25%),
    linear-gradient(45deg, rgba(0,0,0,0.15) 25%, transparent 25%);
  background-size: 20px 20px;
}

/* HEADERS */
/* ── HUB HEADER ── */
.hub-header {
  background: rgba(0,0,0,0.55);
  border-bottom: 4px solid #111;
  flex-shrink: 0;
}

.hub-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
}

/* ── HUD chips (gold / timer) ── */
.hud-gold, .hud-timer {
  background: #2d2d2d;
  border: 3px solid #111;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ffd700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── XP / Level row (horizontal) ── */
.hud-level-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

#level-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

.xp-bar-outer {
  flex: 1;
  min-width: 48px;
  background: #1a1a2e;
  border: 3px solid #111;
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}

.xp-bar-fill {
  background: #a24cff;
  height: 100%;
  width: var(--xp-pct, 0%);
  transition: width 0.5s ease;
}

.xp-bar-fill.levelup {
  animation: levelup-flash 0.6s ease;
}

#xp-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Tab buttons ── */
.hub-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.tab-btn {
  background: #3a2a70;
  border: 3px solid #111;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tab-btn:hover, .tab-btn.active {
  background: #5a3fa0;
  border-color: #ffd700;
}
.tab-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #aaa;
  line-height: 1;
  white-space: nowrap;
}
.tab-btn.active .tab-label,
.tab-btn:hover .tab-label { color: #fff; }

/* HUB BODY (ore sidebar + main content) */
.hub-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

.hub-main-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

/* ORE SIDEBAR */
#ore-sidebar {
  width: 52px;
  background: rgba(0,0,0,0.4);
  border-right: 3px solid #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  gap: 10px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#ore-sidebar::-webkit-scrollbar { display: none; }

.ore-sidebar-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.ore-sidebar-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
.ore-sidebar-count {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #fff;
  text-align: center;
}

/* Flying ore animation */
.ore-fly-el {
  position: fixed;
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 500;
  pointer-events: none;
}

/* HUB MAIN */
.hub-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* UPGRADE TREE */
#tab-upgrades {
  flex: 1;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  scrollbar-width: none;
}

/* SETTINGS TAB */
#tab-settings {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: 80px;
}

#tab-upgrades::-webkit-scrollbar {
  display: none;
}

#tab-upgrades.is-dragging {
  cursor: grabbing;
}

.upgrade-subtabs {
  display: flex;
  gap: 4px;
  padding: 4px 12px 8px;
  border-top: 2px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.subtab-btn {
  background: #2a1a50;
  border: 2px solid #333;
  border-radius: 4px;
  padding: 5px 10px;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #aaa;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.subtab-btn.active,
.subtab-btn:hover {
  background: #5a3fa0;
  border-color: #a24cff;
  color: #fff;
}

.upgrade-tree-wrap {
  --node-size: 92px;
  position: relative;
  display: flex;
  justify-content: center;
  width: max-content;
  margin: 0 auto;
  padding: 24px;
}

.upgrade-tree {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.upgrade-tree[data-subtab="basic"] {
  grid-template-columns: repeat(3, var(--node-size, 92px));
  grid-template-areas:
    ".          stone_upg  ."
    "regen      spd        gold_upg"
    "acc        .          expl"
    "spstone    .          .";
}

.upgrade-tree[data-subtab="mining"] {
  grid-template-columns: repeat(3, var(--node-size, 92px));
  grid-template-areas:
    ".             usilver      ."
    "silver_drill  sand         spsilver"
    ".             ugold        ."
    "gold_plating  spgold       focus";
}

.upgrade-tree[data-subtab="crystal"] {
  grid-template-columns: repeat(3, var(--node-size, 92px));
  grid-template-areas:
    "myst_aura    umystrile    haul"
    ".            .            spmyst"
    ".            uplatinum    ."
    "platinum_drill spplatinum refinery";
}

.upgrade-tree[data-subtab="legend"] {
  grid-template-columns: repeat(3, var(--node-size, 92px));
  grid-template-areas:
    ".            uaether        ."
    "aether_aura  spaether       fortune_chain";
}

.upgrade-connectors {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}


.upgrade-node {
  width: var(--node-size, 92px);
  height: var(--node-size, 92px);
  background: #4a4a5a;
  border: 4px solid #222;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.1s, border-color 0.1s;
  position: relative;
  font-family: 'Press Start 2P', monospace;
  user-select: none;
}

.upgrade-node .node-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.upgrade-node .node-icon svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 30px;
  height: 30px;
}
.upgrade-node .node-level {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #aaa;
  margin-top: 3px;
}
.upgrade-node .node-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: #ccc;
  text-align: center;
  max-width: 100%;
  padding: 0 2px;
  word-break: break-word;
  line-height: 1.3;
  margin-top: 2px;
}
.upgrade-node.locked .node-name {
  color: #666;
}
.upgrade-node .node-cost {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #ffd700;
  margin-top: 4px;
  word-break: break-word;
  text-align: center;
  max-width: 100%;
  padding: 0 2px;
}

.upgrade-node.locked {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
  filter: grayscale(1);
  border-color: #333;
}

.upgrade-node.available {
  background: #5a5a6e;
  border-color: #888;
}

.upgrade-node.available.can-afford {
  border-color: #a24cff;
  animation: node-pulse 1.2s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { box-shadow: 0 0 4px #a24cff; }
  50%       { box-shadow: 0 0 14px #a24cff, 0 0 24px rgba(162,76,255,0.4); }
}

.upgrade-node.available:hover {
  transform: scale(1.08);
  border-color: #ffd700;
  background: #6a6a7e;
}

#upgrade-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  max-width: 320px;
  padding: 12px 14px;
  background: rgba(18, 18, 24, 0.96);
  border: 3px solid #ffd700;
  border-radius: 6px;
  color: #f3f0d2;
  font-family: 'Press Start 2P', monospace !important;
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

#upgrade-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.upgrade-tooltip-name {
  font-family: 'Press Start 2P', monospace !important;
  font-size: 13px;
  color: #ffd700;
  margin-bottom: 8px;
}

.upgrade-tooltip-desc,
.upgrade-tooltip-meta,
.upgrade-tooltip-status {
  font-family: 'Press Start 2P', monospace !important;
  color: #e6e6e6;
}

.upgrade-tooltip-status {
  margin-top: 8px;
  color: #9fe870;
}

.upgrade-node.purchased {
  background: #3a3a28;
  border-color: #ffd700;
}

.upgrade-node.maxed {
  background: #4a4a20;
  border-color: #ffd700;
  animation: node-glow 1.5s ease-in-out infinite;
}

/* Grid areas for nodes */
/* basic */
[data-id="acc"]       { grid-area: acc; }
[data-id="regen"]     { grid-area: regen; }
[data-id="stone_upg"] { grid-area: stone_upg; }
[data-id="spd"]       { grid-area: spd; }
[data-id="sand"]      { grid-area: sand; }
[data-id="gold_upg"]  { grid-area: gold_upg; }
[data-id="expl"]      { grid-area: expl; }
[data-id="spstone"]   { grid-area: spstone; }
/* mining */
[data-id="usilver"]      { grid-area: usilver; }
[data-id="spsilver"]     { grid-area: spsilver; }
[data-id="silver_drill"] { grid-area: silver_drill; }
[data-id="ugold"]        { grid-area: ugold; }
[data-id="spgold"]       { grid-area: spgold; }
[data-id="gold_plating"] { grid-area: gold_plating; }
[data-id="focus"]        { grid-area: focus; }
/* crystal */
[data-id="umystrile"]      { grid-area: umystrile; }
[data-id="spmyst"]         { grid-area: spmyst; }
[data-id="myst_aura"]      { grid-area: myst_aura; }
[data-id="haul"]           { grid-area: haul; }
[data-id="uplatinum"]      { grid-area: uplatinum; }
[data-id="spplatinum"]     { grid-area: spplatinum; }
[data-id="platinum_drill"] { grid-area: platinum_drill; }
[data-id="refinery"]       { grid-area: refinery; }
/* legend */
[data-id="uaether"]       { grid-area: uaether; }
[data-id="spaether"]      { grid-area: spaether; }
[data-id="aether_aura"]   { grid-area: aether_aura; }
[data-id="fortune_chain"] { grid-area: fortune_chain; }

/* STATS PANEL */
.stats-panel {
  background: #2d2d2d;
  border: 4px solid #111;
  border-radius: 6px;
  padding: 16px;
  max-width: 400px;
  margin: 0 auto;
}

.stats-title {
  font-size: 11px;
  color: #ffd700;
  margin-bottom: 16px;
  text-align: center;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.stats-table td {
  font-family: 'Press Start 2P', monospace;
  padding: 8px 6px;
  font-size: 8px;
  border-bottom: 2px solid #444;
  color: #ccc;
}

.stats-table td:last-child {
  color: #ffd700;
  text-align: right;
}

.reset-btn {
  display: block;
  margin: 0 auto;
  font-size: 9px;
}

/* BUTTONS */
.px-btn-green, .px-btn-red {
  position: fixed;
  bottom: 16px;
  right: 16px;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 12px 18px;
  border-radius: 6px;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.1s, filter 0.1s;
  border: 4px solid;
}

.px-btn-green {
  background: #3a9e5f;
  border-color: #1a5030;
  color: #fff;
}

.px-btn-red {
  background: #9e3a3a;
  border-color: #501a1a;
  color: #fff;
}

.px-btn-green:hover, .px-btn-red:hover {
  transform: scale(1.05);
  filter: brightness(1.15);
}

.px-btn-green:active, .px-btn-red:active {
  transform: scale(0.97);
}

/* Non-fixed reset button */
.stats-panel .reset-btn {
  position: static;
  width: 100%;
}

/* MINE BODY (sidebar + canvas) */
.mine-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

#mine-ore-sidebar {
  width: 52px;
  background: rgba(0,0,0,0.4);
  border-right: 3px solid #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  gap: 10px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#mine-ore-sidebar::-webkit-scrollbar { display: none; }

/* MINE CANVAS WRAP */
.mine-canvas-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 20px 20px 92px;
}

#mine-canvas {
  touch-action: none;
  display: block;
}

/* Inline pixel-art icon spans */
[data-px-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
[data-px-icon] svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 24px;
  height: 24px;
  display: block;
}
.px-btn-green [data-px-icon] svg,
.px-btn-red [data-px-icon] svg {
  width: 18px;
  height: 18px;
}
.tab-btn [data-px-icon] svg {
  width: 20px;
  height: 20px;
}
.stats-title [data-px-icon] svg {
  width: 18px;
  height: 18px;
}
.stats-table td [data-px-icon] svg {
  width: 16px;
  height: 16px;
}
.result-box [data-px-icon] svg {
  width: 16px;
  height: 16px;
}

/* Pixel-art image icons – spiegeln SVG-Größen */
[data-px-icon] img.pixel-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}
.px-btn-green [data-px-icon] img.pixel-icon,
.px-btn-red [data-px-icon] img.pixel-icon {
  width: 18px;
  height: 18px;
}
.tab-btn [data-px-icon] img.pixel-icon {
  width: 20px;
  height: 20px;
}
.stats-title [data-px-icon] img.pixel-icon {
  width: 18px;
  height: 18px;
}
.stats-table td [data-px-icon] img.pixel-icon,
.result-box [data-px-icon] img.pixel-icon {
  width: 16px;
  height: 16px;
}

img, .pixel-icon, svg {
  image-rendering: pixelated !important;
  image-rendering: crisp-edges !important;
  -ms-interpolation-mode: nearest-neighbor !important;
}

.upgrade-node .node-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px; /* Even multiple */
  height: 64px;
  margin-bottom: 4px;
}

.upgrade-node .node-icon img, 
.upgrade-node .node-icon svg {
  width: 32px; /* Fixed integer size */
  height: 32px;
  transform: scale(2); /* Integer scale */
}

/* ANIMATIONS */
@keyframes node-glow {
  0%, 100% { box-shadow: 0 0 6px #ffd700, 0 0 12px rgba(255,215,0,0.4); }
  50%       { box-shadow: 0 0 16px #ffd700, 0 0 28px rgba(255,215,0,0.6); }
}

@keyframes levelup-flash {
  0%, 100% { filter: brightness(1); background: #a24cff; }
  30%       { filter: brightness(2.5); background: #fff; }
  60%       { filter: brightness(1.8); background: #ffd700; }
}

/* RESULT OVERLAY */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  flex-direction: column;
  gap: 16px;
}

.confirm-msg {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ccc;
  line-height: 1.9;
  margin: 12px 0 20px;
}

.result-box {
  background: #2d2d2d;
  border: 4px solid #ffd700;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  max-width: 320px;
  width: 90%;
}

.result-box h2 {
  font-size: 14px;
  color: #ffd700;
  margin-bottom: 16px;
}

.result-box .result-stat {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ccc;
  margin: 8px 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.result-box .result-stat span:last-child {
  color: #ffd700;
}

.result-box .result-levelup {
  font-size: 11px;
  color: #a24cff;
  margin-top: 12px;
  animation: levelup-flash 0.6s ease;
}

/* Result-Screen entrance animation */
@keyframes result-enter {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.result-box {
  animation: result-enter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
}

/* Section labels ("THIS RUN" / "TOTALS") */
.result-section-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #888;
  text-align: left;
  margin: 4px 0 8px;
  letter-spacing: 1px;
}

/* Hero stat: Gold Earned */
.result-stat.result-hero {
  font-size: 11px;
  margin-bottom: 10px;
  padding: 8px;
  background: rgba(255, 215, 0, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(255, 215, 0, 0.25);
}
.result-stat.result-hero span:last-child {
  font-size: 13px;
  color: #ffd700;
}

/* Divider */
.result-divider {
  border: none;
  border-top: 2px solid #444;
  margin: 12px 0;
}

/* Level-up banner */
.result-levelup {
  background: rgba(162, 76, 255, 0.18);
  border: 2px solid #a24cff;
  border-radius: 4px;
  padding: 8px;
  margin-top: 12px;
  text-align: center;
}

/* Return button inside the box */
.result-box .px-btn-green {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 16px;
}

.result-box .px-btn-red {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 0;
}

.result-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

/* Resource label colours */
.result-stat.res-silver   span:first-child { color: #c0c0c0; }
.result-stat.res-gold     span:first-child { color: #ffd700; }
.result-stat.res-mystrile span:first-child { color: #33ccff; }
.result-stat.res-platinum span:first-child { color: #e5e4e2; }
.result-stat.res-aether   span:first-child { color: #9f5bff; }

/* Scrollbar */
.hub-main::-webkit-scrollbar { width: 6px; }
.hub-main::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.hub-main::-webkit-scrollbar-thumb { background: #a24cff; border-radius: 3px; }

/* MUTE BUTTON */
#btn-mute {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  background: #2d2d2d;
  border: 3px solid #555;
  border-radius: 6px;
  cursor: pointer;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.1s, transform 0.1s;
}

#btn-mute:hover {
  border-color: #ffd700;
  transform: scale(1.08);
}

#btn-mute:active {
  transform: scale(0.95);
}

#btn-mute svg,
#btn-mute img {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}

/* MINE TIMER OVERLAY */
#mine-timer-overlay {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 20;
  background: rgba(0,0,0,0.65);
  border: 3px solid #ffd700;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: 'Press Start 2P', monospace;
  font-size: 28px;
  color: #ffd700;
  pointer-events: none;
  line-height: 1;
}

@keyframes timer-urgent {
  0%, 100% { border-color: #ffd700; color: #ffd700; background: rgba(0,0,0,0.65); }
  50%       { border-color: #ff4444; color: #ff4444; background: rgba(90,0,0,0.85); transform: scale(1.06); }
}
#mine-timer-overlay.urgent {
  animation: timer-urgent 0.5s ease-in-out infinite;
}

/* ── Resource strip (second row, only when unlocked) ── */
.hud-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  padding: 5px 12px 7px;
  border-top: 1px solid rgba(255,255,255,0.08);
  overflow-x: auto;
  scrollbar-width: none;
}
.hud-resources::-webkit-scrollbar { display: none; }

.res-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #ccc;
  white-space: nowrap;
}
.res-chip svg { width: 14px !important; height: 14px !important; vertical-align: middle; }
.res-chip .res-amt {
  color: #fff;
}

/* ── REWARD BAR ── */
.reward-bar {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 2px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  background: rgba(0,0,0,0.25);
}
.reward-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 7px 10px;
  border-radius: 4px;
  border: 3px solid;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  white-space: nowrap;
  overflow: hidden;
}
.reward-btn--ready {
  background: #3a2a70;
  border-color: #ffd700;
  color: #ffd700;
  animation: reward-pulse 1.4s ease-in-out infinite;
}
.reward-btn--ready:hover { transform: scale(1.04); filter: brightness(1.2); }
.reward-btn--ready:active { transform: scale(0.97); }
.reward-btn--waiting {
  background: #1e1e30;
  border-color: #333;
  color: #666;
  cursor: default;
  opacity: 0.7;
}
.reward-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #a24cff;
  color: #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  font-size: 7px;
  flex-shrink: 0;
  animation: reward-badge-pop 0.8s ease-in-out infinite;
}
.reward-timer { color: #888; font-size: 7px; }
.reward-icon { display: inline-flex; align-items: center; }
#reward-btn-daily  .reward-icon svg { filter: hue-rotate(-30deg) saturate(1.4); }
#reward-btn-hourly .reward-icon svg { filter: hue-rotate(160deg) saturate(1.5) brightness(1.2); }
@keyframes reward-pulse {
  0%, 100% { box-shadow: 0 0 4px #ffd700; }
  50%       { box-shadow: 0 0 14px #ffd700, 0 0 24px rgba(255,215,0,0.35); }
}
@keyframes reward-badge-pop {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.3); }
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .upgrade-tree-wrap { --node-size: 72px; }
  .upgrade-node .node-icon svg { width: 20px; height: 20px; }
  .hub-header-row, .mine-header { padding: 6px 8px; gap: 6px; }
  .hud-gold, .hud-timer { font-size: 9px; padding: 4px 8px; }
  #level-label { font-size: 8px; }
  #xp-label { display: none; }
  .mine-canvas-wrap { padding: 12px 12px 80px; }
}

/* ── LAPTOP / MEDIUM SCREEN ── */
@media (min-width: 768px) {
  .upgrade-tree-wrap { --node-size: 104px; }
  .upgrade-node .node-name  { font-size: 7px; }
  .upgrade-node .node-level { font-size: 9px; }
  .upgrade-node .node-cost  { font-size: 8px; }
  .mine-canvas-wrap { padding: 24px 32px 96px; }
}

/* ── HIGH-DPI / LARGE SCREEN SCALING ── */
@media (min-width: 1800px) {
  .upgrade-tree-wrap { --node-size: 140px; }
  .upgrade-node .node-icon svg { width: 44px; height: 44px; }
  .upgrade-node .node-name  { font-size: 10px; }
  .upgrade-node .node-level { font-size: 12px; }
  .upgrade-node .node-cost  { font-size: 11px; }
  .hud-gold, .hud-timer { font-size: 14px; padding: 7px 14px; }
  #level-label { font-size: 12px; }
  #xp-label    { font-size: 9px; }
  .xp-bar-outer { height: 16px; }
  .tab-btn { font-size: 20px; padding: 7px 12px; }
  .tab-label { font-size: 8px; }
  .tab-btn [data-px-icon] svg { width: 26px; height: 26px; }
  #btn-mute { width: 56px; height: 56px; }
  #btn-mute svg, #btn-mute img { width: 32px; height: 32px; }
  .result-box { max-width: 440px; }
  .result-box .result-stat { font-size: 13px; }
  .result-stat.result-hero { font-size: 13px; }
  .result-stat.result-hero span:last-child { font-size: 16px; }
  .result-box h2 { font-size: 17px; }
  .px-btn-green, .px-btn-red { font-size: 13px; padding: 14px 22px; }
  .res-chip { font-size: 10px; padding: 4px 10px; }
  .res-chip svg { width: 18px !important; height: 18px !important; }
  .result-section-label { font-size: 9px; }
  .px-btn-green [data-px-icon] svg,
  .px-btn-red   [data-px-icon] svg { width: 22px; height: 22px; }
  .result-box [data-px-icon] svg   { width: 20px; height: 20px; }
}
/* ── TUTORIAL OVERLAY ── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.tutorial-overlay.visible { display: flex; }

.tutorial-box {
  background: #2d2d2d;
  border: 4px solid #a24cff;
  border-radius: 8px;
  padding: 2.5rem 2rem 1.5rem;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  max-width: min(480px, 92vw);
  width: 100%;
  animation: result-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tutorial-step { display: none; }
.tutorial-step.active { display: block; }

.tut-icon {
  margin-bottom: 1.2rem;
}
.tut-icon [data-px-icon] svg {
  width: 4rem !important;
  height: 4rem !important;
}

.tut-title {
  font-size: 1.1rem;
  color: #a24cff;
  margin-bottom: 1rem;
}

.tut-text {
  font-size: 0.85rem;
  color: #ccc;
  line-height: 2;
}

.tut-dots {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin: 1.4rem 0 1.2rem;
}

.tut-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #555;
  transition: background 0.2s;
}
.tut-dot.active { background: #a24cff; }

.tut-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
}

.tut-skip-btn {
  background: transparent;
  border: none;
  color: #666;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.5rem;
}
.tut-skip-btn:hover { color: #aaa; }

.tut-next-btn {
  position: static;
  font-size: 0.75rem;
  padding: 0.75rem 1.2rem;
}

@media (min-width: 2300px) {
  .upgrade-tree-wrap { --node-size: 180px; }
  .upgrade-node .node-icon svg { width: 56px; height: 56px; }
  .upgrade-node .node-name  { font-size: 13px; }
  .upgrade-node .node-level { font-size: 15px; }
  .upgrade-node .node-cost  { font-size: 13px; }
  .hud-gold, .hud-timer { font-size: 18px; padding: 9px 18px; }
  #level-label { font-size: 15px; }
  #xp-label    { font-size: 11px; }
  .xp-bar-outer { height: 20px; }
  .tab-btn { font-size: 24px; padding: 9px 16px; }
  .tab-label { font-size: 10px; }
  .tab-btn [data-px-icon] svg { width: 32px; height: 32px; }
  #btn-mute { width: 68px; height: 68px; }
  #btn-mute svg, #btn-mute img { width: 40px; height: 40px; }
  .result-box { max-width: 520px; }
  .result-box .result-stat { font-size: 16px; }
  .result-stat.result-hero { font-size: 16px; }
  .result-stat.result-hero span:last-child { font-size: 20px; }
  .result-box h2 { font-size: 20px; }
  .px-btn-green, .px-btn-red { font-size: 16px; padding: 16px 26px; }
  .res-chip { font-size: 13px; padding: 5px 12px; }
  .res-chip svg { width: 22px !important; height: 22px !important; }
  .result-section-label { font-size: 11px; }
  .px-btn-green [data-px-icon] svg,
  .px-btn-red   [data-px-icon] svg { width: 28px; height: 28px; }
  .result-box [data-px-icon] svg   { width: 24px; height: 24px; }
}

/* ── 4K / VERY LARGE SCREEN ── */
@media (min-width: 3400px) {
  .upgrade-tree-wrap { --node-size: 260px; }
  .upgrade-node .node-icon svg { width: 80px; height: 80px; }
  .upgrade-node .node-name  { font-size: 18px; }
  .upgrade-node .node-level { font-size: 21px; }
  .upgrade-node .node-cost  { font-size: 18px; }
  .hud-gold, .hud-timer { font-size: 26px; padding: 12px 26px; }
  #level-label { font-size: 22px; }
  #xp-label    { font-size: 16px; }
  .xp-bar-outer { height: 28px; }
  .tab-btn { font-size: 34px; padding: 12px 22px; }
  .tab-label { font-size: 14px; }
  .tab-btn [data-px-icon] svg { width: 44px; height: 44px; }
  #btn-mute { width: 96px; height: 96px; bottom: 24px; left: 24px; }
  #btn-mute svg, #btn-mute img { width: 58px; height: 58px; }
  [data-px-icon] svg { width: 36px; height: 36px; }
  .result-box { max-width: 740px; }
  .result-box .result-stat { font-size: 22px; }
  .result-stat.result-hero { font-size: 22px; }
  .result-stat.result-hero span:last-child { font-size: 28px; }
  .result-box h2 { font-size: 28px; }
  .px-btn-green, .px-btn-red { font-size: 22px; padding: 22px 36px; }
  .res-chip { font-size: 18px; padding: 7px 16px; }
  .res-chip svg { width: 30px !important; height: 30px !important; }
  .result-section-label { font-size: 16px; }
  .px-btn-green [data-px-icon] svg,
  .px-btn-red   [data-px-icon] svg { width: 40px; height: 40px; }
  .result-box [data-px-icon] svg   { width: 34px; height: 34px; }
  .subtab-btn { font-size: 18px; padding: 10px 16px; }
  .subtab-btn [data-px-icon] svg { width: 30px; height: 30px; }
}

/* ── BETA OVERLAY ── */
.beta-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.beta-overlay.hidden { display: none; }

.beta-box {
  background: #2d2d2d;
  border: 4px solid #ffd700;
  border-radius: 8px;
  padding: 2rem 1.5rem;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  max-width: min(600px, 92vw);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: result-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.beta-badge {
  background: #ffd700;
  color: #1a1a2e;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 7px 18px;
  border-radius: 4px;
  letter-spacing: 2px;
}

.beta-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 20px;
  color: #ffd700;
}

.beta-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: #ccc;
  line-height: 2.4;
}

.beta-ok-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 10px 22px;
  border-radius: 6px;
  cursor: pointer;
  border: 3px solid #1a5030;
  background: #3a9e5f;
  color: #fff;
  margin-top: 4px;
  transition: transform 0.1s, filter 0.1s;
}
.beta-ok-btn:hover { transform: scale(1.05); filter: brightness(1.15); }
.beta-ok-btn:active { transform: scale(0.97); }

/* ── FEEDBACK PANEL ── */
.feedback-panel {
  background: #2d2d2d;
  border: 4px solid #111;
  border-radius: 6px;
  padding: 16px;
  max-width: 400px;
  margin: 12px auto 0;
}

.feedback-textarea {
  width: 100%;
  min-height: 90px;
  padding: 8px;
  border-radius: 4px;
  border: 2px solid #555;
  background: #1a1a2e;
  color: #eee;
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.feedback-submit-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 3px solid #1a5030;
  background: #3a9e5f;
  color: #fff;
  display: block;
  margin: 0 auto;
  transition: transform 0.1s, filter 0.1s;
}
.feedback-submit-btn:hover { transform: scale(1.05); filter: brightness(1.15); }
.feedback-submit-btn:active { transform: scale(0.97); }
.feedback-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }

.feedback-status {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  text-align: center;
  min-height: 16px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.feedback-status.ok  { color: #3a9e5f; }
.feedback-status.err { color: #e05252; }

/* ── PRESTIGE SYSTEM ─────────────────────────────────── */

.prestige-gems-hud {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #c084fc;
  background: rgba(162, 76, 255, 0.2);
  border: 2px solid #7c3aed;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 4px;
  white-space: nowrap;
}

.prestige-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 3px solid #7c3aed;
  background: linear-gradient(135deg, #4c1d95, #7c3aed);
  color: #e9d5ff;
  transition: transform 0.1s, filter 0.1s, opacity 0.1s;
  white-space: nowrap;
}
.prestige-btn:hover:not(.prestige-locked) { transform: scale(1.05); filter: brightness(1.2); }
.prestige-btn:active:not(.prestige-locked) { transform: scale(0.97); }
.prestige-btn.prestige-locked {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: #44335a;
  background: #2a1a3a;
  color: #7c6a8a;
}

.subtab-prestige {
  font-size: 14px;
  line-height: 1;
}

.prestige-node {
  border-color: #7c3aed !important;
}
.prestige-node.can-afford {
  box-shadow: 0 0 10px rgba(162, 76, 255, 0.7) !important;
  border-color: #c084fc !important;
}
.prestige-node.maxed {
  background: linear-gradient(135deg, #4c1d95, #2e1065) !important;
  border-color: #7c3aed !important;
  color: #c084fc !important;
}
