/* ════════════════════════════════════════════
   ROOT TOKENS
════════════════════════════════════════════ */
:root {
  --blood:        #8b0000;
  --blood-bright: #e74c3c;
  --blood-glow:   rgba(231,76,60,0.5);
  --shadow:       #050102;
  --ink:          #0a0204;
  --glass:        rgba(10, 2, 4, 0.75);
  --glass-bright: rgba(139, 0, 0, 0.1);
  --bone:         #f5e6d3;
  --bone-dim:     #d5c7b5;
  --ash:          #cfc5b8;
  --player-clr:   #00d2ff;
  --ai-clr:       #ff4d4d;
  --gold:         #ffcc33;
  --gold-dim:     #c5a02a;
  --heal-clr:     #2ecc71;
  --poison-clr:   #a362ea;
  --card-back:    #150406;
  --card-front:   #080102;
  --border-clr:   rgba(139, 0, 0, 0.3);
 
  --stage-1: #8b0000;
  --stage-2: #5c0099;
  --stage-3: #004488;
  --stage-4: #008844;
  --stage-5: #880000;
}
 
* { 
  box-sizing: border-box; 
  margin: 0; padding: 0; 
  -webkit-tap-highlight-color: transparent;
}
 
html { 
  scroll-behavior: smooth; 
  overflow-x: hidden;
  width: 100%;
}
 
body {
  background: var(--shadow);
  color: var(--bone);
  font-family: 'Crimson Text', serif;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='5' fill='%238b0000' opacity='0.9'/%3E%3Ccircle cx='10' cy='10' r='2' fill='%23ff0000'/%3E%3C/svg%3E") 10 10, pointer;
  position: relative;
}
 
/* Atmospheric background layers */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 15% 85%, rgba(139,0,0,0.12) 0%, transparent 65%),
    radial-gradient(ellipse 50% 70% at 85% 15%, rgba(80,0,30,0.14) 0%, transparent 65%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(18,4,6,1) 0%, rgba(4,0,2,1) 100%);
}
 
/* Grain overlay */
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.45;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  animation: grain 0.4s steps(2) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  25%     { transform: translate(-2px,1px); }
  50%     { transform: translate(1px,-2px); }
  75%     { transform: translate(-1px,-1px); }
}
 
/* ════════════════════════════════════════════
   SCREEN MANAGEMENT
════════════════════════════════════════════ */
.screen {
  display: none;
  position: relative; z-index: 1;
  min-height: 100vh;
}
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ════════════════════════════════════════════
   BACKEND: AUTH STATUS & HEADER
════════════════════════════════════════════ */
.auth-status-header {
  width: fit-content;
  margin: 10px 0 10px 15px;
  animation: fadeIn 1s ease 0.8s both;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.auth-prompt-box {
  width: 100%;
  background: rgba(139, 0, 0, 0.05);
  border: 1px dashed var(--border-clr);
  border-radius: 16px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  transition: all 0.3s;
}

.auth-prompt-box:hover {
  background: rgba(139, 0, 0, 0.1);
  border-color: var(--blood);
}

.auth-prompt-text {
  font-size: 0.75rem;
  color: var(--ash);
  font-style: italic;
}

.auth-link-btn {
  display: inline-block;
  padding: 12px 30px;
  font-size: 0.7rem;
  text-decoration: none;
}

.user-profile-badge {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: auto;
  background: transparent;
  border: none;
  padding: 8px 0;
  transition: all 0.3s;
}

/* Match History Items */
.history-item {
  background: rgba(139, 0, 0, 0.05);
  border: 1px solid rgba(139, 0, 0, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.history-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--blood);
  opacity: 0.5;
}

.history-item:hover {
  background: rgba(139, 0, 0, 0.1);
  border-color: var(--blood-bright);
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.hi-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hi-result {
  font-family: 'Cinzel Decorative', serif;
  font-weight: bold;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 4px;
  text-transform: uppercase;
}

.hi-result.win { 
  color: var(--gold); 
  background: rgba(255, 204, 51, 0.1);
  border: 1px solid rgba(255, 204, 51, 0.2);
}

.hi-result.lose { 
  color: var(--blood-bright); 
  background: rgba(139, 0, 0, 0.1);
  border: 1px solid rgba(139, 0, 0, 0.2);
}

.hi-stage {
  color: var(--bone);
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.hi-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: 0.65rem;
  color: var(--bone-dim);
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 8px;
}

.hi-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hi-label {
  color: var(--ash);
  font-size: 0.55rem;
  text-transform: uppercase;
}

.hi-date {
  font-size: 0.6rem;
  color: var(--ash);
  text-align: right;
  font-style: italic;
  margin-top: 4px;
}

.user-badge-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-badge-avatar {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px var(--blood));
}

.user-badge-info {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.user-badge-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: bold;
}

.user-badge-tag {
  font-size: 0.6rem;
  color: var(--ash);
  letter-spacing: 0.05em;
}

.logout-minimal-btn {
  background: transparent;
  border: 1px solid rgba(139, 0, 0, 0.4);
  color: var(--ash);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.55rem;
  font-family: 'Cinzel Decorative', serif;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-minimal-btn:hover {
  background: var(--blood);
  color: var(--bone);
  border-color: var(--blood-bright);
}

/* ════════════════════════════════════════════
   TITLE SCREEN
════════════════════════════════════════════ */
#titleScreen {
  justify-content: center;
  padding: 20px 20px 40px;
  gap: 0;
}
 
.title-bg-art {
  position: fixed; inset: 0; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 28vw; opacity: 0.03; pointer-events: none;
  animation: titleDrift 12s ease-in-out infinite alternate;
  filter: blur(2px);
}
@keyframes titleDrift {
  from { transform: scale(1) rotate(-3deg); }
  to   { transform: scale(1.08) rotate(3deg); }
}
 
.title-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; text-align: center; 
  width: 100%;
  max-width: 600px;
  padding: 0 15px;
}
 
