:root {
  --bg: #11131c;
  --card: #1f2433;
  --card-2: #2b3144;
  --text: #eff1f7;
  --muted: #bbc2d4;
  --accent: #ffcc4d;
  --danger: #ff6b6b;
  --ok: #6be39a;
  --crit: #ff4de8;
  --essence: #a78bfa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top, #202640, var(--bg));
  color: var(--text);
}

.game-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.hud-item {
  background: var(--card);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
  border: 1px solid #31384f;
}

.battlefield,
.hero-zone {
  background: rgba(25, 30, 44, 0.9);
  border: 1px solid #2d3449;
  border-radius: 16px;
  padding: 0.85rem;
}

.monster-card {
  display: grid;
  place-items: center;
  gap: 0.6rem;
}

.monster-meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.93rem;
}

.monster-field {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 0.45rem;
  touch-action: manipulation;
  user-select: none;
}

.monster-button {
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  background: var(--card);
  border-radius: 16px;
  min-height: 86px;
  display: grid;
  place-items: center;
  border: 2px solid #343d57;
  transition: transform 100ms ease;
  padding: 0.2rem;
}

.monster-button.small {
  gap: 0.2rem;
}

.monster-button.primary {
  border-color: #ffcc4d;
  box-shadow: 0 0 0 1px #81631a;
}

.monster-button.primary.boss {
  border-color: #ff6b6b;
  box-shadow: 0 0 0 1px #7d1f1f;
}

.monster-button:active,
.monster-button.hit {
  transform: scale(0.95);
}

.monster-emoji {
  font-size: clamp(2rem, 8vw, 3rem);
}

.enemy-hp {
  font-size: 0.8rem;
  color: var(--muted);
}

.enemy-hp-track {
  display: block;
  width: 82%;
  height: 7px;
  background: #3b435f;
  border-radius: 999px;
  overflow: hidden;
}

.enemy-hp-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4ae389, #beff79);
}

.hp-section {
  width: 100%;
}

.hp-label {
  text-align: center;
  margin-bottom: 0.35rem;
}

.hp-track {
  width: 100%;
  height: 16px;
  background: #3a445f;
  border-radius: 999px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #4ae389, #beff79);
  width: 100%;
  transition: width 180ms linear;
}

.combat-effects {
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  color: var(--accent);
}

.hero-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}

.hero {
  font-size: 2.2rem;
}

.hero-title {
  margin: 0;
  font-weight: 700;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}


.abilities-zone {
  background: rgba(25, 30, 44, 0.9);
  border: 1px solid #2d3449;
  border-radius: 16px;
  padding: 0.85rem;
}

.abilities-zone h3 {
  margin: 0;
}

.abilities-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.ability-help-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #4b5577;
  border-radius: 999px;
  color: var(--text);
  background: #2a3147;
  font-weight: 800;
  cursor: pointer;
}

.abilities-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.ability-card {
  background: var(--card);
  border: 1px solid #3b445f;
  border-radius: 12px;
  padding: 0.55rem;
}

.ability-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 0.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #ff9f4d);
  color: #11131c;
  cursor: pointer;
}

.ability-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ability-cooldown-track {
  margin-top: 0.45rem;
  height: 8px;
  border-radius: 999px;
  background: #3a445f;
  overflow: hidden;
}

.ability-cooldown-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5d6a93, #2f3752);
  transition: width 180ms linear;
}

.ability-row {
  margin-top: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ability-badge {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--danger);
}

.ability-badge.ready {
  color: var(--ok);
}

