@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;900&family=Rajdhani:wght@600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  font-family: 'Cinzel', serif;
  touch-action: none;
}

body, html {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #171103 0%, #050401 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Obsidian Polished Vault Container */
#game-container {
  position: relative;
  width: 420px;
  height: 650px;
  min-width: 420px;
  min-height: 650px;
  background: linear-gradient(135deg, #1c1505 0%, #0d0a02 50%, #150f03 100%);
  border-radius: 0;
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
  border: 2px solid #d4af37;
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.95),
    0 0 35px rgba(212, 175, 55, 0.2),
    inset 0 0 30px rgba(212, 175, 55, 0.1);
  overflow: hidden;
  transform-origin: center center;
  flex-shrink: 0;
}

/* Polished Gold Filigree Header Rim */
#game-container::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 24px;
  right: 24px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fbbf24, #d4af37, #fef08a, transparent);
  z-index: 5;
}

/* Splash Screen */
.splash-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0d0a03;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.splash-layer.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80%;
}

.splash-svg-laser {
  width: 55px;
  height: 55px;
  filter: drop-shadow(0 0 15px #fbbf24);
  animation: goldBreathe 2s infinite ease-in-out;
}

@keyframes goldBreathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 12px #d4af37); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 25px #fef08a); }
}

.splash-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 3px;
  margin-top: 14px;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.8);
}

.splash-subtitle {
  color: #fef08a;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #1c1505;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid #d4af37;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #d4af37, #fef08a);
  box-shadow: 0 0 10px #fbbf24;
  transition: width 0.1s linear;
}

.splash-loading-text {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  color: #fde68a;
  margin-top: 8px;
}

/* Top HUD */
#hud-bar {
  position: absolute;
  top: 14px;
  left: 0;
  width: 100%;
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

#hud-bar.hidden {
  display: none;
}

#level-badge {
  pointer-events: auto;
  background: #1f1706;
  border: 1.5px solid #d4af37;
  padding: 4px 12px;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  color: #fbbf24;
  font-size: 0.85rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  transition: all 0.2s ease;
}

#stars-row {
  display: flex;
  gap: 4px;
}

.hud-star {
  width: 18px;
  height: 18px;
  fill: #fbbf24;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
}

.hud-star.dim {
  fill: #382705;
  opacity: 0.35;
}

#hud-actions {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-btn {
  background: #1f1706;
  border: 1.5px solid #d4af37;
  color: #fbbf24;
  width: 32px;
  height: 32px;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.2);
  transition: all 0.2s ease;
}

.hud-ad-btn {
  border-color: #fef08a;
  color: #fef08a;
  box-shadow: 0 0 10px rgba(254, 240, 138, 0.4);
}

.hud-btn:hover {
  background: #d4af37;
  color: #050401;
  transform: translateY(-2px);
}

.hud-btn:active {
  transform: scale(0.92);
}

.svg-icon {
  width: 16px;
  height: 16px;
}

/* Gameplay Quote Banner */
#gameplay-quote-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(23, 17, 3, 0.95);
  border: 1px solid #d4af37;
  padding: 4px 14px;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  z-index: 10;
  max-width: 90%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

#gameplay-quote-banner.hidden {
  display: none;
}