.title-eyebrow {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.4em;
  color: var(--blood-bright);
  text-transform: uppercase;
  animation: fadeInDown 0.8s ease both;
  text-shadow: 0 0 10px rgba(139,0,0,0.3);
}
.game-title {
  font-family: 'Creepster', cursive;
  font-size: clamp(2rem, 10vw, 4.5rem);
  color: var(--blood);
  line-height: 1.05;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow:
    0 0 20px rgba(139,0,0,1),
    0 0 40px rgba(139,0,0,0.8),
    0 0 80px rgba(139,0,0,0.4),
    4px 4px 0 #000;
  animation: titlePulse 3s ease-in-out infinite alternate, fadeInDown 1s ease 0.2s both;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
  word-wrap: break-word;
  max-width: 100%;
}
@keyframes titlePulse {
  from { text-shadow: 0 0 40px rgba(139,0,0,1), 0 0 80px rgba(139,0,0,0.5), 3px 3px 0 #000; }
  to   { text-shadow: 0 0 60px rgba(192,57,43,1), 0 0 120px rgba(192,57,43,0.7), 0 0 200px rgba(139,0,0,0.3), 3px 3px 0 #000; }
}
.title-sub {
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
  font-style: italic; color: var(--bone-dim);
  letter-spacing: 0.08em;
  animation: fadeInDown 1s ease 0.4s both;
}
 
.title-divider {
  width: 80%; max-width: 400px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--blood), transparent);
  animation: fadeIn 1s ease 0.6s both;
}
 
.title-story {
  font-size: 0.9rem; color: var(--bone-dim); font-style: italic;
  max-width: 400px; line-height: 1.6;
  animation: fadeIn 1s ease 0.8s both;
}

/* User Header (Logged in) */
.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 10px 20px;
  width: 100%;
  max-width: 380px;
  margin-bottom: 10px;
}

.user-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-header-avatar {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 5px var(--gold));
}

.user-header-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: bold;
}

.logout-header-btn {
  background: rgba(139, 0, 0, 0.4);
  border: 1px solid var(--blood);
  color: var(--bone);
  padding: 6px 15px;
  border-radius: 6px;
  font-size: 0.55rem;
  cursor: pointer;
  font-family: 'Cinzel Decorative', serif;
  transition: all 0.2s;
}

.logout-header-btn:hover {
  background: rgba(139, 0, 0, 0.7);
  border-color: var(--blood-bright);
}
 
.title-stats-bar {
  display: flex; 
  gap: clamp(10px, 4vw, 30px);
  flex-wrap: wrap; 
  justify-content: center;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(139,0,0,0.5);
  border-radius: 8px; 
  padding: 10px 25px;
  width: 100%;
  max-width: 480px;
  margin: 5px 0;
  animation: fadeIn 1s ease 1s both;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.ts-item {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.68rem; 
  color: var(--bone);
  letter-spacing: 0.08em;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.ts-val { 
  color: var(--blood-bright); 
  margin-right: 6px; 
  font-weight: 700; 
  font-size: 0.85rem;
  text-shadow: 0 0 5px #000, 0 0 15px rgba(139, 0, 0, 0.6);
}
 
.btn-primary {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.85rem; letter-spacing: 0.2em;
  padding: 16px 42px;
  background: linear-gradient(135deg, #8b0000 0%, #450000 100%);
  border: 1px solid rgba(231,76,60,0.6);
  color: var(--bone); border-radius: 4px; cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), inset 0 0 15px rgba(231,76,60,0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
  animation: fadeInUp 1s ease 1.2s both;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%); transition: transform 0.6s;
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: #ff4d4d;
  box-shadow: 0 10px 40px rgba(139,0,0,0.5), inset 0 0 25px rgba(231,76,60,0.3);
  color: #fff;
}
.btn-primary:hover::after { transform: translateX(100%); }
.btn-primary:active { transform: scale(0.96) translateY(0); }
 
.btn-secondary {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem; letter-spacing: 0.15em;
  padding: 12px 20px;
  background: rgba(139, 0, 0, 0.08);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border-clr);
  color: var(--bone-dim); border-radius: 4px; cursor: pointer;
  text-transform: uppercase; transition: all 0.25s;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 110px;
}
.btn-secondary:hover {
  background: rgba(139, 0, 0, 0.2);
  border-color: var(--blood-bright);
  color: var(--bone);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

/* ════════════════════════════════════════════
   BACKEND: DASHBOARD & HUD
════════════════════════════════════════════ */
.dashboard-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
  padding: 5px;
}

.dash-user-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.7rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  margin-bottom: 5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-clr);
  padding-bottom: 5px;
}

.dash-performance {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.perf-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--blood);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem;
  color: var(--blood-bright);
  box-shadow: 0 0 8px var(--blood-glow);
}

.perf-info {
  display: flex;
  flex-direction: column;
}

.perf-label {
  font-size: 0.55rem;
  color: var(--ash);
  text-transform: uppercase;
}

.perf-val {
  font-size: 0.8rem;
  color: var(--bone);
  font-weight: bold;
}

.best-stage-card {
  background: linear-gradient(135deg, rgba(139, 0, 0, 0.1) 0%, rgba(10, 2, 4, 0.8) 100%);
  border: 1px solid rgba(139, 0, 0, 0.3);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 10px;
  position: relative;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}


.bsc-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.75rem;
  color: var(--gold);
  margin-bottom: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bsc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.bsc-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bsc-label {
  font-size: 0.5rem;
  color: var(--ash);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bsc-val {
  font-size: 0.85rem;
  color: var(--bone);
  font-family: 'Cinzel', serif;
}

.dash-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.7rem;
  color: var(--ash);
  margin: 15px 0 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.dash-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-clr), transparent);
}

.recent-descent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  margin-bottom: 6px;
  transition: background 0.2s;
  border-left: 2px solid transparent;
}

