:root {
  --bg-desk: #0d1117;
  --calc-body: #1f242c;
  --calc-body-dark: #151920;
  --calc-lcd-bg: #b9c9ad;
  --calc-lcd-text: #162216;
  --calc-lcd-border: #2c3540;

  --neon-bg: #070913;
  --neon-surface: #0f1526;
  --neon-card: #131b31;
  --neon-border: #243258;
  --cyan: #00f0ff;
  --magenta: #ff2a85;
  --gold: #ffd166;
  --green: #2ee59d;
  --purple: #9b5de5;
  --red: #ff4d6d;
  --text-main: #eef3ff;
  --text-dim: #8a99c0;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg-desk);
  color: var(--text-main);
}

.hidden {
  display: none !important;
}

/* =========================================================
   CALCULATOR SKINS
   ========================================================= */
body.theme-amber .calc-lcd-frame .calc-lcd-screen {
  background: #e3c07d;
}
body.theme-amber .calc-expr-input,
body.theme-amber .calc-result-line {
  color: #2b1d07;
}

body.theme-cyber .calc-shell {
  background: linear-gradient(160deg, #171a2d, #0d101d);
  border-color: #2d4278;
  box-shadow: 0 24px 60px rgba(0, 240, 255, 0.14);
}
body.theme-cyber .calc-lcd-frame .calc-lcd-screen {
  background: #0b1824;
  border-color: #00f0ff;
}
body.theme-cyber .calc-expr-input,
body.theme-cyber .calc-result-line {
  color: #00f0ff;
}
body.theme-cyber .calc-lcd-status {
  color: #82d9ff;
}

body.theme-gold .calc-shell {
  background: linear-gradient(160deg, #2b2416, #18140d);
  border-color: #9e7b2f;
}
body.theme-gold .key-eq {
  background: linear-gradient(180deg, #e7b949, #b5841d);
  color: #161005;
}

/* =========================================================
   VIEW 1: STEALTH SCIENTIFIC CALCULATOR
   ========================================================= */
.calc-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 20% 20%, #192231 0%, #0b0e14 70%);
}

.calc-shell {
  width: 100%;
  max-width: 410px;
  background: linear-gradient(165deg, #272d38 0%, #181c24 100%);
  border: 2px solid #384152;
  border-radius: 22px;
  padding: 18px 18px 14px;
  box-shadow:
    0 24px 55px rgba(0, 0, 0, 0.65),
    inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

.calc-bezel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.calc-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-logo {
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 16px;
  color: #e4e9f2;
}

.brand-model {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  font-style: italic;
}

.brand-sub {
  font-size: 9px;
  letter-spacing: 1px;
  color: #64748b;
}

.calc-solar {
  width: 96px;
  height: 28px;
  background: #2b211f;
  border: 2px solid #13161c;
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 2px;
}

.solar-cell {
  background: linear-gradient(180deg, #433230, #2b1f1e);
  border-radius: 1px;
}

.calc-lcd-frame {
  background: #101319;
  border: 3px solid var(--calc-lcd-border);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 14px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.7);
}

.calc-lcd-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #7c899e;
}

.lcd-badge {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0.4;
}

.lcd-badge.active {
  opacity: 1;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.14);
}

.lcd-ref-btn {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
}

.lcd-ref-btn + .lcd-ref-btn {
  margin-left: 4px;
}

.lcd-ref-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.calc-lcd-screen {
  background: var(--calc-lcd-bg);
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
  font-family: 'Consolas', 'Courier New', monospace;
}

.calc-expr-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--calc-lcd-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.calc-result-line {
  text-align: right;
  font-size: 26px;
  font-weight: 800;
  color: var(--calc-lcd-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-tape {
  margin-top: 8px;
  background: #141922;
  border: 1px solid #2b3446;
  border-radius: 6px;
  padding: 6px 8px;
  max-height: 120px;
  overflow-y: auto;
  font-family: 'Consolas', monospace;
  font-size: 11px;
}

.tape-header {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  margin-bottom: 4px;
  font-weight: 700;
}

.tape-header button {
  background: none;
  border: none;
  color: #f87171;
  cursor: pointer;
  font-size: 11px;
}

.tape-item {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-radius: 3px;
  color: #cbd5e1;
  cursor: pointer;
}

.tape-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.calc-keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.key {
  border: none;
  border-radius: 8px;
  padding: 11px 4px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #f1f5f9;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: transform 0.06s, filter 0.12s;
  user-select: none;
}

.key:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.key:hover {
  filter: brightness(1.12);
}

.key-sci {
  background: linear-gradient(180deg, #323946, #252b36);
  font-size: 12px;
  color: #cbd5e1;
}

.key-num {
  background: linear-gradient(180deg, #4b5565, #37404e);
  font-size: 16px;
}

.key-op {
  background: linear-gradient(180deg, #3c4b64, #2b374b);
  font-size: 17px;
  color: #93c5fd;
}

.key-fn {
  background: linear-gradient(180deg, #9a4f25, #763a18);
  font-size: 12px;
}

.key-ac {
  background: linear-gradient(180deg, #b83a3a, #892525);
}

.calc-bottom-bar {
  margin-top: 10px;
}

.key-eq {
  width: 100%;
  padding: 12px;
  font-size: 20px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #ffffff;
}

.calc-footer-hint {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #64748b;
}

/* =========================================================
   UNLOCK OVERLAY
   ========================================================= */
.unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 7, 16, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
}

.unlock-glitch-box {
  width: min(480px, 90vw);
  padding: 32px;
  border: 2px solid var(--cyan);
  border-radius: 16px;
  background: #0b1124;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.35);
  text-align: center;
}

.unlock-code {
  font-family: monospace;
  color: var(--green);
  letter-spacing: 3px;
  font-size: 13px;
  margin-bottom: 10px;
}

.unlock-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--cyan);
  margin-bottom: 18px;
}

.unlock-bar {
  height: 10px;
  background: #17213d;
  border-radius: 999px;
  overflow: hidden;
}

.unlock-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--gold));
  animation: unlockProgress 0.85s ease-out forwards;
}

@keyframes unlockProgress {
  to { width: 100%; }
}

/* =========================================================
   VIEW 2: SECRET 20-GAME HUB
   ========================================================= */
.hub-view {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, rgba(0, 240, 255, 0.1), transparent 40%),
    radial-gradient(circle at 88% 15%, rgba(255, 42, 133, 0.1), transparent 42%),
    var(--neon-bg);
  padding: 18px 24px 40px;
}

.hub-header {
  max-width: 1400px;
  margin: 0 auto 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: rgba(15, 21, 38, 0.9);
  border: 1px solid var(--neon-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.hub-brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hub-logo-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cyan), var(--magenta));
  color: #050814;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.hub-title {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: 1px;
  font-weight: 900;
}

.hub-sub {
  font-size: 13px;
  color: var(--cyan);
  font-weight: 600;
}

.hub-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.stat-pill {
  background: #17213d;
  border: 1px solid #2b3a66;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.stat-credits strong { color: var(--cyan); }
.stat-stars strong { color: var(--gold); }
.stat-level strong { color: var(--green); }

.xp-bar-wrap {
  position: relative;
  width: 150px;
  height: 20px;
  background: #11182c;
  border: 1px solid #2b3a66;
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  transition: width 0.3s ease;
}

.xp-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  text-shadow: 0 1px 2px #000;
}

.hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hub-btn, .stage-btn {
  background: #18223d;
  color: var(--text-main);
  border: 1px solid #304270;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hub-btn:hover, .stage-btn:hover {
  border-color: var(--cyan);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 240, 255, 0.18);
}

