/* ==========================================================================
   Level Devil Reborn - Modern Stylized Game UI & Layout
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Fredoka:wght@600;700&display=swap');

:root {
  --bg-dark: #0a0c14;
  --bg-panel: rgba(18, 22, 38, 0.85);
  --border-glow: rgba(255, 68, 85, 0.4);
  --accent-red: #ff3366;
  --accent-orange: #ff7700;
  --accent-neon-yellow: #ccff00;
  --accent-cyan: #00f0ff;
  --text-main: #f0f4fc;
  --text-muted: #8a96b4;
  --door-gold: #ffd700;
  --spike-color: #ff2a55;
  --font-title: 'Fredoka', 'Outfit', sans-serif;
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  background: radial-gradient(circle at 50% 30%, #171b30 0%, #080a10 100%);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

/* Background animated subtle grid */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Main Container */
#game-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 960px;
  padding: 10px;
}

/* Header & HUD */
#game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-title {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ff4d6d 0%, #ff9e00 60%, #ccff00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(255, 77, 109, 0.3);
}

.badge-tag {
  font-size: 0.65rem;
  background: rgba(255, 51, 102, 0.2);
  color: var(--accent-red);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 51, 102, 0.4);
  font-weight: 800;
  text-transform: uppercase;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-box span.val {
  color: var(--text-main);
  font-weight: 800;
  font-family: var(--font-title);
}

.hud-controls {
  display: flex;
  gap: 8px;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.hud-btn:active {
  transform: translateY(1px);
}

/* Canvas Area */
#canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0d111d;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

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

/* Floating Banner Messages / Troll Prompts */
#troll-toast {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  opacity: 0;
  background: rgba(255, 42, 85, 0.9);
  color: white;
  padding: 8px 20px;
  border-radius: 30px;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px rgba(255, 42, 85, 0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 10;
}

#troll-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Mobile Virtual Controls */
#mobile-controls {
  width: 100%;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 16px 16px;
}

@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls {
    display: flex;
  }
}

.touch-dpad {
  display: flex;
  gap: 12px;
}

.touch-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}

.touch-btn:active, .touch-btn.active {
  background: var(--accent-red);
  transform: scale(0.92);
  box-shadow: 0 0 15px rgba(255, 51, 102, 0.6);
}

.touch-btn.jump-btn {
  width: 80px;
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
  border: none;
  font-family: var(--font-title);
  font-size: 1rem;
}

/* Modals & Overlays */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 16, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 51, 102, 0.2);
  border-radius: 24px;
  padding: 28px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ff4d6d, #ff9e00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Level Grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.level-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.level-card:hover {
  background: rgba(255, 51, 102, 0.15);
  border-color: var(--accent-red);
  transform: translateY(-2px);
}

.level-card.current {
  background: linear-gradient(135deg, rgba(255, 51, 102, 0.3), rgba(255, 119, 0, 0.3));
  border-color: var(--accent-neon-yellow);
  box-shadow: 0 0 15px rgba(204, 255, 0, 0.3);
}

.level-num {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.level-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-red), var(--accent-orange));
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 14px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 51, 102, 0.4);
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 51, 102, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.hud-btn-shop {
  background: linear-gradient(135deg, rgba(255, 183, 3, 0.25), rgba(255, 68, 85, 0.25));
  border-color: rgba(255, 183, 3, 0.5);
  color: #ffe600;
}

.hud-btn-shop:hover {
  background: linear-gradient(135deg, rgba(255, 183, 3, 0.4), rgba(255, 68, 85, 0.4));
  border-color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.coins-stat {
  color: #ffd700;
  font-size: 1rem;
}

.coins-stat span.val {
  color: #ffe600;
}

/* Shop Modal Styles */
.shop-modal-content {
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.shop-user-balance {
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  padding: 8px 16px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.shop-user-balance span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.shop-coins-badge {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: #ffd700;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 650px) {
  .shop-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.shop-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.shop-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-3px);
}

.shop-card.active-skin {
  border-color: var(--accent-neon-yellow);
  background: linear-gradient(180deg, rgba(204, 255, 0, 0.12), rgba(255, 51, 102, 0.08));
  box-shadow: 0 0 16px rgba(204, 255, 0, 0.25);
}

.shop-card-preview {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.shop-card-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.shop-card-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  min-height: 30px;
}

.shop-card-btn {
  width: 100%;
  padding: 6px 0;
  border-radius: 10px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.shop-card-btn.btn-equipped {
  background: rgba(204, 255, 0, 0.2);
  color: var(--accent-neon-yellow);
  border: 1px solid rgba(204, 255, 0, 0.4);
  cursor: default;
}

.shop-card-btn.btn-select {
  background: linear-gradient(135deg, #00f0ff, #0077b6);
  color: white;
}

.shop-card-btn.btn-select:hover {
  filter: brightness(1.15);
  transform: scale(1.02);
}

.shop-card-btn.btn-buy {
  background: linear-gradient(135deg, #ffb703, #ff5500);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 119, 0, 0.35);
}

.shop-card-btn.btn-buy:hover {
  filter: brightness(1.15);
  transform: scale(1.02);
}

.shop-footer {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* Footer info */
.game-footer {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  align-items: center;
}

.game-footer kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-family: inherit;
  font-size: 0.75rem;
}