.recent-descent-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--blood);
}

.rdi-stage { 
  color: var(--bone-dim); 
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem;
}

.rdi-pts { 
  color: var(--ash); 
  font-size: 0.55rem;
  margin-top: 2px;
}

.rdi-date { 
  color: var(--ash); 
  font-size: 0.6rem; 
  font-style: italic;
}

.leaderboard-side-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
}

.leaderboard-item {
  background: rgba(139, 0, 0, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.leaderboard-item:hover {
  background: rgba(139, 0, 0, 0.12);
  border-color: rgba(139, 0, 0, 0.3);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.leaderboard-item.current-user {
  background: rgba(255, 204, 51, 0.04);
  border: 1px solid rgba(255, 204, 51, 0.25);
  box-shadow: inset 0 0 10px rgba(255, 204, 51, 0.05);
}

.leaderboard-item.current-user:hover {
  background: rgba(255, 204, 51, 0.08);
  border-color: var(--gold);
}

.li-rank-col {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
}

.li-rank {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--bone-dim);
  white-space: nowrap;
}

.leaderboard-item:nth-child(1) .li-rank {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 204, 51, 0.6);
}

.leaderboard-item:nth-child(2) .li-rank {
  color: #e0e0e0;
  text-shadow: 0 0 8px rgba(224, 224, 224, 0.5);
}

.leaderboard-item:nth-child(3) .li-rank {
  color: #cd7f32;
  text-shadow: 0 0 8px rgba(205, 127, 50, 0.5);
}

.li-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.li-username {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--bone);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.leaderboard-item.current-user .li-username {
  color: var(--gold);
}

.li-stage {
  font-size: 0.55rem;
  color: var(--ash);
  font-style: italic;
}

.li-score-col {
  text-align: right;
}

.li-score {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--blood-bright);
}

.leaderboard-item.current-user .li-score {
  color: var(--gold);
  text-shadow: 0 0 5px rgba(255, 204, 51, 0.4);
}

.history-side-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
}

.side-history-item {
  background: rgba(139, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.side-history-item:hover {
  background: rgba(139, 0, 0, 0.1);
  border-color: rgba(139, 0, 0, 0.2);
  transform: translateX(3px);
}

.side-history-item.win { border-left-color: var(--gold); }
.side-history-item.lose { border-left-color: var(--blood-bright); }

.shi-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shi-stage {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem;
  color: var(--bone);
}

.shi-result {
  font-size: 0.55rem;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.05em;
}

.shi-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.55rem;
  color: var(--ash);
  font-style: italic;
}

.shi-date {
  font-size: 0.55rem;
  color: var(--ash);
  opacity: 0.8;
}

.history-container::-webkit-scrollbar {
  width: 4px;
}

.history-container::-webkit-scrollbar-thumb {
  background: var(--blood);
  border-radius: 10px;
}
 
.stage-section {
  width: 100%;
  margin: 15px 0 10px;
}

.section-header {
  margin-bottom: 8px;
}

.section-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--blood-bright);
  text-shadow: 0 0 5px #000, 0 0 10px rgba(139, 0, 0, 0.4);
  text-align: center;
}

.stage-select-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px; 
  width: 100%; 
  max-width: 480px;
  padding: 10px 0;
  margin: 0 auto;
  animation: fadeIn 1s ease 1s both;
}
 
.stage-btn {
  font-family: 'Cinzel Decorative', serif;
  padding: 16px 12px; border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-clr);
  cursor: pointer;
  text-align: center; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative; overflow: hidden;
  flex: 1 1 130px;
  max-width: 150px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
.stage-btn:not(.locked):hover {
  transform: translateY(-5px);
  border-color: var(--blood-bright);
  box-shadow: 0 12px 30px rgba(139,0,0,0.3);
  background: rgba(139, 0, 0, 0.15);
}
.stage-btn .stage-num {
  font-size: 1.4rem; display: block; margin-bottom: 4px;
}
.stage-btn .stage-name {
  font-family: 'Outfit', sans-serif;
  font-size: 0.6rem; letter-spacing: 0.1em; font-weight: 600;
  text-transform: uppercase; display: block; margin-bottom: 2px;
}
.stage-btn .stage-pairs {
  font-size: 0.48rem; color: var(--ash);
  font-family: 'Crimson Text', serif; font-style: italic;
}
.stage-btn.locked {
  opacity: 0.35; cursor: not-allowed;
  filter: grayscale(1);
}
.stage-btn.locked::after {
  content: '🔒'; position: absolute;
  top: 4px; right: 6px; font-size: 0.8rem;
}
.stage-btn.cleared::before {
  content: '✓'; position: absolute;
  top: 4px; right: 7px; font-size: 0.7rem;
  font-family: 'Cinzel Decorative', serif;
  color: var(--blood-bright);
  text-shadow: 0 0 5px #000;
}
 
/* ════════════════════════════════════════════
   GAME SCREEN
════════════════════════════════════════════ */
#gameScreen {
  padding: 12px 14px 36px;
  gap: 10px;
  max-width: 980px; margin: 0 auto; width: 100%;
}
 
/* Stage banner */
.stage-banner {
  width: 100%; text-align: center;
  padding: 6px 0 2px;
}
.stage-banner-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.55rem, 1.5vw, 0.8rem);
  letter-spacing: 0.2em; color: var(--ash);
  text-transform: uppercase;
}
.stage-banner-name {
  font-family: 'Metal Mania', cursive;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: var(--bone);
  text-shadow: 0 0 25px rgba(139,0,0,0.8), 2px 2px 0 #000;
  line-height: 1;
  letter-spacing: 0.05em;
}
 
/* ── BATTLE HUD ── */
.battle-hud {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
  background: transparent;
  border: none;
  padding: clamp(12px, 3vw, 24px);
  position: relative;
  box-shadow: none;
}

