:root {
  --theme-primary: #22c55e;
  --theme-bg: #030712;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

/* QuestGains v2.13 custom styles */
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background-color: var(--theme-bg); }
.tab-active, .subtab-active { background-color: var(--theme-primary); color: white; }
.modal { animation: pop 0.3s ease; }
.node-card { transition: all 0.2s ease; }
.modal-image { min-height: 200px; object-fit: cover; background: #111827; }
.scrollbar-thin::-webkit-scrollbar { height: 6px; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: #374151; border-radius: 999px; }

.equipped-title-bar {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(59, 130, 246, 0.12));
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 1.5rem;
  padding: 1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 30px rgba(0,0,0,0.18);
}

.hero-character-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  max-height: 23rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.character-card {
  position: relative;
  border-radius: 1.5rem;
  text-align: left;
  overflow: hidden;
  min-height: 11rem;
  border: 1px solid rgba(255,255,255,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0,0,0,0.35);
}

.character-card.active {
  border-color: rgba(255,255,255,0.45);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.6), 0 18px 40px rgba(34, 197, 94, 0.18);
}

.character-card-overlay,
.skill-tree-header-overlay {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.18), rgba(2, 6, 23, 0.82));
  padding: 1rem;
  height: 100%;
}

.faction-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.faction-badge.hero {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.22);
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.faction-badge.villain {
  color: #fee2e2;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.hero-skill-tree-panel {
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 1.75rem;
  padding: 1rem;
}

.skill-tree-header {
  border-radius: 1.5rem;
  overflow: hidden;
}

.skill-tree-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.skill-node-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.skill-node {
  width: 100%;
  background: linear-gradient(180deg, #111827, #0b1220);
  border: 1px solid #374151;
  border-radius: 1.4rem;
  padding: 1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.skill-node.unlocked {
  border-color: #4ade80;
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.22), 0 0 26px rgba(34, 197, 94, 0.16);
}

.skill-node.available {
  border-color: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.2), 0 0 20px rgba(250, 204, 21, 0.14);
  animation: pulse 2s infinite;
}

.skill-node.locked { opacity: 0.4; }

.skill-node.equipped {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.35), 0 0 24px rgba(59, 130, 246, 0.22);
}

.skill-node-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.skill-node-cost {
  font-size: 0.75rem;
  font-weight: 800;
  color: #4ade80;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.skill-node-equipped {
  font-size: 0.68rem;
  font-weight: 800;
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

.skill-node-name {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.skill-node-title {
  font-size: 0.82rem;
  color: #facc15;
  margin-top: 0.2rem;
  font-weight: 700;
}

.skill-node-desc,
.skill-node-perk {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-top: 0.55rem;
  line-height: 1.45;
}

.skill-node-perk {
  color: #86efac;
  font-weight: 600;
}

.skill-node-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.skill-node-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-size: 0.76rem;
  font-weight: 800;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.skill-node-btn:hover { transform: translateY(-1px); }
.skill-node-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.unlock-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
}

.equip-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

.skill-node-locked-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #9ca3af;
}

.skill-connector {
  width: 2px;
  height: 24px;
  background: #374151;
  margin: 0 auto;
}

.skill-connector.unlocked { background: #22c55e; }

.hero-streak-card {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.18), rgba(239, 68, 68, 0.16));
  border: 1px solid rgba(251, 146, 60, 0.35);
  border-radius: 1.5rem;
  padding: 0.95rem 1rem;
  font-weight: 800;
  color: #fdba74;
}

.achievement-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: #dcfce7;
  font-size: 0.82rem;
  font-weight: 700;
}

.macro-progress-track {
  width: 100%;
  height: 0.8rem;
  background: #1f2937;
  border-radius: 999px;
  overflow: hidden;
}

