/* STAR FORGE — deep space theme */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #05060f; color: #dfe6ff;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 14px; pointer-events: none; z-index: 5;
}
#hud.hidden { display: none; }
.hud-score { font-size: 26px; font-weight: 800; letter-spacing: 1px; color: #ffe9a8; text-shadow: 0 0 14px rgba(255, 214, 90, .45); font-variant-numeric: tabular-nums; }
.hud-combo { font-size: 13px; font-weight: 700; color: #8ef6ff; text-shadow: 0 0 10px rgba(80, 230, 255, .5); min-height: 17px; }
.hud-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.hud-time { font-size: 15px; font-weight: 700; color: #aab5e0; font-variant-numeric: tabular-nums; }
.hud-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid rgba(140, 160, 255, .25);
  background: rgba(20, 26, 58, .55); color: #cdd6ff; font-size: 13px; cursor: pointer; backdrop-filter: blur(4px);
}

/* ---------- overlays & panels ---------- */
.ov {
  position: absolute; inset: 0; z-index: 10; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(4, 5, 14, .72); backdrop-filter: blur(6px);
  overflow-y: auto;
}
.ov.show { display: flex; }
.pnl {
  position: relative; width: 100%; max-width: 420px; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(16, 20, 46, .96), rgba(9, 11, 28, .96));
  border: 1px solid rgba(130, 150, 255, .18); border-radius: 22px;
  padding: 24px 22px; box-shadow: 0 18px 60px rgba(0, 0, 0, .55), inset 0 0 40px rgba(70, 90, 220, .06);
  scrollbar-width: thin;
}
.pnl.wide { max-width: 520px; }
.pnl.center { text-align: center; }
.x {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  border: none; background: rgba(120, 140, 255, .12); color: #aab5e0;
  border-radius: 10px; font-size: 19px; cursor: pointer; z-index: 2;
}
.pnl-title { font-size: 20px; font-weight: 800; margin-bottom: 12px; color: #eef2ff; }
.soft { color: #7d89b8; font-size: 12.5px; }

.logo { font-size: 40px; font-weight: 900; letter-spacing: 4px; color: #fff; text-shadow: 0 0 24px rgba(120, 150, 255, .5); }
.logo span { color: #ffd76a; text-shadow: 0 0 18px rgba(255, 205, 80, .8); }
.tagline { color: #93a0cf; font-size: 13.5px; margin: 8px 0 18px; }

button { font-family: inherit; }
.b-pri {
  display: inline-block; border: none; cursor: pointer;
  background: linear-gradient(135deg, #ffd76a, #ff9d5c); color: #3a2405;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  padding: 13px 34px; border-radius: 999px;
  box-shadow: 0 6px 24px rgba(255, 170, 60, .35);
  transition: transform .12s;
}
.b-pri:active { transform: scale(.95); }
.b-pri.hero { font-size: 19px; padding: 15px 48px; margin: 6px 0 4px; }
.b-sec {
  border: 1px solid rgba(140, 160, 255, .3); cursor: pointer;
  background: rgba(70, 90, 200, .14); color: #cdd6ff;
  font-size: 13.5px; font-weight: 700; padding: 10px 16px; border-radius: 999px;
  transition: background .15s;
}
.b-sec:active { background: rgba(90, 110, 230, .3); }
.b-sec.small { padding: 7px 14px; }
.daily-btn { display: block; margin: 10px auto 2px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.menu-row { margin-top: 18px; }

.howto { list-style: none; text-align: left; margin: 16px auto 0; max-width: 320px; }
.howto li { display: flex; gap: 10px; align-items: flex-start; color: #93a0cf; font-size: 13px; margin-bottom: 9px; }
.howto i { font-style: normal; font-size: 16px; }
.meta-row { margin-top: 18px; font-size: 13px; color: #5d688f; }
.meta-dot { margin: 0 8px; }
.text-link { color: #8fa3ff; text-decoration: none; }

/* ---------- level-up cards ---------- */
#panel-levelup { background: rgba(4, 5, 14, .55); }
.lv-pnl { max-width: 460px; background: none; border: none; box-shadow: none; padding: 10px; }
.lv-title { color: #ffe9a8; text-shadow: 0 0 20px rgba(255, 210, 90, .5); letter-spacing: 3px; }
.lv-num { color: #8ef6ff; }
.lv-cards { display: flex; gap: 12px; justify-content: center; align-items: stretch; flex-wrap: wrap; margin-top: 14px; }
.lv-card {
  flex: 1 1 120px; max-width: 146px; cursor: pointer; text-align: center;
  background: linear-gradient(165deg, rgba(24, 30, 66, .97), rgba(12, 15, 36, .97));
  border: 1px solid rgba(140, 160, 255, .3); border-radius: 18px; padding: 16px 10px 14px;
  transition: transform .14s, border-color .14s, box-shadow .14s;
  animation: cardIn .3s backwards;
}
.lv-card:nth-child(2) { animation-delay: .08s; }
.lv-card:nth-child(3) { animation-delay: .16s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px) scale(.92); } }
.lv-card:hover, .lv-card:active { transform: translateY(-4px); border-color: #ffd76a; box-shadow: 0 8px 30px rgba(255, 190, 70, .25); }
.lv-card .ic { font-size: 30px; line-height: 1; filter: drop-shadow(0 0 8px rgba(150, 180, 255, .6)); }
.lv-card .nm { font-size: 13.5px; font-weight: 800; color: #eef2ff; margin: 8px 0 2px; }
.lv-card .tier { font-size: 11px; font-weight: 700; color: #ffd76a; letter-spacing: 1px; }
.lv-card .ds { font-size: 11.5px; color: #93a0cf; margin-top: 6px; line-height: 1.45; }
.lv-card.new .tier { color: #8ef6ff; }

/* ---------- result ---------- */
.res-pnl { max-width: 440px; }
.final-score { font-size: 44px; font-weight: 900; color: #ffe9a8; text-shadow: 0 0 26px rgba(255, 210, 80, .5); margin: 2px 0 8px; font-variant-numeric: tabular-nums; }
#res-title.almost { color: #ff9d9d; text-shadow: 0 0 18px rgba(255, 90, 90, .6); letter-spacing: 2px; }
.res-stats { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: #93a0cf; margin-bottom: 8px; }
.res-stats b { color: #dfe6ff; font-size: 15px; display: block; }
.res-quip { font-size: 13px; color: #b9c5f2; font-style: italic; margin: 6px 0 4px; min-height: 18px; }
.res-build { font-size: 19px; letter-spacing: 4px; margin: 4px 0 10px; }
.submit-row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.text-input {
  background: rgba(10, 13, 32, .8); border: 1px solid rgba(140, 160, 255, .3); border-radius: 10px;
  color: #eef2ff; padding: 9px 12px; font-size: 14px; width: 170px; font-family: inherit;
}
.board-card { margin-top: 14px; background: rgba(10, 13, 30, .6); border-radius: 14px; padding: 12px; text-align: left; }
.card-title { font-size: 12px; font-weight: 700; color: #7d89b8; letter-spacing: .5px; margin-bottom: 8px; }
.board-list { min-height: 40px; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 5px 2px; font-size: 13px; }
.board-rank { width: 30px; color: #ffd76a; font-weight: 800; }
.board-name { font-weight: 700; color: #dfe6ff; }
.board-meta { font-size: 11px; color: #5d688f; }
.board-score { margin-left: auto; font-weight: 800; color: #8ef6ff; font-variant-numeric: tabular-nums; }
.board-empty { color: #5d688f; font-size: 12.5px; padding: 8px 2px; }

/* ---------- star map ---------- */
.map-hint { margin: -4px 0 12px; }
.map-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.const-card { background: rgba(10, 13, 30, .6); border: 1px solid rgba(130, 150, 255, .12); border-radius: 14px; padding: 12px; }
.const-card h4 { font-size: 13px; color: #eef2ff; margin-bottom: 2px; }
.const-card .buff { font-size: 10.5px; color: #7fd7a8; margin-bottom: 8px; }
.const-stars { display: flex; gap: 6px; margin-bottom: 8px; }
.const-stars i { font-style: normal; font-size: 15px; opacity: .22; filter: grayscale(1); }
.const-stars i.lit { opacity: 1; filter: none; text-shadow: 0 0 10px rgba(255, 220, 100, .8); }
.const-card .cond { font-size: 11px; color: #7d89b8; line-height: 1.5; }
.const-card .cond .done { color: #7fd7a8; text-decoration: line-through; }

/* ---------- shop / codex ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  flex: 1; padding: 9px 0; border-radius: 10px; border: 1px solid rgba(140, 160, 255, .18);
  background: transparent; color: #7d89b8; font-weight: 700; font-size: 13px; cursor: pointer;
}
.tab.on { background: rgba(90, 110, 230, .22); color: #eef2ff; border-color: rgba(150, 170, 255, .45); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.shop-item { background: rgba(10, 13, 30, .6); border: 1px solid rgba(130, 150, 255, .12); border-radius: 14px; padding: 10px; text-align: center; cursor: pointer; }
.shop-item.equipped { border-color: #ffd76a; box-shadow: 0 0 14px rgba(255, 200, 80, .2); }
.shop-item canvas { width: 56px; height: 56px; }
.shop-item .nm { font-size: 11.5px; font-weight: 700; color: #dfe6ff; margin: 4px 0 2px; }
.shop-item .pr { font-size: 11px; color: #ffd76a; font-weight: 700; }
.shop-item .pr.owned { color: #7fd7a8; }
.shop-item.locked { opacity: .55; }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.codex-item { background: rgba(10, 13, 30, .6); border-radius: 14px; padding: 10px; text-align: center; }
.codex-item canvas { width: 54px; height: 54px; }
.codex-item .nm { font-size: 11.5px; font-weight: 700; color: #dfe6ff; margin-top: 4px; }
.codex-item .ds { font-size: 10.5px; color: #7d89b8; margin-top: 3px; line-height: 1.4; }
.codex-item.unseen { opacity: .4; }
.codex-item.unseen .nm::after { content: ' ?'; }
.codex-sec { font-size: 12px; font-weight: 800; color: #7d89b8; letter-spacing: 1px; margin: 14px 0 8px; }
.codex-note { font-size: 10.5px; color: #cf8f7f; margin-top: 3px; }

/* ---------- settings ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0; font-size: 14px; color: #b9c5f2; }
.set-row input[type=range] { width: 150px; accent-color: #ffd76a; }
.set-row input[type=checkbox] { width: 20px; height: 20px; accent-color: #ffd76a; }

/* ---------- boss banner ---------- */
#boss-banner {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 56px); left: 50%; transform: translateX(-50%);
  z-index: 6; text-align: center; pointer-events: none; width: min(420px, 76vw);
}
#boss-banner.hidden { display: none; }
#boss-name { font-size: 15px; font-weight: 800; letter-spacing: 3px; color: #ffb3c8; text-shadow: 0 0 16px rgba(255, 100, 140, .6); margin-bottom: 5px; }
.boss-bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .1); overflow: hidden; border: 1px solid rgba(255, 140, 170, .3); }
.boss-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5d8f, #ffb36a); transition: width .2s; }

/* ---------- toasts ---------- */
#toasts { position: absolute; bottom: 26px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 20; pointer-events: none; }
.toast {
  background: rgba(16, 20, 46, .92); border: 1px solid rgba(255, 210, 100, .35); color: #ffe9a8;
  padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 700;
  animation: toastIn .25s, toastOut .3s 2.2s forwards; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 480px) {
  .logo { font-size: 32px; }
  .final-score { font-size: 36px; }
  .lv-cards { gap: 8px; }
  .map-body { grid-template-columns: 1fr; }
}