@media (max-width: 600px) {
  .battle-hud {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    padding: 12px;
  }
  .vs-col {
    grid-column: 1 / span 2;
    order: -1;
    flex-direction: row;
    margin-bottom: 4px;
  }
  .vs-badge { font-size: 1.2rem; }
  .turn-indicator { bottom: -18px; }
}
 
.fighter { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
 
.fighter-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.6rem, 1.5vw, 0.85rem);
  letter-spacing: 0.07em;
}
.fighter.player .fighter-name { color: var(--player-clr); }
.fighter.enemy  .fighter-name { color: var(--ai-clr); }
 
/* ── Fighter Avatars (pixel art images) ── */
.fighter-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.fighter-avatar img {
  width: clamp(95px, 18vw, 140px);
  height: clamp(95px, 18vw, 140px);
  object-fit: cover;
  object-position: center top;
  border-radius: 10px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  transition: border-color 0.4s, box-shadow 0.3s;
}

.fighter.player .fighter-avatar img {
  border: 2px solid var(--player-clr);
}

.fighter.enemy .fighter-avatar img {
  border: 2px solid var(--ai-clr);
  box-shadow: 0 0 12px rgba(231,76,60,0.4), 0 0 4px rgba(0,0,0,0.8);
  transition: all 0.3s ease;
}

/* Avatar hit flash */
@keyframes avatarHit {
  0%,100% { filter: brightness(1); }
  40%     { filter: brightness(2.2) saturate(2); }
}
.fighter-avatar img.avatar-hit { animation: avatarHit 0.35s ease; }

/* Boss stage: gold border on enemy */
body.boss-stage .fighter.enemy .fighter-avatar img {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(240,192,64,0.6);
}


.hp-track {
  width: 100%; height: 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 4px; overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
.hp-fill {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.hp-fill::after {
  content: ''; position: absolute; inset: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, transparent 100%);
  border-radius: 99px;
}
.fighter.player .hp-fill {
  background: linear-gradient(90deg, #1565c0, var(--player-clr));
  box-shadow: 0 0 8px rgba(79,195,247,0.4);
}
.fighter.enemy .hp-fill {
  float: right;
  background: linear-gradient(90deg, var(--ai-clr), #ff8888);
  box-shadow: 0 0 8px rgba(231,76,60,0.4);
}
.hp-fill.low {
  background: linear-gradient(90deg, #5a0000, #ff3333) !important;
  animation: hpLowPulse 1s ease-in-out infinite alternate;
}
@keyframes hpLowPulse {
  from { box-shadow: 0 0 4px rgba(255,50,50,0.4); }
  to   { box-shadow: 0 0 16px rgba(255,50,50,0.9); }
}
@keyframes hpDamage {
  0%,100% { filter: brightness(1); }
  35%     { filter: brightness(3) saturate(2.5); }
}
@keyframes hpHeal {
  0%,100% { filter: brightness(1); }
  40%     { filter: brightness(2) hue-rotate(90deg); }
}
.hp-fill.dmg-anim  { animation: hpDamage 0.4s ease; }
.hp-fill.heal-anim { animation: hpHeal 0.5s ease; }
 
.hp-row {
  display: flex; justify-content: space-between;
  width: 100%;
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.55rem, 1.3vw, 0.75rem);
}
.hp-cur { color: var(--bone); }
.hp-max { color: var(--ash); }
 
/* Power-up indicators */
.fighter-buffs {
  display: flex; gap: 4px; flex-wrap: wrap; min-height: 16px;
}
.buff-pip {
  font-size: 0.7rem; padding: 1px 5px;
  border-radius: 99px; border: 1px solid rgba(240,192,64,0.4);
  background: rgba(240,192,64,0.1); color: var(--gold);
  font-family: 'Cinzel Decorative', serif; font-size: 0.42rem;
  letter-spacing: 0.05em; white-space: nowrap;
  animation: buffPip 0.4s ease;
}
@keyframes buffPip { from { transform: scale(0); } to { transform: scale(1); } }
 
.vs-col {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  padding: 0 4px;
}
.vs-badge {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.75rem, 2vw, 1.1rem);
  color: var(--blood-bright);
  text-shadow: 0 0 12px var(--blood-glow);
}
 
/* Combo badge */
.combo-badge {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.4rem, 1vw, 0.55rem);
  padding: 3px 8px; border-radius: 99px;
  border: 1px solid rgba(240,192,64,0.4);
  background: rgba(240,192,64,0.1); color: var(--gold);
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.combo-badge.visible { opacity: 1; transform: scale(1); }
.combo-badge.tier-2 { border-color: rgba(255,160,0,0.6); background: rgba(255,140,0,0.15); color: #ffaa00; }
.combo-badge.tier-3 { border-color: rgba(255,80,0,0.7); background: rgba(255,60,0,0.18); color: #ff7722;
  box-shadow: 0 0 10px rgba(255,80,0,0.4); }
.combo-badge.tier-4 { border-color: rgba(200,0,200,0.8); background: rgba(180,0,200,0.2); color: #ee44ee;
  box-shadow: 0 0 16px rgba(200,0,200,0.5); animation: comboPulse 0.6s ease-in-out infinite alternate; }
@keyframes comboPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.12); }
}
@keyframes comboPop {
  0%  { transform: scale(1); }
  40% { transform: scale(1.5) rotate(-5deg); }
  70% { transform: scale(0.9) rotate(3deg); }
  100%{ transform: scale(1); }
}
 
.turn-indicator {
  position: absolute; bottom: -13px; left: 50%; transform: translateX(-50%);
  font-family: 'Cinzel Decorative', serif; font-size: 0.48rem;
  letter-spacing: 0.14em; padding: 3px 14px; border-radius: 99px;
  border: 1px solid; background: var(--shadow);
  white-space: nowrap; text-transform: uppercase; transition: all 0.3s;
}
.turn-indicator.player-turn { color: var(--player-clr); border-color: var(--player-clr); }
.turn-indicator.ai-turn     { color: var(--ai-clr);     border-color: var(--ai-clr); }
.turn-indicator.paused      { color: var(--ash);         border-color: var(--ash); }
 
