/* ==========================================================================
   PRISM GROOVE — Pop-Sunset / Tactile Glass Stylesheet
   Mobile-first, 100dvh, safe-area aware, zero external fonts/assets
   ========================================================================== */

:root {
  --font-main: "Segoe UI", "SF Pro Rounded", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --accent-1: #ff7a59;
  --accent-2: #ff4d79;
  --accent-3: #25d0c8;
  --gold: #ffd94a;
  --ink-dark: #1f1638;
  --ink-light: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.22);
  --glass-border: rgba(255, 255, 255, 0.42);
  --glass-strong: rgba(34, 22, 62, 0.78);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ff7568;
  font-family: var(--font-main);
  color: var(--ink-light);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Portrait stage shell: maintains crisp 450:800 ratio on desktop/landscape,
   fills phone screens cleanly with safe-area support */
#stage-shell {
  position: relative;
  z-index: 1;
  width: min(100vw, calc(100dvh * 450 / 800));
  height: min(100dvh, calc(100vw * 800 / 450));
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  border-radius: 0;
  box-shadow: 0 24px 64px rgba(24, 12, 48, 0.35);
}

@media (min-aspect-ratio: 460/800) {
  #stage-shell {
    height: min(96dvh, 880px);
    width: calc(min(96dvh, 880px) * 450 / 800);
    border-radius: 28px;
    border: 2px solid rgba(255, 255, 255, 0.35);
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ===================== GLASS UTILITIES ===================== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid var(--glass-border);
  box-shadow: 0 6px 20px rgba(31, 22, 56, 0.14);
}

.glass-strong {
  background: var(--glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 20px 50px rgba(15, 8, 36, 0.45);
}

.hidden {
  display: none !important;
}

/* ===================== BUTTONS ===================== */
button {
  font-family: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  outline: none;
  transition: transform 0.12s ease, background 0.18s ease, box-shadow 0.18s ease;
}

button:active {
  transform: scale(0.95);
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.btn-primary {
  width: 100%;
  min-height: 56px;
  padding: 12px 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffe066 0%, #ff8a4c 48%, #ff477e 100%);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px rgba(140, 20, 50, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 10px 26px rgba(255, 71, 126, 0.38);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn-primary .btn-sub-text {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.92;
  letter-spacing: 0.02em;
}

.pulse-btn {
  animation: softPulse 2.4s ease-in-out infinite;
}

@keyframes softPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 26px rgba(255, 71, 126, 0.38); }
  50% { transform: scale(1.022); box-shadow: 0 14px 34px rgba(255, 138, 76, 0.52); }
}

.btn-glass {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.22);
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-shadow: 0 1px 4px rgba(25, 15, 50, 0.28);
}

.btn-glass.accent-daily {
  background: linear-gradient(135deg, rgba(255, 217, 74, 0.36), rgba(255, 122, 89, 0.36));
  border-color: rgba(255, 238, 145, 0.7);
}

.btn-glass.compact {
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  min-height: 54px;
  padding: 8px 6px;
}

.btn-glass.danger-soft {
  background: rgba(255, 71, 102, 0.28);
  border-color: rgba(255, 130, 150, 0.55);
}

.btn-icon {
  font-size: 17px;
  line-height: 1;
}

.btn-small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #25d0c8, #3fa7ff);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

/* ===================== SCREENS ===================== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) calc(16px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ===================== TITLE SCREEN ===================== */
.title-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.currency-pill {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.currency-pill.mini {
  height: 34px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.title-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 12px;
}

.logo-emblem {
  margin-bottom: 10px;
  animation: floatLogo 3.4s ease-in-out infinite;
  filter: drop-shadow(0 12px 24px rgba(31, 22, 56, 0.24));
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1.5deg); }
}

.game-title {
  margin: 0;
  font-size: 40px;
  line-height: 0.96;
  font-weight: 950;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 5px 18px rgba(31, 22, 56, 0.3);
}

