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

:root {
  --panel: rgba(10, 22, 26, 0.78);
  --panel-edge: rgba(140, 220, 230, 0.18);
  --ink: #d9eef2;
  --dim: #8fb4bc;
  --gold: #ffd479;
  --teal: #6fe3d2;
}

html, body { width: 100%; height: 100%; }

body {
  overflow: hidden;
  background: #0a1216;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  user-select: none;
}

canvas { display: block; }

.hidden { display: none !important; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #14323c 0%, #08141a 70%);
}
#loading h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 64px; letter-spacing: 18px; text-indent: 18px;
  color: var(--teal); text-shadow: 0 0 40px rgba(111, 227, 210, 0.45);
}
#loading .sub { margin-top: 8px; color: var(--dim); font-style: italic; letter-spacing: 2px; }
.barwrap {
  width: 320px; height: 8px; margin-top: 36px; border-radius: 99px;
  background: rgba(255,255,255,0.08); overflow: hidden;
  border: 1px solid var(--panel-edge);
}
#bar { width: 0%; height: 100%; background: linear-gradient(90deg, #2b8f84, #6fe3d2); transition: width .15s; }
#loadmsg { margin-top: 14px; font-size: 13px; color: var(--dim); }

/* ---------- hud ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(4, 10, 12, 0.42) 100%);
}

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 6px; height: 6px;
  margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
#target {
  position: absolute; top: calc(50% + 22px); left: 50%; transform: translateX(-50%);
  font-size: 13px; letter-spacing: 1px; text-shadow: 0 1px 3px #000;
}

#topleft {
  position: absolute; top: 16px; left: 18px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  padding: 10px 16px; border-radius: 10px; backdrop-filter: blur(6px);
}
#topleft .title {
  font-family: Georgia, serif; letter-spacing: 6px; font-size: 15px; color: var(--teal);
}
#levname { font-size: 12px; color: var(--gold); margin-top: 2px; letter-spacing: 1px; }
#topleft .controls { font-size: 11px; color: var(--dim); margin-top: 6px; }

#stats {
  position: absolute; top: 16px; right: 18px; text-align: right;
  background: var(--panel); border: 1px solid var(--panel-edge);
  padding: 10px 16px; border-radius: 10px; backdrop-filter: blur(6px);
}
#essence { font-size: 22px; color: var(--gold); font-weight: 600; text-shadow: 0 0 14px rgba(255, 212, 121, .35); }
#harvest, #heartrow, #relicrow { font-size: 12px; color: var(--dim); margin-top: 3px; letter-spacing: 1px; }
#heartrow { color: #ff8d7a; }

#parts {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 80vw;
}
.chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  padding: 5px 10px; border-radius: 99px; font-size: 12px; backdrop-filter: blur(6px);
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }

#toasts {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast {
  background: var(--panel); border: 1px solid var(--panel-edge);
  padding: 8px 18px; border-radius: 99px; font-size: 14px; letter-spacing: 1px;
  animation: toastin .25s ease-out, toastout .6s ease-in 3.4s forwards;
  backdrop-filter: blur(6px); white-space: nowrap;
}
.toast.big { color: var(--gold); font-size: 16px; border-color: rgba(255, 212, 121, .4); }
@keyframes toastin { from { opacity: 0; transform: translateY(-10px) scale(.95); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-6px); } }

#lockhint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 12, 15, 0.45);
}
#lockhint span {
  font-size: 18px; letter-spacing: 4px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--panel-edge);
  padding: 14px 34px; border-radius: 99px; backdrop-filter: blur(4px);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- shop ---------- */
#shop {
  position: fixed; top: 50%; right: 26px; transform: translateY(-50%);
  width: 380px; max-height: 86vh; overflow-y: auto; z-index: 20;
  background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 14px; backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
  padding: 18px;
}
.shop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.shop-head h2 { font-family: Georgia, serif; font-size: 18px; letter-spacing: 2px; color: var(--teal); font-weight: 400; }
#shopclose, #resetbtn {
  background: none; border: 1px solid var(--panel-edge); color: var(--dim);
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px;
}
#shopclose:hover, #resetbtn:hover { color: var(--ink); border-color: var(--dim); }

#shopstats {
  font-size: 12px; color: var(--dim); line-height: 1.7;
  border-bottom: 1px solid var(--panel-edge); padding-bottom: 10px; margin-bottom: 10px;
}
#shopstats b { color: var(--ink); font-weight: 600; }

.upg {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid rgba(140,220,230,.08);
}
.upg .nm { font-size: 14px; }
.upg .lv { color: var(--teal); font-size: 12px; margin-left: 6px; }
.upg .ds { font-size: 11px; color: var(--dim); margin-top: 2px; }
.upg button {
  min-width: 92px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  background: rgba(111, 227, 210, 0.12); border: 1px solid rgba(111, 227, 210, 0.35);
  color: var(--teal); font-size: 13px; font-weight: 600;
}
.upg button:hover:not(:disabled) { background: rgba(111, 227, 210, 0.25); }
.upg button:disabled { opacity: .35; cursor: default; }
.upg button.maxed { border-color: var(--gold); color: var(--gold); }

#prestige { margin-top: 12px; }
#prestige .box {
  border: 1px solid rgba(255, 212, 121, .45); border-radius: 10px;
  padding: 12px; text-align: center; background: rgba(255, 212, 121, .06);
}
#prestige .box p { font-size: 12px; color: var(--dim); margin-bottom: 8px; line-height: 1.5; }
#prestige .box button {
  background: rgba(255, 212, 121, .15); border: 1px solid var(--gold); color: var(--gold);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 600;
}
#prestige .box button:hover { background: rgba(255, 212, 121, .3); }
#prestige .locked { font-size: 12px; color: var(--dim); text-align: center; padding: 8px; font-style: italic; }

.shop-foot {
  display: flex; justify-content: space-between; align-items: center; margin-top: 14px;
}
.shop-foot .hint { font-size: 11px; color: var(--dim); font-style: italic; }