/* ── HUD STRIP ── */
.hud-strip {
  width: 100%; display: flex; gap: 8px;
  align-items: center; flex-wrap: wrap; justify-content: center;
}
.hud-pill {
  display: flex; flex-direction: column; align-items: center;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-clr);
  border-radius: 8px; padding: 8px 18px;
  min-width: 80px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.hud-val {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.9rem, 2.4vw, 1.25rem);
  color: var(--blood-bright);
  text-shadow: 0 0 15px var(--blood-glow);
  line-height: 1;
}
.hud-label {
  font-size: 0.55rem; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ash); margin-top: 2px;
}
.hud-pill.timer-warning .hud-val { color: #ff4444; animation: timerBlink 0.5s ease-in-out infinite alternate; }
@keyframes timerBlink { from { opacity: 1; } to { opacity: 0.4; } }
 

 
/* ── AI TURN BANNER ── */
#aiOverlay {
  width: 100%; display: none;
}
#aiOverlay.active { display: block; }
.ai-box {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(6,1,1,0.9);
  border: 1px solid rgba(192,57,43,0.5);
  border-radius: 6px; padding: 9px 20px;
  animation: bannerPulse 1s ease-in-out infinite alternate;
}
@keyframes bannerPulse {
  from { border-color: rgba(192,57,43,0.3); box-shadow: none; }
  to   { border-color: rgba(192,57,43,0.9); box-shadow: 0 0 20px rgba(192,57,43,0.3); }
}
.ai-box p {
  font-family: 'Cinzel Decorative', serif; font-size: 0.68rem;
  color: var(--ai-clr); letter-spacing: 0.12em; text-transform: uppercase; margin: 0;
}
.ai-mem-hint {
  font-size: 0.55rem; color: var(--ash); font-style: italic; margin: 0;
}
 
/* ── BOARD ── */
.board-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 100%;
  padding: 10px 0;
  margin-bottom: 5px;
}
.board {
  display: grid; 
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: clamp(8px, 2vw, 16px);
  width: min(90%, 480px); 
  margin: 0 auto;
}

@media (max-width: 768px) {
  .board {
    grid-template-columns: repeat(min(var(--cols, 4), 4), 1fr);
  }
}

@media (max-width: 480px) {
  .board {
    grid-template-columns: repeat(min(var(--cols, 4), 3), 1fr);
    gap: 8px;
  }
}
 
/* ── CARDS ── */
.card {
  aspect-ratio: 3/4;
  cursor: pointer; perspective: 1000px;
  position: relative;
  width: 100%;
  max-width: 110px;
  margin: 0 auto;
}
.card-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.23,1,0.32,1);
  border-radius: 8px;
}
.card.flipped .card-inner,
.card.matched .card-inner { transform: rotateY(180deg); }
 
.card-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; overflow: hidden;
}
 
.card-back {
  background: var(--card-back);
  border: 1px solid rgba(139,0,0,0.4);
  box-shadow: inset 0 0 25px rgba(0,0,0,0.9), 0 8px 20px rgba(0,0,0,0.6);
}
.card-back::before {
  content: ''; position: absolute; inset: 8px;
  border: 1px solid rgba(139,0,0,0.12); border-radius: 4px;
  background: 
    radial-gradient(circle at center, rgba(139,0,0,0.05) 0%, transparent 70%),
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(139,0,0,0.02) 10px, rgba(139,0,0,0.02) 20px);
}
.card-back-sym {
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  filter: drop-shadow(0 0 8px rgba(139,0,0,0.7));
  position: relative; z-index: 1;
}
.card-back-txt {
  font-family: 'Cinzel Decorative', serif; font-size: 0.36rem;
  letter-spacing: 0.2em; color: rgba(139,0,0,0.45);
  text-transform: uppercase; position: relative; z-index: 1;
}
 
.card-front {
  transform: rotateY(180deg);
  background: var(--card-front); padding: 6px;
  border: 2px solid rgba(139,0,0,0.3);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.9);
}
.card-emoji {
  font-size: clamp(1.5rem, 4.5vw, 2.5rem);
  filter: drop-shadow(0 0 5px rgba(0,0,0,0.9)); flex-shrink: 0;
}
.card-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(0.36rem, 1vw, 0.54rem);
  color: var(--bone); text-align: center; line-height: 1.2;
  opacity: 0.88; word-break: break-word; hyphens: auto;
}
.card-tagline {
  font-size: clamp(0.3rem, 0.8vw, 0.44rem);
  font-style: italic; color: var(--ash); text-align: center;
}
.card-reward {
  font-size: clamp(0.3rem, 0.7vw, 0.42rem);
  padding: 1px 4px; border-radius: 99px;
  border: 1px solid; text-align: center;
  font-family: 'Cinzel Decorative', serif;
}
.card-reward.heal  { border-color: rgba(46,204,113,0.5); color: var(--heal-clr); background: rgba(46,204,113,0.08); }
.card-reward.power { border-color: rgba(240,192,64,0.5); color: var(--gold);     background: rgba(240,192,64,0.08); }
.card-reward.curse { border-color: rgba(155,89,182,0.5); color: var(--poison-clr); background: rgba(155,89,182,0.08); }
 