.macro-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* Portrait images */
.skill-tree-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.hero-detail-icon,
.hero-card-icon {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.pixel-portrait {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 8px;
}

.pixel-portrait.sprite-large {
  width: 160px;
  height: 160px;
  object-fit: cover;
}

.pixel-portrait.sprite-small {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.sprite-fallback {
  width: 160px;
  height: 160px;
  background: var(--sprite-color, #22c55e);
  border-radius: 50%;
  opacity: 0.6;
}

.sprite-fallback.sprite-small {
  width: 48px;
  height: 48px;
}

.pixel-sprite-container {
  width: 160px;
  height: 160px;
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pixel-sprite-container.small {
  width: 48px;
  height: 48px;
  margin: 0 auto 8px auto;
}

.character-card .pixel-sprite-container {
  pointer-events: none;
}



.water-drop {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  opacity: 0.45;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.water-drop.filled {
  opacity: 1;
  background: rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

.history-card {
  border: 1px solid rgba(255,255,255,0.05);
}

.inline-set-form {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(74, 222, 128, 0.18);
  border-radius: 1.2rem;
  padding: 1rem;
}

.unit-toggle-wrap {
  display: inline-flex;
  background: #0f172a;
  border-radius: 999px;
  padding: 0.25rem;
  gap: 0.25rem;
}

.unit-pill,
.recovery-pill {
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 0.95rem;
  background: #1f2937;
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 700;
}

.unit-pill.active,
.recovery-pill.active {
  background: #22c55e;
  color: white;
}

.recovery-pill {
  min-width: 2.75rem;
  font-size: 1rem;
}

.template-checkbox-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  max-height: 16rem;
  overflow-y: auto;
}

.template-option {
  display: block;
  background: #111827;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 1rem;
  padding: 0.8rem 0.9rem;
  font-size: 0.9rem;
}

@keyframes pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.18), 0 0 16px rgba(250, 204, 21, 0.1); }
  50% { box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.45), 0 0 28px rgba(250, 204, 21, 0.28); }
}


.tab-bar-btn {
  min-width: 0;
  white-space: nowrap;
}

#levelup-content,
#achievement-toast,
.tab-screen,
.hero-skill-tree-panel,
.character-card,
.skill-node,
.pixel-sprite-container,
.pixel-portrait,
canvas,
img,
input,
select,
textarea,
button {
  max-width: 100%;
}

.pixel-portrait.sprite-large {
  animation: heroFloat 3s ease-in-out infinite, heroGlow 3s ease-in-out infinite !important;
}

.levelup-confetti-piece {
  position: absolute;
  top: -12%;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  opacity: 0.95;
  animation: fall linear forwards;
}

@keyframes fall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes slideDown {
  0% { opacity: 0; transform: translate(-50%, -24px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes slideUp {
  0% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -24px); }
}

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

@keyframes heroGlow {
  0%, 100% { filter: drop-shadow(0 0 8px var(--hero-color, #22c55e)); }
  50% { filter: drop-shadow(0 0 16px var(--hero-color, #22c55e)) drop-shadow(0 0 32px var(--hero-color, #22c55e)); }
}

@media (max-width: 480px) {
  .tab-bar-btn {
    flex: 0 0 auto;
    font-size: 0.7rem;
    padding: 0.6rem 0.4rem;
    min-width: 52px;
    white-space: nowrap;
  }

  .pixel-sprite-container,
  .pixel-portrait.sprite-large,
  .sprite-fallback {
    width: 132px;
    height: 132px;
  }
}


.gear-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0.9rem; }
.gear-card { border-radius: 1.25rem; border: 1px solid rgba(255,255,255,0.08); padding: 1rem; background: linear-gradient(180deg, rgba(17,24,39,1), rgba(15,23,42,1)); }
.gear-card.locked { opacity: 0.55; filter: grayscale(0.2); }
.gear-card.equipped { border-color: rgba(34,197,94,0.7); box-shadow: 0 0 0 1px rgba(34,197,94,0.35), 0 0 24px rgba(34,197,94,0.18); }
.theme-swatch { width: 2.25rem; height: 2.25rem; border-radius: 999px; border: 2px solid rgba(255,255,255,0.12); cursor: pointer; transition: transform 0.15s ease, border-color 0.2s ease; }
.theme-swatch.active { border-color: white; transform: scale(1.08); }
.theme-swatch.locked { background: #4b5563 !important; cursor: not-allowed; opacity: 0.6; }
.class-card { border: 1px solid rgba(255,255,255,0.08); border-radius: 1.5rem; padding: 1rem; text-align: left; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
.class-card.selected { border-color: rgba(34,197,94,0.7); box-shadow: 0 0 0 1px rgba(34,197,94,0.35), 0 0 24px rgba(34,197,94,0.14); }
.class-overlay.hidden { display:none; }
.rival-card { border: 1px solid rgba(239,68,68,0.35); background: linear-gradient(135deg, rgba(127,29,29,0.28), rgba(17,24,39,1)); border-radius: 1.5rem; padding: 1rem; }
.boss-card { border: 1px solid rgba(255,255,255,0.08); background: linear-gradient(180deg, rgba(17,24,39,1), rgba(3,7,18,1)); border-radius: 1.5rem; padding: 1rem; }
.theme-accent { color: var(--theme-primary); }
.theme-accent-bg { background-color: var(--theme-primary); }
.exercise-filter-chip { background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 999px; padding: 0.3rem 0.85rem; font-size: 0.75rem; color: #9ca3af; cursor: pointer; transition: all 0.15s ease; white-space: nowrap; }
.exercise-filter-chip.active { background: #22c55e; border-color: #22c55e; color: #030712; font-weight: 600; }
.exercise-search-row { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: 1rem; padding: 0.75rem 1rem; display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: background 0.15s ease; }
.exercise-search-row:hover { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); }
