/* PRISM CASCADE — deep-space prism 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: #0d0b1f; color: #e8e3ff;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#stage { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-home {
  width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: #1c1a3a; border: 2px solid #35306b; color: #c8c1f5; text-decoration: none; font-size: 19px;
  box-shadow: 0 3px 0 #35306b;
}
.pill {
  background: #1c1a3a; border: 2px solid #35306b; border-radius: 999px;
  padding: 5px 12px 5px 8px; font-size: 15px; box-shadow: 0 3px 0 #35306b;
  display: flex; align-items: center; gap: 5px;
}
.pill b { color: #d6c9ff; }
.pico { font-size: 14px; }
.hud-spacer { flex: 1; }
.hud-btn {
  position: relative; width: 38px; height: 38px; border-radius: 12px; border: 2px solid #35306b;
  background: #1c1a3a; font-size: 17px; cursor: pointer; box-shadow: 0 3px 0 #35306b; color: #c8c1f5;
}
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #35306b; }

#mg-quit { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; z-index: 30; display: none; }
#mg-quit.show { display: block; }

/* ---------- in-play bottom bar ---------- */
.ov-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  display: none; flex-direction: column; gap: 8px; align-items: center;
}
.ov-bar.show { display: flex; }
.steps-track {
  position: relative; width: min(420px, 92vw); height: 22px; border-radius: 999px;
  background: #1c1a3a; border: 2px solid #35306b; overflow: hidden;
}
.steps-fill { height: 100%; background: linear-gradient(90deg, #a78bfa, #22d3ee); width: 0%; transition: width 0.25s; }
.steps-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #f3f0ff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.tool-row { display: flex; gap: 10px; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 58px; padding: 6px 4px; border-radius: 14px; border: 2px solid #35306b;
  background: #1c1a3a; color: #c8c1f5; cursor: pointer; box-shadow: 0 3px 0 #35306b; font-size: 19px;
}
.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #35306b; }
.tool-btn small { font-size: 10px; color: #9891c4; }

/* ---------- overlays & panels ---------- */
.ov {
  position: absolute; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center;
  background: rgba(6, 5, 18, 0.55); backdrop-filter: blur(3px);
  padding: 14px;
}
.ov.show { display: flex; }
.pnl {
  position: relative; width: min(480px, 96vw); max-height: min(86vh, 700px); overflow-y: auto;
  background: #171433; border: 2px solid #35306b; border-radius: 22px;
  padding: 20px 18px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  scrollbar-width: thin;
}
.pnl.center { text-align: center; }
.pnl .x {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid #35306b; background: #1c1a3a; color: #c8c1f5; font-size: 18px; cursor: pointer; line-height: 1;
}
.pnl-title { font-size: 21px; color: #e8e3ff; margin-bottom: 10px; letter-spacing: 0.5px; }
.soft { color: #9891c4; font-size: 13px; }
.logo { font-size: 32px; letter-spacing: 3px; color: #e8e3ff; margin: 8px 0 2px; }
.logo span { color: #ec4899; }
.tagline { color: #9891c4; margin-bottom: 16px; font-size: 14px; }

/* ---------- mode select ---------- */
.mode-grid { display: grid; gap: 10px; margin: 4px 0 14px; }
.mode-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 2px solid #35306b; background: #1c1a3a; border-radius: 16px; padding: 12px 16px;
  cursor: pointer; box-shadow: 0 3px 0 #35306b; color: #e8e3ff;
}
.mode-card:active { transform: translateY(2px); box-shadow: 0 1px 0 #35306b; }
.mode-ic { font-size: 26px; }
.mode-name { font-size: 15.5px; font-weight: 800; }
.mode-sub { font-size: 12px; color: #9891c4; }
.restart-link { font-size: 11px; margin-top: 4px; }

/* ---------- buttons ---------- */
.b-pri, .b-sec {
  border: none; border-radius: 14px; padding: 11px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.4px;
}
.b-pri { background: linear-gradient(180deg, #c4b5fd, #a78bfa); color: #1c1030; box-shadow: 0 4px 0 #7c5fd6; }
.b-pri:active { transform: translateY(2px); box-shadow: 0 2px 0 #7c5fd6; }
.b-pri:disabled { filter: grayscale(0.7); opacity: 0.6; box-shadow: none; cursor: default; }
.b-sec { background: #1c1a3a; color: #c8c1f5; border: 2px solid #35306b; box-shadow: 0 3px 0 #35306b; }
.b-sec:active { transform: translateY(2px); box-shadow: 0 1px 0 #35306b; }
.b-sec:disabled { opacity: 0.5; box-shadow: none; cursor: default; }
.small { padding: 7px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

.howto { list-style: none; text-align: left; margin: 4px auto 12px; max-width: 340px; }
.howto li { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; color: #b3acdb; padding: 4px 0; }
.howto i { font-style: normal; }
.meta-row { margin-top: 6px; font-size: 13px; }
.meta-dot { margin: 0 7px; color: #4a4480; }
.text-link { color: #22d3ee; text-decoration: none; }

/* ---------- result panel ---------- */
.final-score { font-size: 46px; font-weight: 800; color: #e8e3ff; margin: 6px 0 2px;
  background: linear-gradient(90deg, #a78bfa, #22d3ee, #ec4899); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.submit-row { display: flex; gap: 8px; margin: 14px 0 6px; }
.text-input {
  flex: 1; border: 2px solid #35306b; background: #1c1a3a; color: #e8e3ff; border-radius: 12px;
  padding: 9px 12px; font-size: 14px;
}
.board-card { margin-top: 14px; text-align: left; }
.card-title { font-size: 13px; color: #9891c4; margin-bottom: 6px; font-weight: 700; }
.board-list { display: grid; gap: 6px; }
.board-row { display: flex; align-items: center; gap: 10px; background: #1c1a3a; border: 2px solid #35306b; border-radius: 12px; padding: 6px 10px; }
.board-rank { width: 28px; font-weight: 800; color: #a78bfa; font-size: 13px; }
.board-name { font-size: 13px; font-weight: 700; color: #e8e3ff; }
.board-meta { font-size: 11px; color: #9891c4; }
.board-score { margin-left: auto; font-weight: 800; color: #22d3ee; font-size: 13px; }
.board-empty { color: #6a648f; font-size: 13px; text-align: center; padding: 10px 0; }

/* ---------- shop ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  border: 2px solid #35306b; background: #1c1a3a; color: #b3acdb; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.tab.on { background: #a78bfa; border-color: #a78bfa; color: #1c1030; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 10px; }
.card-i {
  border: 2px solid #35306b; border-radius: 16px; background: #1c1a3a; padding: 12px 8px 10px;
  text-align: center; position: relative;
}
.card-i .swatch { width: 100%; height: 40px; border-radius: 10px; margin-bottom: 6px; }
.card-i .nm { font-size: 12.5px; font-weight: 700; color: #e8e3ff; margin: 3px 0 3px; }
.card-i .cond { font-size: 10.5px; color: #9891c4; min-height: 14px; margin-bottom: 6px; }
.card-i .b-pri, .card-i .b-sec { width: 100%; padding: 6px 4px; font-size: 12px; border-radius: 10px; }
.card-i.locked { opacity: 0.75; }
.card-i.active { border-color: #22d3ee; }

/* ---------- toasts ---------- */
#toasts { position: absolute; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: #1c1a3a; border: 2px solid #35306b; color: #e8e3ff; font-size: 13px; font-weight: 700;
  padding: 8px 16px; border-radius: 999px; box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.2s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