/* Player matched → GOLD */
.card.matched .card-front {
  border-color: #a07800;
  animation: glowGold 2s ease-in-out infinite alternate;
}
@keyframes glowGold {
  from { border-color:#a07800; box-shadow:0 0 0 2px #a07800, 0 0 12px rgba(240,192,64,0.4), inset 0 0 14px rgba(240,192,64,0.15); }
  to   { border-color:#f0c040; box-shadow:0 0 0 3px #f0c040, 0 0 28px rgba(240,192,64,0.8), inset 0 0 22px rgba(240,192,64,0.3); }
}

/* AI matched → RED */
.card.matched.ai-matched .card-front,
.card.ai-matched.matched .card-front {
  border-color: #8b0000 !important;
  animation: glowRed 2s ease-in-out infinite alternate !important;
}
@keyframes glowRed {
  from { border-color:#8b0000; box-shadow:0 0 0 2px #8b0000, 0 0 12px rgba(192,57,43,0.4), inset 0 0 14px rgba(139,0,0,0.2); }
  to   { border-color:#c0392b; box-shadow:0 0 0 3px #c0392b, 0 0 28px rgba(192,57,43,0.75), inset 0 0 22px rgba(139,0,0,0.45); }
}
.card.wrong .card-inner {
  animation: cardShake 0.5s ease;
}
@keyframes cardShake {
  0%,100% { transform: rotateY(180deg) translateX(0); }
  20%     { transform: rotateY(180deg) translateX(-6px) rotate(-1.5deg); }
  40%     { transform: rotateY(180deg) translateX(6px) rotate(1.5deg); }
  60%     { transform: rotateY(180deg) translateX(-4px); }
  80%     { transform: rotateY(180deg) translateX(4px); }
}
.card.ai-reveal { cursor: default; }
@keyframes aiRevealPulse {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(2) sepia(1) hue-rotate(-20deg); }
}
.card.ai-reveal.flipped .card-front { animation: aiRevealPulse 0.5s ease; }
 
/* Card shuffle animations */
@keyframes shuffleOut {
  0%   { transform: rotateY(0deg) scale(1); opacity: 1; }
  100% { transform: rotateY(90deg) scale(0.82); opacity: 0; }
}
@keyframes shuffleIn {
  0%   { transform: rotateY(-90deg) scale(0.82); opacity: 0; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.card.shuffle-out .card-inner { animation: shuffleOut 0.25s ease-in forwards; }
.card.shuffle-in  .card-inner { animation: shuffleIn  0.25s ease-out forwards; }
 
/* ── LORE BAR ── */
.lore-bar {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(139,0,0,0.2); border-radius: 6px;
  padding: 10px 18px; text-align: center;
  font-style: italic; font-size: clamp(0.75rem, 2vw, 0.9rem);
  color: rgba(200,140,100,0.85); min-height: 46px;
  transition: opacity 0.3s; line-height: 1.5;
}
 
/* ── REWARD POPUP ── */
.reward-popup {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 600; pointer-events: none;
  background: rgba(0,0,0,0.95); border: 2px solid var(--gold);
  border-radius: 12px; padding: 20px 32px; text-align: center;
  box-shadow: 0 0 40px rgba(240,192,64,0.5);
  animation: rewardPopup 2.2s cubic-bezier(0.22,1,0.36,1) forwards;
}
@keyframes rewardPopup {
  0%   { transform: translate(-50%,-50%) scale(0) rotate(-10deg); opacity: 0; }
  15%  { transform: translate(-50%,-50%) scale(1.1) rotate(2deg); opacity: 1; }
  25%  { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
  75%  { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-55%) scale(0.9); opacity: 0; }
}
.reward-popup .rp-icon { font-size: 2.5rem; }
.reward-popup .rp-title {
  font-family: 'Cinzel Decorative', serif; font-size: 0.85rem;
  color: var(--gold); letter-spacing: 0.1em;
  text-transform: uppercase; margin: 6px 0 3px;
}
.reward-popup .rp-desc {
  font-style: italic; font-size: 0.8rem; color: var(--bone-dim);
}
 
/* ── FLOATING NUMBERS ── */
.float-num {
  position: fixed; font-family: 'Cinzel Decorative', serif;
  font-weight: 900; pointer-events: none; z-index: 700;
  animation: floatUp 1.1s ease forwards;
}
.float-num.dmg-player { font-size: 1.6rem; color: #ff4444; text-shadow: 0 0 10px rgba(255,68,68,0.8); }
.float-num.dmg-ai     { font-size: 1.6rem; color: #ff4040; text-shadow: 0 0 10px rgba(255,64,64,0.8); }
.float-num.crit       { font-size: 2rem;   color: var(--gold); text-shadow: 0 0 16px rgba(240,192,64,0.9); }
.float-num.heal       { font-size: 1.3rem; color: var(--heal-clr); text-shadow: 0 0 12px rgba(46,204,113,0.8); }
.float-num.power      { font-size: 1.1rem; color: #00d4ff; text-shadow: 0 0 10px rgba(0,212,255,0.7); }
@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  20%  { opacity: 1; transform: translateY(-15px) scale(1.2); }
  70%  { opacity: 1; transform: translateY(-60px) scale(1); }
  100% { opacity: 0; transform: translateY(-100px) scale(0.8); }
}
 
/* ── CONTROLS ── */
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
 
/* ── SCREEN EFFECTS ── */
.hit-flash {
  position: fixed; inset: 0; z-index: 400; pointer-events: none; opacity: 0;
}
.hit-flash.f-player { background: rgba(255,50,50,0.18); animation: flashFade 0.35s ease forwards; }
.hit-flash.f-ai     { background: rgba(192,57,43,0.22); animation: flashFade 0.35s ease forwards; }
.hit-flash.f-heal   { background: rgba(46,204,113,0.1); animation: flashFade 0.4s ease forwards; }
.hit-flash.f-power  { background: rgba(0,212,255,0.1);  animation: flashFade 0.4s ease forwards; }
@keyframes flashFade { 0% { opacity:0; } 30% { opacity:1; } 100% { opacity:0; } }
 
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-9px,4px); }
  30% { transform: translate(9px,-4px); }
  50% { transform: translate(-6px,3px); }
  70% { transform: translate(6px,-3px); }
  88% { transform: translate(-3px,1px); }
}
body.shaking { animation: shake 0.45s ease; }
 
/* Jump scare */
#jumpscare {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
}
#jumpscare.active {
  animation: scareFlash 0.45s ease forwards;
}
#scareInner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(0.3);
}
#jumpscare.active #scareInner {
  animation: scarePop 0.45s cubic-bezier(0.1, 1.5, 0.4, 1) forwards;
}
#scareSVG {
  width: 260px;
  height: 260px;
  filter: drop-shadow(0 0 40px rgba(200, 0, 0, 0.9)); 
}
#scareText {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.6rem;
  color: #ff2222;
  text-shadow: 0 0 20px rgba(255,0,0,0.8), 0 0 60px rgba(255,0,0,0.4);
  letter-spacing: 0.15em;
  text-align: center;
}
@keyframes scareFlash {
  0%   { opacity: 0; background: rgba(0,0,0,0); }
  10%  { opacity: 1; background: rgba(80,0,0,0.85); }
  70%  { opacity: 1; background: rgba(40,0,0,0.7); }
  100% { opacity: 0; background: rgba(0,0,0,0); }
}
@keyframes scarePop {
  0%   { transform: scale(0.3) rotate(-8deg); }
  50%  { transform: scale(1.15) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ════════════════════════════════════════════
   OVERLAYS — Win / Lose / Level Up
════════════════════════════════════════════ */
.full-overlay {
  display: none; position: fixed; inset: 0;
  background: radial-gradient(circle at center, rgba(15, 2, 4, 0.94) 0%, rgba(5, 1, 2, 0.98) 100%);
  z-index: 2500;
  align-items: center; justify-content: flex-start;
  flex-direction: column; gap: clamp(10px, 4vh, 24px);
  text-align: center; padding: 40px 24px 80px;
  backdrop-filter: blur(12px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.full-overlay.active { display: flex; }
 
.ov-emoji { font-size: 4rem; animation: ovFloat 3s ease-in-out infinite; }
@keyframes ovFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
 
.ov-title {
  font-family: 'Pirata One', cursive;
  font-size: clamp(2.5rem, 10vw, 4rem);
  color: var(--bone);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: 0 0 30px var(--blood-glow), 3px 3px 0 #000;
}
.ov-title.win  { text-shadow: 0 0 30px rgba(240,192,64,0.8), 0 0 60px rgba(240,192,64,0.4); }
.ov-title.lose { text-shadow: 0 0 30px rgba(192,57,43,1),    0 0 60px rgba(192,57,43,0.6); }
.ov-title.next { text-shadow: 0 0 30px rgba(79,195,247,0.8), 0 0 60px rgba(79,195,247,0.4); }
 
.ov-subtitle {
  font-size: 1rem; color: var(--bone-dim); font-style: italic; max-width: 380px; line-height: 1.6;
}
.ov-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  margin: 20px auto 0;
}
.ov-actions button {
  flex: 0 0 160px;
  width: 160px;
  height: 48px;
  padding: 0 10px !important;
  font-size: 0.68rem !important;
  font-family: 'Cinzel Decorative', serif;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 6px !important;
  margin: 0 !important;
  animation-delay: 0.4s !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
}
.ov-stats {
  display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin: 4px 0;
}
.ov-stat { text-align: center; }
.ov-stat-val {
  font-family: 'Cinzel Decorative', serif; font-size: 1.4rem;
  color: var(--blood-bright);
}
.ov-stat-val.gold { color: var(--gold); }
.ov-stat-label {
  font-size: 0.58rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ash);
}
 
/* XP Bar */
.xp-bar-wrap {
  width: 100%; max-width: 360px;
  height: 8px; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  box-shadow: 0 0 15px rgba(255,204,51,0.4);
  transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.xp-label {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.55rem; letter-spacing: 0.12em;
  color: var(--gold-dim); text-transform: uppercase;
}
 
/* Drops decoration */
.drops { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.drop  { position: absolute; top: -20px; opacity: 0; animation: drip linear infinite; }
@keyframes drip {
  0%   { transform: translate(0, -5vh); opacity: 0; }
  15%  { opacity: 0.8; }
  85%  { opacity: 0.8; }
  100% { transform: translate(calc(10px - 2vw), 110vh); opacity: 0; }
}
 
/* ════════════════════════════════════════════
   PAUSE / INVENTORY PANEL
════════════════════════════════════════════ */
.side-panel {
  display: none; position: fixed; top: 0; right: 0;
  width: min(280px, 85vw); height: 100vh;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-clr);
  box-shadow: -20px 0 50px rgba(0,0,0,0.8);
  z-index: 2000; flex-direction: column; gap: 10px;
  padding: 25px 18px; overflow-y: auto;
  transform: translateX(100%); transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.side-panel.open { display: flex; transform: translateX(0); }
.sp-title {
  font-family: 'Cinzel Decorative', serif; font-size: 1rem;
  color: var(--bone); letter-spacing: 0.12em;
  text-transform: uppercase; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-clr);
  text-align: center;
  margin-bottom: 5px;
}
.sp-section-label {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ash); margin-bottom: 4px;
}
.inventory-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.inv-item {
  background: rgba(0, 0, 0, 0.5); 
  border: 1px solid rgba(139, 0, 0, 0.2);
  border-radius: 10px; padding: 12px 6px; text-align: center; cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  position: relative;
  overflow: hidden;
}
.inv-item:hover:not(.empty) { 
  border-color: var(--gold); 
  background: rgba(139, 0, 0, 0.1); 
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(139, 0, 0, 0.3);
}
.inv-item::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.05), transparent);
  opacity: 0; transition: opacity 0.3s;
}
.inv-item:hover::before { opacity: 1; }

