:root {
  --bg-dark: #1c0b1e;
  --panel-bg: rgba(43, 19, 44, 0.92);
  --panel-border: rgba(255, 182, 193, 0.35);
  --pink: #ff5d8f;
  --pink-light: #ff8fa3;
  --gold: #ffbe0b;
  --mint: #00f5d4;
  --text-main: #fff0f3;
  --text-sub: #ffccd5;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: radial-gradient(circle at top, #4a1936 0%, #150617 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#app-shell {
  position: relative;
  width: min(100vw, 1060px);
  aspect-ratio: 16 / 9;
  max-height: 94vh;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.65), 0 0 0 4px rgba(255, 143, 163, 0.35);
  background: #2b132c;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* Top Utility Bar */
.top-utility {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 35;
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(28, 11, 30, 0.78);
  border: 2px solid rgba(255, 204, 213, 0.45);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.2s;
}

.icon-btn:hover {
  transform: scale(1.07);
  background: rgba(255, 93, 143, 0.65);
}

/* In-Game HUD Layer */
#hud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 22px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-right: 100px;
}

.bars-box {
  flex: 1;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.hp-bar-outer {
  position: relative;
  height: 28px;
  background: rgba(20, 6, 22, 0.82);
  border: 3px solid #ffe5ec;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

#hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4d6d, #ff8fa3, #ffbe0b);
  border-radius: 999px;
  transition: width 0.1s linear;
}

#hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 4px #000;
}

.skill-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skill-bar-outer {
  flex: 1;
  height: 12px;
  background: rgba(20, 6, 22, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  overflow: hidden;
}

#skill-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f5d4, #9b5de5);
  transition: width 0.1s linear;
}

#hud-skill-name {
  font-size: 12px;
  font-weight: 800;
  color: #ffe5ec;
  background: rgba(43, 19, 44, 0.8);
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Fever M-O-C-H-I Slots */
#fever-slots {
  display: flex;
  gap: 6px;
}

.fever-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(28, 11, 30, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.4);
}

.fever-badge.active {
  background: var(--gold);
  color: #2b132c;
  border-color: #fff;
  box-shadow: 0 0 12px var(--gold);
  transform: scale(1.08);
}

.fever-badge.rainbow {
  animation: pulseRainbow 0.4s infinite alternate;
}

@keyframes pulseRainbow {
  from {
    background: #ffbe0b;
    transform: scale(1.05);
  }
  to {
    background: #00f5d4;
    transform: scale(1.18);
  }
}

.score-box {
  text-align: right;
  background: rgba(28, 11, 30, 0.75);
  padding: 8px 16px;
  border-radius: 16px;
  border: 2px solid rgba(255, 204, 213, 0.35);
}

.score-line {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
}

.coin-line {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
}

#hud-combo {
  margin-top: 4px;
  display: inline-block;
  background: linear-gradient(90deg, #ff5d8f, #ffbe0b);
  color: #1c0b1e;
  font-weight: 900;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 99px;
}

/* Stage Toast */
#stage-toast {
  align-self: center;
  background: rgba(28, 11, 30, 0.88);
  border: 2px solid var(--gold);
  padding: 10px 26px;
  border-radius: 999px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  animation: popIn 0.3s ease-out;
}

.toast-title {
  font-weight: 900;
  font-size: 17px;
  color: var(--gold);
}

.toast-sub {
  font-size: 12px;
  color: #ffe5ec;
}

/* Touch / On-screen Action Controls */
.hud-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: auto;
  padding-bottom: 4px;
}

.action-pedal {
  width: 138px;
  height: 76px;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s;
  touch-action: manipulation;
}

.action-pedal span {
  font-size: 11px;
  opacity: 0.88;
  font-weight: 700;
  margin-top: 2px;
}

.pedal-jump {
  background: linear-gradient(180deg, #ff5d8f 0%, #c9184a 100%);
}

.pedal-slide {
  background: linear-gradient(180deg, #4cc9f0 0%, #4361ee 100%);
}

.action-pedal:active,
.action-pedal.pressed {
  transform: scale(0.93) translateY(3px);
}

/* Modal Overlays (Lobby, Pause, Game Over) */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(20, 6, 22, 0.84);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-container {
  width: 100%;
  height: 100%;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 22px;
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 18px;
  padding: 18px;
  overflow: hidden;
}

.lobby-left {
  background: rgba(20, 6, 22, 0.65);
  border: 2px solid rgba(255, 204, 213, 0.22);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}

.logo-banner {
  width: 100%;
  max-height: 74px;
  object-fit: contain;
}

.stage-pedestal {
  position: relative;
  width: 180px;
  height: 145px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lobby-preview-char {
  width: 118px;
  height: 118px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.5));
  animation: floatBob 2.2s ease-in-out infinite;
}

#lobby-preview-pet {
  position: absolute;
  left: 8px;
  top: 10px;
  width: 58px;
  height: 58px;
  object-fit: contain;
  animation: floatBob 1.7s ease-in-out infinite reverse;
}

@keyframes floatBob {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
}

.char-summary h2 {
  font-size: 21px;
  color: #fff;
}

.char-summary p.sub {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 6px;
}

.skill-box {
  background: rgba(255, 93, 143, 0.16);
  border: 1px solid rgba(255, 93, 143, 0.45);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #ffe5ec;
}

.primary-run-btn {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(90deg, #ff5d8f 0%, #ff9ebb 50%, #ffbe0b 100%);
  color: #1c0b1e;
  font-size: 21px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 93, 143, 0.5);
  transition: transform 0.12s;
}