.ability-btn.frenzy {
  background: linear-gradient(135deg, #a47dff, #67e3ff);
}

.ability-btn.midas {
  background: linear-gradient(135deg, #f6d365, #9be15d);
}

.ability-btn.execute {
  background: linear-gradient(135deg, #ff7e5f, #d7263d);
  color: #fff4ea;
}

.ability-badge.active {
  color: #ffd166;
}

.shop-subtitle {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.95rem;
  color: #d6dbff;
}
.companion-list {
  margin-top: 0.6rem;
  min-height: 52px;
  background: #20263a;
  border-radius: 10px;
  border: 1px dashed #3f4764;
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.companion-list.hidden-list {
  display: none;
}

.companion {
  font-size: 1rem;
  line-height: 1;
  background: #2a3249;
  border-radius: 999px;
  padding: 0.2rem 0.4rem;
  border: 1px solid transparent;
}

.companion.attacking {
  border-color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.language-switch {
  display: flex;
  gap: 0.5rem;
}

.automation-zone {
  display: grid;
  gap: 0.5rem;
}

.action-btn,
.prestige-btn,
.shop-buy,
.inv-equip,
.close,
.inv-tab {
  border: none;
  border-radius: 10px;
  padding: 0.6rem;
  font-weight: 700;
  cursor: pointer;
  color: #121420;
  background: var(--accent);
}

.inv-tab {
  padding: 0.45rem 0.55rem;
  font-size: 0.82rem;
}

.inv-tab.active {
  background: #6be39a;
}

.action-btn:disabled,
.shop-buy:disabled,
.prestige-btn:disabled,
.inv-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


.offline-open {
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  opacity: 0.9;
}
.panel {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 19, 0.78);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
}

.hidden {
  display: none;
}

.panel-content {
  width: min(92vw, 680px);
  max-height: 85vh;
  overflow: auto;
  background: var(--card-2);
  border: 1px solid #404a68;
  border-radius: 14px;
  padding: 1rem;
  position: relative;
}

.close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  padding: 0.4rem 0.55rem;
  background: #f18d8d;
}

.shop-gold {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
}

.shop-items,
.inventory-items,
.equipment-slots {
  display: grid;
  gap: 0.45rem;
}

.inventory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.shop-item,
.inventory-item,
.slot {
  background: #1f2435;
  border: 1px solid #404a68;
  border-radius: 10px;
  padding: 0.55rem;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.item-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.rarity-0 {
  color: #d0d4df;
}

.rarity-1 {
  color: #7cf0a0;
}

.rarity-2 {
  color: #82c8ff;
}

.rarity-3 {
  color: #c291ff;
}

.rarity-4 {
  color: #ffbf67;
}

/* ------------------------------------------------------------------ */
/*  FX Layer — floating damage numbers                                 */
/* ------------------------------------------------------------------ */

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.fx-float {
  position: absolute;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  animation: floatUp 800ms ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
}

.fx-float.crit {
  font-size: 1.5rem;
  color: var(--crit);
  text-shadow: 0 0 12px rgba(255, 77, 232, 0.6), 0 1px 4px rgba(0, 0, 0, 0.6);
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-60px) scale(0.7);
  }
}

/* ------------------------------------------------------------------ */
/*  Toast notifications                                                */
/* ------------------------------------------------------------------ */

.toast-container {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
  max-width: 340px;
}

.toast {
  background: linear-gradient(135deg, #2b3144, #3a4466);
  border: 1px solid #5a6490;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  animation: toastIn 400ms ease-out, toastOut 400ms 2600ms ease-in forwards;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast .toast-badge {
  font-size: 1.2rem;
  margin-right: 0.35rem;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(60px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ------------------------------------------------------------------ */
/*  Talent grid                                                        */
/* ------------------------------------------------------------------ */

.talent-section {
  margin-top: 1rem;
  border-top: 1px solid #404a68;
  padding-top: 0.75rem;
}

.talent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.45rem;
}

.talent-card {
  background: #1f2435;
  border: 1px solid #404a68;
  border-radius: 10px;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.talent-card .talent-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.talent-card .talent-info {
  color: var(--muted);
  font-size: 0.82rem;
}

.talent-card .talent-buy {
  border: none;
  border-radius: 8px;
  padding: 0.35rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  color: #121420;
  background: var(--essence);
}

.talent-card .talent-buy:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.talent-card .talent-buy.maxed {
  background: var(--ok);
}

/* ------------------------------------------------------------------ */
/*  Quest / Achievements panel                                         */
/* ------------------------------------------------------------------ */

.quest-list,
.achievement-list {
  display: grid;
  gap: 0.4rem;
}

.quest-item,
.achievement-item {
  background: #1f2435;
  border: 1px solid #404a68;
  border-radius: 10px;
  padding: 0.55rem;
}

.quest-item .quest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.quest-progress-track {
  height: 8px;
  background: #3a445f;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--essence), var(--accent));
  transition: width 200ms ease;
}

.quest-reward {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.quest-item.completed {
  border-color: var(--ok);
  opacity: 0.7;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.achievement-item .ach-badge {
  font-size: 1.4rem;
}

.achievement-item .ach-info {
  flex: 1;
}

.achievement-item .ach-name {
  font-weight: 600;
}

.achievement-item .ach-desc {
  font-size: 0.82rem;
  color: var(--muted);
}

.achievement-item .ach-reward {
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.1rem;
}

.achievement-item.locked {
  opacity: 0.4;
}

/* ------------------------------------------------------------------ */
/*  Offline / Welcome back                                             */
/* ------------------------------------------------------------------ */

.offline-content {
  text-align: center;
  padding: 1.5rem;
}

.offline-detail {
  font-size: 1.05rem;
  margin: 0.4rem 0;
}

.offline-gold {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/*  Settings extras                                                    */
/* ------------------------------------------------------------------ */

.settings-divider {
  border: none;
  border-top: 1px solid #404a68;
  margin: 0.75rem 0;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
}

.settings-row label {
  font-weight: 600;
  font-size: 0.92rem;
}

.settings-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-row input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/*  Reduce motion                                                      */
/* ------------------------------------------------------------------ */

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ------------------------------------------------------------------ */
/*  Essence color                                                      */
/* ------------------------------------------------------------------ */

.essence-color {
  color: var(--essence);
}

/* ------------------------------------------------------------------ */
/*  Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (min-width: 700px) {
  .hud {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .actions {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ---- NEW STYLES: Combo, Quests, Audio, Companions ---- */

/* Combo Gauge */
.combo-container {
  margin-top: 0.5rem;
  background: var(--card-2);
  border-radius: 8px;
  padding: 0.4rem;
  border: 1px solid #3c435b;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-container.hidden {
  display: none;
}

.combo-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--crit);
  margin-bottom: 0.2rem;
  display: flex;
  justify-content: space-between;
}

.combo-bar {
  height: 6px;
  background: #111;
  border-radius: 3px;
  overflow: hidden;
}

.combo-fill {
  background: linear-gradient(90deg, #ff4de8, #ffcc4d);
  height: 100%;
  border-radius: 3px;
  width: 0%;
  /* Transition handled in JS for reset */
}

/* Quests */
.quest-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quest-item {
  background: var(--card-2);
  padding: 0.6rem;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid #3c435b;
}

.quest-item.claimed {
  opacity: 0.6;
  filter: grayscale(0.5);
  border-color: #2b3144;
}

.quest-info {
  font-size: 0.9rem;
}

.quest-info strong {
  color: var(--text);
  display: block;
}

.quest-info small {
  color: var(--muted);
}

.quest-progress {
  grid-column: 1 / -1;
  background: #111;
  height: 14px;
  border-radius: 7px;
  position: relative;
  overflow: hidden;
}

.quest-fill {
  background: var(--ok);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.quest-text {
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.quest-claim-btn {
  background: var(--card);
  border: 1px solid #fff3;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
}

.quest-claim-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.quest-claim-btn.ready {
  background: var(--ok);
  color: #111;
  border-color: transparent;
  animation: pulse 1.5s infinite;
}

/* Companions */
.companion-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0.2rem;
  padding: 0.3rem;
  background: var(--card-2);
  border-radius: 8px;
  border: 1px solid #ffffff10;
  transition: transform 0.18s ease, box-shadow 0.2s ease;
  position: relative;
}

.companion-item.golden {
  border-color: var(--accent);
  box-shadow: 0 0 8px #ffcc4d40;
}

.companion-item.attacking {
  animation: lunge 0.28s ease-in-out;
  box-shadow: 0 0 0 2px #ffcc4d55;
}

.companion-item.attacking::after {
  content: "✨";
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 0.8rem;
  animation: spark 0.28s ease-out;
}

.companion-dps {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

@keyframes spark {
  from {
    opacity: 0.95;
    transform: translateY(0) scale(0.8);
  }

  to {
    opacity: 0;
    transform: translateY(-10px) scale(1.15);
  }
}

@keyframes lunge {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px) scale(1.1);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(107, 227, 154, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(107, 227, 154, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(107, 227, 154, 0);
  }
}
@media (max-width: 640px) {
  .abilities-list {
    grid-template-columns: 1fr;
  }
}