.inv-item .ii-emoji { font-size: 2.2rem; display: block; margin-bottom: 4px; }
.inv-item .ii-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.6rem; color: var(--bone-dim);
  letter-spacing: 0.08em; display: block; text-transform: uppercase;
}
.inv-item .ii-count {
  position: absolute; top: 6px; right: 8px;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.8rem; color: var(--gold);
  text-shadow: 0 0 5px #000;
}
.inv-item.empty { opacity: 0.2; cursor: default; filter: grayscale(1); }
 
.achievement-list { display: flex; flex-direction: column; gap: 5px; }
.ach-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.4); 
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.ach-item::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.02), transparent);
  transform: translateX(-100%); transition: transform 0.6s;
}
.ach-item:hover {
  background: rgba(139, 0, 0, 0.05);
  border-color: rgba(139, 0, 0, 0.3);
  transform: translateY(-2px);
}
.ach-item:hover::before { transform: translateX(100%); }

.ach-item.earned { 
  border-color: var(--gold-dim); 
  background: rgba(255, 204, 51, 0.03);
}
.ach-item.earned .ach-icon {
  filter: drop-shadow(0 0 5px var(--gold));
}
.ach-item.locked { opacity: 0.35; filter: grayscale(1); }

.ach-item .ach-icon { font-size: 1.8rem; flex-shrink: 0; }
.ach-item .ach-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ach-item .ach-name {
  font-family: 'Cinzel Decorative', serif; font-size: 0.75rem;
  color: var(--bone); letter-spacing: 0.05em; font-weight: bold;
}
.ach-item .ach-desc { font-size: 0.65rem; color: var(--ash); font-style: italic; }
.ach-item .ach-check { color: var(--gold); font-size: 0.8rem; margin-left: 5px; }
 