#gameplay-quote-text {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fbbf24;
  letter-spacing: 0.5px;
  text-align: center;
  display: block;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 4, 1, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease;
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-box {
  background: linear-gradient(180deg, #241a05 0%, #0f0a02 100%);
  border: 2px solid #d4af37;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  padding: 22px 18px;
  width: 92%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(212, 175, 55, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-center {
  text-align: center;
  align-items: center;
}

.game-title {
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fbbf24;
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.8);
}

.subtitle {
  color: #fef08a;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-top: -6px;
}

.pause-white-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: #ffffff !important;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

.pass-quote {
  font-family: 'Rajdhani', sans-serif;
  color: #fef08a;
  font-size: 0.95rem;
  font-weight: 700;
  font-style: italic;
  margin: -2px 0 6px 0;
}

.menu-actions, .modal-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

.primary-btn {
  background: linear-gradient(180deg, #d4af37 0%, #a16207 100%);
  color: #050401;
  border: 1.5px solid #fef08a;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  padding: 12px 18px;
  font-size: 0.92rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
  letter-spacing: 1px;
  transition: all 0.2s ease;
}

.primary-btn:hover {
  background: linear-gradient(180deg, #fef08a 0%, #d4af37 100%);
  transform: translateY(-2px);
}

.secondary-btn {
  background: #171103;
  color: #fef08a;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: #241a05;
  border-color: #fbbf24;
  color: #fbbf24;
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
  border-color: #fca5a5 !important;
  color: #ffffff !important;
}

.btn-warning {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

.glow-text {
  color: #fbbf24;
  font-size: 1.35rem;
  text-shadow: 0 0 14px rgba(212, 175, 55, 0.8);
}

.glow-text-danger {
  color: #ef4444;
  font-size: 1.35rem;
  text-shadow: 0 0 14px rgba(239, 68, 68, 0.8);
}

.stars-large {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 4px 0;
}

.stars-large .hud-star {
  width: 34px;
  height: 34px;
}

/* Header */
.header-center {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1.5px solid #d4af37;
  padding-bottom: 10px;
  width: 100%;
}

.header-center-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 2px;
}

.abs-right {
  position: absolute;
  right: 0;
}

.close-btn {
  background: #171103;
  border: 1.5px solid #d4af37;
  color: #d4af37;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.close-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

.svg-close {
  width: 14px;
  height: 14px;
}

/* Hexagonal Diamond Level Drawer */
.level-select-box {
  height: 90%;
  max-height: 580px;
  padding: 16px 12px;
}

#levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 10px;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  padding: 8px 4px 16px 4px;
}

#levels-grid::-webkit-scrollbar, 
#shop-items-container::-webkit-scrollbar,
.bgm-list::-webkit-scrollbar {
  width: 5px;
}

#levels-grid::-webkit-scrollbar-thumb, 
#shop-items-container::-webkit-scrollbar-thumb,
.bgm-list::-webkit-scrollbar-thumb {
  background: #d4af37;
}

.lvl-card {
  background: #1a1304;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  aspect-ratio: 1 / 1.08;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lvl-card.playable {
  border-color: #fbbf24;
  background: #241a05;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.lvl-card.playable:hover {
  background: #332407;
  transform: translateY(-2px) scale(1.03);
}

.lvl-card.passed {
  border-color: #22c55e;
}

.lvl-card.locked {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: #382705;
}

.lvl-card-num {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fef08a;
  line-height: 1;
}

.lvl-card.locked .lvl-card-num {
  color: #713f12;
}

.lvl-card-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.lvl-mini-star {
  width: 12px;
  height: 12px;
  fill: #fbbf24;
}

.lvl-mini-star.dim {
  fill: #382705;
  opacity: 0.35;
}

.lvl-mini-icon {
  width: 13px;
  height: 13px;
  fill: #d4af37;
}

/* Shop Modal */
.shop-box {
  max-height: 88%;
  padding-bottom: 14px;
}

.shop-tabs {
  display: flex;
  gap: 8px;
  width: 100%;
}

.shop-tab {
  flex: 1;
  background: #171103;
  border: 1.5px solid #d4af37;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  color: #fde68a;
  padding: 8px 4px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.shop-tab.active {
  background: #d4af37;
  color: #050401;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

#shop-items-container {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 2px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.shop-grid.hidden {
  display: none;
}

.shop-card {
  background: #1a1304;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.shop-card.equipped {
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

.skin-preview-ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  border: 1.5px solid #d4af37;
}

.skin-preview-portal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
  border: 2px dashed #fbbf24;
}

.skin-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fef08a;
}

.skin-btn {
  width: 100%;
  padding: 5px 4px;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  font-size: 0.65rem;
  font-weight: 900;
  cursor: pointer;
  border: none;
}

.skin-btn.btn-equip {
  background: #382705;
  color: #fde68a;
}

.skin-card.equipped .skin-btn.btn-equip {
  background: #d4af37;
  color: #050401;
}

.skin-btn.btn-ad {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #000;
}

/* Settings & BGM List */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  color: #fef08a;
  font-size: 0.95rem;
}

.setting-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #d4af37;
}

.setting-track-header {
  font-size: 0.78rem;
  font-weight: 900;
  color: #fbbf24;
  text-align: left;
  margin-top: 4px;
}

.bgm-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.bgm-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #171103;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  padding: 5px 10px;
}

.bgm-card.active {
  border-color: #fbbf24;
  background: #241a05;
}

.bgm-name {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: #fef08a;
}

.bgm-btn {
  padding: 4px 8px;
  font-size: 0.62rem;
  font-weight: 900;
  cursor: pointer;
  border: none;
}

.bgm-btn.btn-play {
  background: #d4af37;
  color: #050401;
}

.bgm-btn.btn-unlock {
  background: #f59e0b;
  color: #000;
}