.btn-accent {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: transparent;
}

.btn-boss {
  background: linear-gradient(135deg, #be123c, #9f1239);
  border-color: #fb7185;
}

/* Controls Row */
.hub-controls {
  max-width: 1400px;
  margin: 0 auto 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-tab {
  background: #121a30;
  border: 1px solid #28365c;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-tab:hover {
  color: var(--text-main);
  border-color: var(--cyan);
}

.cat-tab.active {
  background: var(--cyan);
  color: #06101f;
  border-color: var(--cyan);
}

.search-wrap input {
  width: 260px;
  max-width: 100%;
  background: #11182c;
  border: 1px solid #2b3a66;
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--cyan);
}

/* 20-Game Grid */
.game-grid {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 16px;
}

.game-card {
  position: relative;
  background: linear-gradient(170deg, #151e37 0%, #0e1426 100%);
  border: 1px solid var(--neon-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--cyan);
  box-shadow: 0 12px 28px rgba(0, 240, 255, 0.16);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.card-fav-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #4b5c86;
  padding: 2px 4px;
}

.card-fav-btn.active {
  color: var(--gold);
}

.card-title-block h3 {
  margin: 0 0 3px;
  font-size: 16px;
  font-weight: 800;
}

.card-cat {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.card-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
  flex: 1;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tag {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.22);
  color: #a5f3fc;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
}

.card-stars {
  color: var(--gold);
  letter-spacing: 2px;
}

.card-best {
  color: #cbd5e1;
  font-weight: 700;
}

/* =========================================================
   ACTIVE GAME STAGE
   ========================================================= */
.game-stage {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #060913;
  display: flex;
  flex-direction: column;
}

.stage-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #0d1428;
  border-bottom: 1px solid #243258;
}

.stage-left, .stage-right, .stage-hud {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-title-group h2 {
  margin: 0;
  font-size: 17px;
}

.stage-genre {
  font-size: 11px;
  color: var(--cyan);
}

.hud-metric {
  background: #141e38;
  border: 1px solid #273761;
  padding: 4px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.hud-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.8px;
}

.hud-metric strong {
  font-size: 14px;
  color: var(--text-main);
}

.stage-help-banner {
  background: #111b36;
  border-bottom: 1px solid #283a68;
  padding: 10px 20px;
  font-size: 13px;
  color: #cbd5e1;
}

.game-mount {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

/* =========================================================
   MODALS & SHOP
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(4, 7, 15, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: min(620px, 95vw);
  max-height: 86vh;
  overflow-y: auto;
  background: #11192e;
  border: 1px solid #2e4070;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #233156;
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px 18px;
}

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

.formula-item {
  background: #0c1222;
  border: 1px solid #243252;
  border-radius: 10px;
  padding: 10px 12px;
}

.formula-name {
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
  margin-bottom: 4px;
}

.formula-item code {
  font-family: Consolas, monospace;
  color: #e2e8f0;
  font-size: 13px;
}

.formula-calibration {
  border-color: #2f5547;
  background: #0b1b19;
}

.formula-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.formula-note {
  margin: 6px 0 0;
  font-size: 11px;
  color: #94a3b8;
}

.btn-mini {
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.shop-item {
  background: #0c1224;
  border: 1px solid #273761;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.shop-item h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--cyan);
}

.shop-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.setting-block {
  margin-bottom: 18px;
}

.setting-block label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.setting-row {
  display: flex;
  gap: 8px;
}

.setting-row input {
  flex: 1;
  background: #0b1020;
  border: 1px solid #2b3a66;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-main);
  font-family: Consolas, monospace;
}

.setting-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 0 0;
}

/* =========================================================
   SHARED IN-GAME UI PRIMITIVES
   ========================================================= */
.g-wrap {
  width: 100%;
  max-width: 1060px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.g-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.g-panel {
  background: #10172d;
  border: 1px solid #283864;
  border-radius: 12px;
  padding: 12px;
}

.g-canvas {
  background: #070b17;
  border: 2px solid #263868;
  border-radius: 12px;
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
}

.g-btn {
  background: #1b284d;
  color: #eef3ff;
  border: 1px solid #354c88;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.g-btn:hover:not(:disabled) {
  border-color: var(--cyan);
  background: #233361;
}

.g-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.g-btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: transparent;
}

.g-btn-gold {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #fbbf24;
}

.g-btn-danger {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  border-color: #f87171;
}

.g-badge {
  background: #172342;
  border: 1px solid #2b3f73;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.g-overlay-card {
  background: rgba(11, 17, 36, 0.94);
  border: 2px solid var(--cyan);
  border-radius: 14px;
  padding: 18px 22px;
  text-align: center;
  max-width: 520px;
}
