/* ============================================================================
 * TRAP DEVIL FURY - STYLESHEET (styles/main.css)
 * Responsive Desktop + Mobile Arcade UI, Glassmorphism Modals & Touch Controls
 * ============================================================================ */

:root {
  --bg-dark: #0c050a;
  --bg-panel: rgba(25, 11, 22, 0.88);
  --primary: #ff2a54;
  --primary-glow: rgba(255, 42, 84, 0.45);
  --accent: #00f5d4;
  --gold: #ffbe0b;
  --text-main: #ffffff;
  --text-muted: #c9b8c4;
  --border-subtle: rgba(255, 255, 255, 0.14);
}

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

body {
  font-family: "Cairo", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at center, #1f0c19 0%, #090307 100%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
}

#app-wrapper {
  width: 100%;
  max-width: 980px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================================================
 * TOP HUD
 * ============================================================================ */
#top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hud-right,
.hud-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-center {
  text-align: center;
  flex: 1;
  min-width: 180px;
}

.level-name {
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--gold);
}

.level-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hud-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hud-btn:hover {
  background: rgba(255, 42, 84, 0.28);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.reward-btn {
  background: linear-gradient(135deg, rgba(255, 190, 11, 0.22), rgba(255, 42, 84, 0.22));
  border-color: rgba(255, 190, 11, 0.55);
}

.ad-tag {
  background: var(--gold);
  color: #14080e;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 4px;
}

.level-pill {
  background: rgba(0, 245, 212, 0.16);
  border: 1px solid rgba(0, 245, 212, 0.55);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 0.84rem;
}

.death-pill {
  background: rgba(255, 42, 84, 0.16);
  border: 1px solid rgba(255, 42, 84, 0.4);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.82rem;
}

.death-pill small {
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================================
 * STATUS / TAUNT BANNER
 * ============================================================================ */
.status-banner {
  background: rgba(255, 42, 84, 0.14);
  border: 1px solid rgba(255, 42, 84, 0.35);
  border-radius: 9px;
  padding: 5px 12px;
  text-align: center;
  font-weight: 700;
  font-size: 0.88rem;
  color: #ffd6e0;
  transition: transform 0.2s ease;
}

.status-banner.pop {
  animation: bannerPulse 0.38s ease;
}

@keyframes bannerPulse {
  0% { transform: scale(0.95); background: rgba(255, 42, 84, 0.45); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ============================================================================
 * LEVEL EDITOR TOOLBAR
 * ============================================================================ */
.editor-toolbar {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-tools-group,
.editor-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.tool-btn,
.action-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  cursor: pointer;
}

.tool-btn.active {
  background: var(--accent);
  color: #090d16;
  border-color: #fff;
}

.action-btn.success {
  background: #00b4d8;
  color: #fff;
}

.action-btn.primary {
  background: #9b5de5;
  color: #fff;
}

.action-btn.danger,
.tool-btn.danger.active {
  background: var(--primary);
  color: #fff;
}

/* ============================================================================
 * GAME VIEWPORT & CANVAS
 * ============================================================================ */
#viewport-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #14080e;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
}

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

/* ============================================================================
 * OVERLAYS & MODALS
 * ============================================================================ */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: rgba(10, 4, 9, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.hidden {
  display: none !important;
}

.menu-card,
.modal-card {
  background: linear-gradient(160deg, rgba(36, 14, 31, 0.96), rgba(16, 7, 15, 0.98));
  border: 1px solid rgba(255, 42, 84, 0.45);
  border-radius: 16px;
  padding: 22px 26px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.75);
}

.wide-modal {
  max-width: 680px;
}

.devil-badge {
  display: inline-block;
  background: rgba(255, 42, 84, 0.2);
  border: 1px solid var(--primary);
  color: var(--gold);
  font-weight: 900;
  font-size: 0.78rem;
  padding: 3px 12px;
  border-radius: 99px;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.menu-title {
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #ffffff, #ffbe0b, #ff2a54);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.menu-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.5;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.row-buttons {
  flex-direction: row;
  justify-content: center;
}

.cta-btn {
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 900;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cta-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.cta-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-cta {
  background: linear-gradient(135deg, #ff2a54, #ff6b00);
  color: #fff;
  box-shadow: 0 6px 20px var(--primary-glow);
}

.secondary-cta {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--border-subtle);
}

.accent-cta {
  background: linear-gradient(135deg, #00f5d4, #00bbf9);
  color: #071018;
}

.controls-guide {
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

code {
  background: rgba(255, 255, 255, 0.14);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--gold);
}

/* ============================================================================
 * LEVEL SELECT GRID
 * ============================================================================ */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 8px;
  max-height: 270px;
  overflow-y: auto;
  padding: 4px;
}

.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.chapter-tab {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chapter-tab.active {
  background: linear-gradient(135deg, var(--primary), #ff6b00);
  border-color: var(--gold);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.chapter-tab.locked-tab {
  opacity: 0.55;
}

.chapter-info-bar {
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(0, 245, 212, 0.1);
  border: 1px solid rgba(0, 245, 212, 0.35);
  border-radius: 8px;
  padding: 5px 10px;
  margin-bottom: 10px;
}

.level-card.upcoming-card {
  opacity: 0.48;
  border-style: dashed;
}

.level-card {
  font-family: inherit;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.level-card:hover {
  border-color: var(--primary);
  background: rgba(255, 42, 84, 0.18);
  transform: translateY(-2px);
}

.level-card.completed {
  border-color: var(--accent);
  background: rgba(0, 245, 212, 0.1);
}

.level-card.boss-card {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(255, 42, 84, 0.25), rgba(155, 93, 229, 0.25));
}

/* ============================================================================
 * SKINS WARDROBE GRID
 * ============================================================================ */
.skins-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
  max-height: 310px;
  overflow-y: auto;
  padding: 4px;
}

.skin-card {
  font-family: inherit;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  transition: all 0.15s ease;
}

.skin-card:hover {
  border-color: var(--gold);
  background: rgba(255, 190, 11, 0.14);
  transform: translateY(-2px);
}

.skin-card.selected {
  border: 2px solid var(--accent);
  background: rgba(0, 245, 212, 0.15);
}

.skin-name {
  font-weight: 900;
  font-size: 0.88rem;
  color: var(--gold);
}

.skin-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 2px 0 4px;
}

.skin-status {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
}

.level-num {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold);
}

.level-title {
  font-size: 0.76rem;
  font-weight: 700;
}

.level-badge {
  font-size: 0.68rem;
  color: var(--accent);
}

/* ============================================================================
 * WIN & AD MODALS
 * ============================================================================ */
.win-icon {
  font-size: 2.5rem;
  margin-bottom: 4px;
}

.win-msg {
  color: var(--gold);
  font-weight: 700;
  margin: 6px 0;
}

.win-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.ad-badge {
  display: inline-block;
  background: var(--gold);
  color: #14080e;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 2px 9px;
  border-radius: 99px;
  margin-bottom: 8px;
}

.ad-timer-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 900;
  margin: 14px auto;
  color: var(--accent);
}

#json-textarea {
  width: 100%;
  background: #090408;
  color: #00f5d4;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  font-size: 0.78rem;
  margin: 10px 0;
  resize: vertical;
}

.json-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================================
 * MOBILE MULTI-TOUCH CONTROLS
 * ============================================================================ */
#mobile-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 6px;
}

.touch-dpad,
.touch-actions {
  display: flex;
  gap: 10px;
}

.touch-btn {
  font-family: inherit;
  min-width: 68px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.touch-btn.active {
  background: var(--primary);
  border-color: #fff;
  transform: scale(0.95);
}

.jump-btn {
  min-width: 95px;
  background: rgba(255, 42, 84, 0.25);
  border-color: var(--primary);
}

.dash-btn {
  min-width: 90px;
  background: rgba(0, 245, 212, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================================
 * GOOGLE ADSENSE BANNER CONTAINER
 * ============================================================================ */
.ad-banner-slot {
  width: 100%;
  min-height: 64px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px dashed rgba(255, 190, 11, 0.4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 680px) {
  .menu-title {
    font-size: 1.3rem;
  }
  .menu-card,
  .modal-card {
    padding: 14px;
  }
  .hud-center {
    order: 3;
    width: 100%;
  }
}
