:root {
  --bg-deep-slate: #061817;
  --bg-sheet-jade: #092220;
  --bg-card-surface: rgba(13, 44, 41, 0.88);
  --bg-card-selected: rgba(20, 68, 63, 0.96);
  --celadon-jade: #2DD4BF;
  --celadon-bright: #5EEAD4;
  --lotus-coral: #FB7185;
  --dewdrop-gold: #FDE047;
  --text-ivory: #ECFEFF;
  --text-muted: #99F6E4;
  --border-subtle: rgba(45, 212, 191, 0.24);
  --font-display: "Avenir Next", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep-slate);
  color: var(--text-ivory);
  font-family: var(--font-display);
  touch-action: none;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #0d3330 0%, #061817 75%);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Top HUD Bar — 320px Score-Safe & Zero-Overflow */
.hud-bar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 8px));
  left: 8px;
  right: 8px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  z-index: 10;
  pointer-events: auto;
}

.hud-icon-btn,
.hud-round-btn {
  height: 36px;
  border-radius: 18px;
  border: 1px solid rgba(94, 234, 212, 0.35);
  background: rgba(6, 24, 23, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-ivory);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.hud-round-btn {
  width: 36px;
  padding: 0;
}

.hud-icon-btn:active,
.hud-round-btn:active {
  transform: scale(0.94);
  border-color: var(--celadon-jade);
}

.hud-stats-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.hud-pill {
  height: 36px;
  padding: 0 8px;
  border-radius: 18px;
  background: rgba(6, 24, 23, 0.85);
  border: 1px solid rgba(45, 212, 191, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  min-width: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pill-lotus {
  flex: 0 1 64px;
}

.pill-pebbles {
  flex: 0 1 54px;
}

.pill-score {
  flex: 1 1 82px;
  max-width: 118px;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-coral {
  background: var(--lotus-coral);
  box-shadow: 0 0 8px var(--lotus-coral);
}

.dot-jade {
  background: var(--celadon-jade);
  box-shadow: 0 0 8px var(--celadon-jade);
}

.dot-gold {
  background: var(--dewdrop-gold);
  box-shadow: 0 0 8px var(--dewdrop-gold);
}

.pill-val {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-ivory);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-block;
}

/* Guardian Vitality & Relic Strip */
.guardian-strip {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top, 8px)) + 42px);
  left: 8px;
  right: 8px;
  z-index: 9;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guardian-bar-wrap {
  background: rgba(6, 24, 23, 0.78);
  border: 1px solid rgba(251, 113, 133, 0.32);
  border-radius: 13px;
  padding: 5px 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 8px;
}

.guardian-emblem-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(251, 113, 133, 0.45));
  transition: transform 0.16s ease;
}

.guardian-bar-col {
  flex: 1;
  min-width: 0;
}

.guardian-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.guardian-name {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #FECDD3;
  white-space: nowrap;
}

.shot-mult-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--dewdrop-gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.guardian-hp-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.guardian-hp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FB7185 0%, #FDE047 100%);
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.7);
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.relic-tray {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.relic-tray::-webkit-scrollbar {
  display: none;
}

.relic-chip {
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: rgba(13, 52, 48, 0.88);
  border: 1px solid rgba(45, 212, 191, 0.45);
  color: var(--text-ivory);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Modal Backdrops & Tolan Split Header */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(3, 12, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sanctuary-sheet {
  width: 100%;
  max-width: 410px;
  border-radius: 26px;
  overflow: hidden;
  background: var(--bg-sheet-jade);
  border: 1.5px solid rgba(94, 234, 212, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 32px rgba(45, 212, 191, 0.14);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-backdrop.active .sanctuary-sheet {
  transform: translateY(0) scale(1);
}

/* Tolan Journey Inspired Atmospheric Split Header with Curved Wave Notch */
.tolan-header {
  position: relative;
  padding: 20px 18px 30px;
  text-align: center;
  background: radial-gradient(circle at 50% 18%, rgba(45, 212, 191, 0.28) 0%, rgba(17, 64, 59, 0.85) 48%, #051615 100%);
  overflow: hidden;
}

.tolan-header.compact {
  padding: 16px 16px 26px;
}

.tolan-glow-orb {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 140px;
  background: radial-gradient(circle, rgba(251, 113, 133, 0.32) 0%, rgba(45, 212, 191, 0) 70%);
  pointer-events: none;
}

.tolan-wave-notch {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 24px;
  display: block;
}

.mascot-hero-img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  margin: 0 auto 6px;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

.mascot-hero-img.small {
  width: 58px;
  height: 58px;
}

.eyebrow-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--dewdrop-gold);
  background: rgba(253, 224, 71, 0.12);
  border: 1px solid rgba(253, 224, 71, 0.35);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
  white-space: nowrap;
}

.sheet-title {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--text-ivory);
  margin-bottom: 5px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.sheet-subtitle {
  font-size: 12.5px;
  line-height: 1.38;
  color: #CCFBF1;
  max-width: 330px;
  margin: 0 auto;
}

.sheet-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* BitePal Selection Cards (4-bar left potency indicator + crisp title/subtitle + glowing celadon border) */
.bitepal-card-stack,
.feature-preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scrollable-atlas {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.scrollable-atlas::-webkit-scrollbar {
  width: 4px;
}

.scrollable-atlas::-webkit-scrollbar-thumb {
  background: rgba(45, 212, 191, 0.35);
  border-radius: 999px;
}

.bitepal-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--bg-card-surface);
  border: 1.5px solid var(--border-subtle);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}

.bitepal-card.preview-static {
  cursor: default;
}

.bitepal-card:hover:not(.preview-static),
.bitepal-card.selected {
  background: var(--bg-card-selected);
  border-color: var(--celadon-jade);
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.28), inset 0 0 10px rgba(45, 212, 191, 0.12);
}

.potency-bars {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  width: 7px;
  flex-shrink: 0;
}

.p-bar {
  width: 7px;
  height: 5px;
  border-radius: 2.5px;
  background: rgba(255, 255, 255, 0.14);
}

.p-bar.lit {
  background: var(--celadon-jade);
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.8);
}

.bitepal-card.selected .p-bar.lit {
  background: var(--dewdrop-gold);
  box-shadow: 0 0 8px rgba(253, 224, 71, 0.9);
}

.card-sprite-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.card-copy {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-ivory);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 12px;
  color: #99F6E4;
  line-height: 1.3;
}

.card-status-pill {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.16);
  color: var(--celadon-bright);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Result Metrics */
.result-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-tile {
  background: var(--bg-card-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  min-width: 0;
}

.metric-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
}

.metric-val {
  display: block;
  font-size: 19px;
  font-weight: 900;
  color: var(--dewdrop-gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Buttons */
.cta-row {
  display: flex;
  gap: 8px;
}

.cta-row.dual > button {
  flex: 1;
  min-width: 0;
}

.primary-jade-btn,
.secondary-slate-btn {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border-radius: 15px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.primary-jade-btn {
  border: none;
  background: linear-gradient(135deg, #2DD4BF 0%, #14B8A6 100%);
  color: #042F2E;
  box-shadow: 0 8px 22px rgba(45, 212, 191, 0.35);
}

.secondary-slate-btn {
  border: 1.5px solid rgba(94, 234, 212, 0.35);
  background: rgba(13, 44, 41, 0.75);
  color: var(--text-ivory);
}

.primary-jade-btn:active,
.secondary-slate-btn:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}