.primary-run-btn:hover {
  transform: translateY(-2px) scale(1.02);
}

/* Lobby Right Side */
.lobby-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-right: 92px;
}

.currency-pills {
  display: flex;
  gap: 10px;
}

.pill {
  background: rgba(20, 6, 22, 0.85);
  border: 2px solid rgba(255, 204, 213, 0.35);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
}

.tabs-bar {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: rgba(20, 6, 22, 0.65);
  border: 2px solid rgba(255, 204, 213, 0.25);
  color: var(--text-sub);
  padding: 8px 16px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--pink);
  color: #fff;
  border-color: #fff;
}

.tab-panel {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.select-card {
  position: relative;
  background: rgba(20, 6, 22, 0.72);
  border: 2px solid rgba(255, 204, 213, 0.22);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
}

.select-card.selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 18px rgba(255, 190, 11, 0.22);
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 99px;
  color: #1c0b1e;
}

.card-sprite {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.pet-sprite {
  width: 56px;
  height: 56px;
}

.card-name {
  font-weight: 900;
  font-size: 15px;
}

.card-meta {
  font-size: 11px;
  color: var(--text-sub);
  min-height: 28px;
}

.card-btn {
  width: 100%;
  padding: 7px 12px;
  border-radius: 10px;
  border: none;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.card-btn.active {
  background: #2ec4b6;
  color: #0b132b;
}

.card-btn.equip {
  background: #ff8fa3;
  color: #1c0b1e;
}

.card-btn.buy {
  background: var(--gold);
  color: #1c0b1e;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  background: rgba(20, 6, 22, 0.75);
  border: 2px solid rgba(255, 204, 213, 0.25);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.upgrade-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.upgrade-info {
  flex: 1;
}

.upgrade-title {
  font-weight: 900;
  font-size: 16px;
}

.lvl-pill {
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: 6px;
}

.upgrade-desc {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 3px;
}

.upgrade-card .card-btn {
  width: auto;
  min-width: 125px;
}

.controls-guide {
  font-size: 12px;
  color: var(--text-sub);
  background: rgba(20, 6, 22, 0.6);
  padding: 8px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
}

/* Commercial Release Additions: Treasures, Stages, Achievements, Item Guide, Save Manager */
#hud-shields {
  font-size: 12px;
  font-weight: 900;
  color: #80ffdb;
  background: rgba(11, 82, 91, 0.85);
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid #80ffdb;
}

.equipped-treasures-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 7px;
}

.treasure-slot-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(20, 6, 22, 0.78);
  border: 1px solid rgba(255, 190, 11, 0.45);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
}

.treasure-slot-pill img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.section-subtitle {
  font-size: 14px;
  font-weight: 900;
  color: var(--gold);
  margin: 4px 0 8px;
}

.save-pill {
  font-size: 12px;
  color: #80ffdb;
  border-color: rgba(128, 255, 219, 0.4);
  transition: transform 0.2s, background 0.2s;
}

.save-pill.highlight {
  background: #2ec4b6;
  color: #0b132b;
  transform: scale(1.06);
}

.stage-card {
  background: rgba(20, 6, 22, 0.78);
  border: 2px solid rgba(255, 204, 213, 0.25);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-card.selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 16px rgba(255, 190, 11, 0.2);
}

.stage-color-swatch {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.stage-info {
  flex: 1;
}

.stage-name {
  font-weight: 900;
  font-size: 14px;
  color: #fff;
}

.stage-sub {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.stage-card .card-btn {
  width: auto;
  min-width: 120px;
}

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

.guide-item {
  background: rgba(20, 6, 22, 0.72);
  border: 1px solid rgba(255, 204, 213, 0.22);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guide-item img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.guide-name {
  font-weight: 900;
  font-size: 13px;
  color: var(--gold);
}

.guide-desc {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.stats-summary-box {
  background: rgba(20, 6, 22, 0.78);
  border: 2px solid rgba(255, 204, 213, 0.25);
  border-radius: 14px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

.save-actions-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.save-code-box {
  background: rgba(20, 6, 22, 0.78);
  border: 2px solid rgba(255, 190, 11, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

#save-code-input {
  width: 100%;
  background: rgba(10, 4, 12, 0.9);
  border: 1px solid rgba(255, 204, 213, 0.35);
  border-radius: 10px;
  color: #80ffdb;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 11px;
  resize: none;
  user-select: text;
  -webkit-user-select: text;
}

.card-btn.danger {
  background: #d90429;
  color: #fff;
}

/* Center Dialog Card (Pause & Game Over) */
.dialog-card {
  background: var(--panel-bg);
  border: 3px solid var(--gold);
  border-radius: 24px;
  padding: 28px 34px;
  width: min(92vw, 440px);
  text-align: center;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.7);
}

.dialog-card h2 {
  font-size: 28px;
  margin-bottom: 14px;
}

.stats-table {
  background: rgba(20, 6, 22, 0.75);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 14px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
}

.stat-row.big {
  font-size: 20px;
  color: var(--gold);
  font-weight: 900;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions button {
  flex: 1;
}

.secondary-btn {
  padding: 14px;
  border-radius: 16px;
  border: 2px solid var(--pink-light);
  background: rgba(20, 6, 22, 0.8);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

@keyframes popIn {
  from {
    transform: translateY(-15px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 780px) {
  .lobby-container {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
}