.game-title span {
  display: block;
  font-size: 44px;
  background: linear-gradient(180deg, #fffbe0 0%, #ffd94a 55%, #ff9b42 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 10px rgba(180, 40, 70, 0.28));
}

.game-tagline {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.title-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* ===================== HUD ===================== */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  padding: calc(10px + var(--safe-top)) 12px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-top button,
.hud-right-group button {
  pointer-events: auto;
}

.hud-center-pill {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 4px rgba(20, 10, 40, 0.25);
  padding: 0 12px;
}

.hud-sep {
  opacity: 0.6;
}

.hud-obj {
  color: #fff6a8;
}

.hud-sub {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.hud-stat {
  min-width: 68px;
  padding: 5px 10px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.stat-val {
  font-size: 17px;
  font-weight: 950;
  line-height: 1.1;
}

.dash-dots {
  color: #7df9ff;
  letter-spacing: 2px;
  font-size: 15px;
}

.fever-wrap {
  flex: 1;
  padding: 6px 12px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.fever-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.fever-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 10, 40, 0.26);
  overflow: hidden;
}

.fever-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd94a, #ff7a59, #ff4d79, #25d0c8);
  transition: width 0.12s linear;
}

.fever-fill.active {
  animation: feverGlow 0.35s linear infinite alternate;
}

@keyframes feverGlow {
  from { filter: brightness(1.05); }
  to { filter: brightness(1.45); }
}

.hud-banner {
  align-self: center;
  margin-top: 6px;
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #ffd94a, #ff4d79, #25d0c8);
  color: #fff;
  font-weight: 950;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  box-shadow: 0 8px 24px rgba(255, 77, 121, 0.45);
  animation: popBanner 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes popBanner {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===================== WORLD MAP ===================== */
.screen-header {
  height: 54px;
  border-radius: 18px;
  padding: 0 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.screen-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.header-badge {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.22);
  font-size: 13px;
  font-weight: 900;
  color: #fff7a8;
}

.map-scroll {
  flex: 1;
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 18px;
  scrollbar-width: none;
}

.map-scroll::-webkit-scrollbar {
  display: none;
}

.world-card {
  border-radius: 22px;
  padding: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 10px 26px rgba(24, 12, 48, 0.2);
}

.world-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.world-card-title {
  font-size: 15px;
  font-weight: 950;
  letter-spacing: 0.02em;
}

.world-card-sub {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.9;
}

.world-stars-pill {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-weight: 800;
  color: #ffe875;
}

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

.lvl-node {
  min-height: 54px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.26);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  position: relative;
}

.lvl-node.current {
  background: linear-gradient(135deg, #ffe066, #ff6b6b);
  border-color: #fff;
  box-shadow: 0 4px 14px rgba(255, 107, 107, 0.48);
}

.lvl-node.locked {
  background: rgba(20, 12, 42, 0.28);
  border-color: rgba(255, 255, 255, 0.18);
  opacity: 0.62;
}

.lvl-node.boss::after {
  content: "👑";
  position: absolute;
  top: -7px;
  right: -4px;
  font-size: 12px;
}

.lvl-stars {
  font-size: 10px;
  letter-spacing: 1px;
  color: #ffe875;
  line-height: 1;
}

.lvl-stars .off {
  opacity: 0.35;
}

/* ===================== MODALS ===================== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(18, 10, 38, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  border-radius: 26px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: modalIn 0.22s cubic-bezier(0.2, 1.25, 0.4, 1);
}

.modal-tall {
  max-height: 86%;
}

@keyframes modalIn {
  from { transform: scale(0.92) translateY(14px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-header h3,
.modal-card h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 950;
  letter-spacing: 0.03em;
  text-align: center;
}

.modal-sub {
  margin: -8px 0 2px;
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
  font-weight: 700;
}

.modal-scroll {
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

/* Result modal */
.result-badge {
  align-self: center;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #25d0c8, #4ce0b3);
  color: #132238;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.result-badge.fail {
  background: linear-gradient(90deg, #ff7a59, #ff4d79);
  color: #fff;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 40px;
  line-height: 1;
}

.star-slot {
  color: rgba(255, 255, 255, 0.22);
  transition: transform 0.3s cubic-bezier(0.2, 1.5, 0.4, 1), color 0.3s;
}

.star-slot.lit {
  color: #ffd94a;
  text-shadow: 0 4px 18px rgba(255, 217, 74, 0.7);
  transform: scale(1.12);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.r-stat {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.r-label {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.75;
}

.r-val {
  font-size: 17px;
  font-weight: 950;
  color: #fff7b8;
}

.result-actions,
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Tabs */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 14px;
}

.tab-btn {
  min-height: 38px;
  border-radius: 10px;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.75);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* Shop items */
.shop-item {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.shop-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.16);
  flex-shrink: 0;
}

.shop-info {
  flex: 1;
  min-width: 0;
}

.shop-name {
  font-size: 14px;
  font-weight: 900;
}

.shop-desc {
  font-size: 11px;
  opacity: 0.82;
  margin-top: 2px;
}

.shop-pips {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.pip {
  width: 14px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.pip.filled {
  background: #ffd94a;
}

.shop-buy-btn {
  min-height: 40px;
  min-width: 78px;
  padding: 0 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffd94a, #ff8a4c);
  color: #24133a;
  font-size: 12px;
  font-weight: 950;
}

.shop-buy-btn.equipped {
  background: rgba(37, 208, 200, 0.35);
  color: #fff;
  border: 1px solid #25d0c8;
}

.shop-buy-btn.maxed {
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.7);
}

/* Leaderboard */
.status-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(37, 208, 200, 0.25);
  border: 1px solid rgba(37, 208, 200, 0.5);
}

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

.lb-player-row input {
  flex: 1;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

.lb-player-row input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.lb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 800;
}

.lb-row.me {
  background: rgba(255, 217, 74, 0.22);
  border: 1px solid rgba(255, 217, 74, 0.5);
}

.lb-rank {
  width: 28px;
  color: #ffd94a;
  font-weight: 950;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 950;
  color: #7df9ff;
}

/* Settings */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-row,
.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 14px;
}

.setting-row input[type="range"] {
  width: 130px;
  accent-color: #ffd94a;
}

.setting-toggle input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: #25d0c8;
}