/* ════════════════════════════════════════════
   ANIMATIONS & KEYFRAMES (utilities)
════════════════════════════════════════════ */
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown  { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp    { from { opacity: 0; transform: translateY(20px);  } to { opacity: 1; transform: translateY(0); } }
@keyframes levelFlash  {
  0%,100% { background: transparent; }
  30%     { background: rgba(79,195,247,0.15); }
}
 
/* ════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════ */
@media (max-width: 680px) {
  #gameScreen { padding: 8px 8px 28px; gap: 7px; }
  .battle-hud { padding: 9px 10px; }
  .hud-strip  { gap: 5px; }
  .hud-pill   { padding: 5px 9px; }
  .lore-bar   { font-size: 0.72rem; padding: 7px 12px; }
  .controls   { gap: 5px; }
}
@media (max-width: 420px) {
  .battle-hud { gap: 6px; padding: 7px 7px; }
  .fighter-avatar { font-size: 1.4rem; }
  .hp-track { height: 9px; }
  .ov-emoji { font-size: 2.8rem; }
  .title-stats-bar { gap: 16px; padding: 8px 14px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  #gameScreen { gap: 4px; padding: 4px 8px 10px; }
  .stage-banner { display: none; }
  .lore-bar { min-height: 28px; font-size: 0.65rem; padding: 4px 10px; }
  .hud-strip { display: none; }
}

/* ════════════════════════════════════════════
   PWA & MOBILE DEVICE INTEGRATION
════════════════════════════════════════════ */

body {
  padding-top:    env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left:   env(safe-area-inset-left);
  padding-right:  env(safe-area-inset-right);
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

.card, .btn-primary, .btn-secondary, .stage-btn, .battle-hud, .inv-item {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (display-mode: standalone) {
  #titleScreen { padding-top: max(40px, env(safe-area-inset-top)); }
  #gameScreen  { padding-top: max(12px, env(safe-area-inset-top)); }
}

@media (orientation: landscape) {
  body {
    padding-left:  max(env(safe-area-inset-left),  10px);
    padding-right: max(env(safe-area-inset-right), 10px);
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card-back, .card-front, .battle-hud { border-width: 0.5px; }
}

@media (max-width: 480px) {
  .ts-item { transform: scale(0.9); }
  .title-stats-bar { gap: 12px; padding: 8px 12px; }
}

@keyframes floatPlayer {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes floatEnemy {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@media (min-width: 950px) {
  #gameScreen {
    max-width: 1300px;
  }
  .battle-hud {
    position: absolute;
    top: 250px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1300px;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 10;
  }
  .battle-hud .fighter {
    pointer-events: auto;
    background: transparent;
    border: none;
    padding: 12px;
    width: 270px;
    box-shadow: none;
  }
  .battle-hud .fighter.player {
    animation: floatPlayer 4s ease-in-out infinite;
  }
  .battle-hud .fighter.enemy {
    animation: floatEnemy 4.5s ease-in-out infinite;
  }
  .battle-hud .vs-col {
    display: none;
  }
}

/* ════════════════════════════════════════════
   MOBILE HAMBURGER MENU
════════════════════════════════════════════ */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  width: 44px;
  height: 44px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-clr);
  border-radius: 8px;
  z-index: 2001;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-menu-toggle:hover {
  border-color: var(--blood-bright);
  background: var(--glass-bright);
}

.mobile-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--bone);
  transition: all 0.3s ease;
  border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; transform: translateX(10px); }
.mobile-menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.action-footer {
  width: 100%;
  margin-top: 30px;
  animation: fadeInUp 1s ease 1.2s both;
}

.action-buttons-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .mobile-menu-toggle { display: flex; }
  
  .action-footer {
    display: none;
    position: fixed;
    top: 70px;
    right: 15px;
    width: 220px;
    background: var(--glass);
    backdrop-filter: blur(25px);
    border: 1px solid var(--border-clr);
    border-radius: 12px;
    padding: 15px;
    z-index: 2000;
    margin-top: 0;
    animation: none;
    box-shadow: 0 15px 40px rgba(0,0,0,0.9);
  }
  
  .action-footer.active {
    display: block;
    animation: fadeInDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  
  .action-buttons-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .footer-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 14px 18px;
    font-size: 0.7rem;
  }
}