@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0c0a09; --bg2: #1a1714; --bg3: #292420;
  --text: #e7dfd5; --text2: #b8ad9e; --text3: #8a7e6e;
  --accent: #e8a624; --accent2: #c48a10; --danger: #c4382a; --danger2: #a52a1e;
  --success: #3d8b3d; --success2: #2d6b2d; --info: #4a7fb5; --info2: #3566a0;
  --purple: #8b5fbf; --purple2: #7040a0;
  --common: #8a8070; --uncommon: #3d8b3d; --rare: #4a7fb5; --epic: #8b5fbf; --legendary: #e8a624;
  --radius: 4px; --radius-sm: 3px;
  --glow-amber: rgba(232,166,36,0.3);
  --glow-danger: rgba(196,56,42,0.3);
  --border: rgba(232,166,36,0.12);
  --border-dim: rgba(255,255,255,0.07);
  --font-main: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  /* Responsive font scaling based on viewport width */
  --font-xs: clamp(10px, 1.2vw, 13px);
  --font-sm: clamp(11px, 1.4vw, 14px);
  --font-base: clamp(13px, 1.6vw, 16px);
  --font-lg: clamp(15px, 1.8vw, 20px);
  --font-xl: clamp(18px, 2.2vw, 26px);
  --font-2xl: clamp(22px, 2.8vw, 32px);
}

html, body {
  height: 100%; width: 100%; overflow: hidden;
  font-family: var(--font-main);
  background: var(--bg); color: var(--text);
  font-size: var(--font-base);
  -webkit-tap-highlight-color: transparent; user-select: none;
  touch-action: manipulation;
}

/* Responsive zoom: scales entire UI proportionally to viewport width.
   Reference design width is 390px (iPhone 14 size).
   Set by JS on load and resize via --ui-zoom custom property. */

/* Subtle noise texture on body */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.04;
  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='1'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

#root { height: 100%; width: 100%; display: flex; flex-direction: column; position: relative; }

button {
  font-family: var(--font-main); font-size: inherit; border: none; cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600;
}
button:active { transform: scale(0.97); }

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text3); border-radius: 1px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

.screen { display:flex; flex-direction:column; height:100%; overflow:hidden; background:var(--bg); }
.scroll {
  flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:16px;
  padding-bottom: max(100px, calc(80px + env(safe-area-inset-bottom)));
  /* Pure CSS scroll shadows — covers hide the shadow when scrolled to top/bottom */
  background:
    linear-gradient(#0c0a09 33%, transparent) center top,
    linear-gradient(transparent, #0c0a09 66%) center bottom,
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.5), transparent) center top,
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.5), transparent) center bottom;
  background-size: 100% 44px, 100% 44px, 100% 16px, 100% 16px;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}

.card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border-dim);
  position: relative;
  transition: border-color 0.2s ease;
}
.card:hover {
  border-color: rgba(232,166,36,0.2);
}
/* Scratched corner accent */
.card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 20px; height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.4;
}
.card::after {
  content: ''; position: absolute; top: 0; left: 0;
  width: 1px; height: 20px;
  background: linear-gradient(180deg, var(--accent), transparent);
  opacity: 0.4;
}

.card-glow {
  box-shadow: 0 0 20px var(--glow-amber), inset 0 1px 0 rgba(232,166,36,0.15);
  border-color: rgba(232,166,36,0.25);
}

.btn {
  display:flex; align-items:center; justify-content:center; gap:8px;
  padding:14px 20px; border-radius:var(--radius); font-weight:700; font-size:var(--font-sm);
  width:100%; transition: transform 0.15s, filter 0.15s, box-shadow 0.15s; letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
  animation: btnBreathe 3s ease-in-out infinite;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
  filter: brightness(0.9);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.05s, filter 0.05s;
}
/* Gentle breathing glow for all buttons */
@keyframes btnBreathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.06); }
}

.btn-primary {
  background: linear-gradient(180deg, #e8a624 0%, #c48a10 100%);
  color: #0c0a09;
  border-color: rgba(232,166,36,0.5);
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
  animation: btnBreathe 3s ease-in-out infinite, btnPrimaryGlow 3s ease-in-out infinite;
}
@keyframes btnPrimaryGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(232,166,36,0.15), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 16px rgba(232,166,36,0.3), 0 0 30px rgba(232,166,36,0.1), 0 2px 4px rgba(0,0,0,0.3); }
}
.btn-primary:active { background: var(--accent2); }
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 0 20px rgba(232,166,36,0.4), 0 4px 12px rgba(0,0,0,0.3);
}
/* Shimmer sweep on primary buttons */
.btn-primary::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: btnShimmer 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btnShimmer {
  0%, 75%, 100% { left: -100%; opacity: 0; }
  10% { opacity: 1; }
  50% { left: 150%; opacity: 0; }
}

.btn-danger {
  background: linear-gradient(180deg, #c4382a 0%, #8b1a10 100%);
  color: #fdd;
  border-color: rgba(196,56,42,0.4);
  animation: btnBreathe 3s ease-in-out infinite, btnDangerGlow 3s ease-in-out infinite;
}
@keyframes btnDangerGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(196,56,42,0.1), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 12px rgba(196,56,42,0.25), 0 0 20px rgba(196,56,42,0.08), 0 2px 4px rgba(0,0,0,0.3); }
}
.btn-danger:active { background: var(--danger2); }
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 0 16px rgba(196,56,42,0.35), 0 4px 12px rgba(0,0,0,0.3);
}

.btn-success {
  background: linear-gradient(180deg, #3d8b3d 0%, #2d5f2d 100%);
  color: #dfe;
  border-color: rgba(61,139,61,0.4);
  animation: btnBreathe 3s ease-in-out infinite, btnSuccessGlow 3s ease-in-out infinite;
}
@keyframes btnSuccessGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(61,139,61,0.1), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 12px rgba(61,139,61,0.25), 0 0 20px rgba(61,139,61,0.08), 0 2px 4px rgba(0,0,0,0.3); }
}
.btn-success:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn-info {
  background: linear-gradient(180deg, #4a7fb5 0%, #2f5580 100%);
  color: #def;
  border-color: rgba(74,127,181,0.4);
  animation: btnBreathe 3s ease-in-out infinite, btnInfoGlow 3s ease-in-out infinite;
}
@keyframes btnInfoGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(74,127,181,0.1), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 12px rgba(74,127,181,0.25), 0 0 20px rgba(74,127,181,0.08), 0 2px 4px rgba(0,0,0,0.3); }
}
.btn-info:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn-ghost {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--border);
  animation: btnBreatheSubtle 4s ease-in-out infinite;
}
@keyframes btnBreatheSubtle {
  0%, 100% { border-color: var(--border); }
  50% { border-color: rgba(232,166,36,0.2); }
}
.btn-ghost:active:not(:disabled) { background: rgba(255,255,255,0.12); transform: translateY(1px) scale(0.97); }
.btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  border-color: rgba(232,166,36,0.35);
}
/* Clickable card buttons (location cards, character cards) */
button.card { transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s; }
button.card:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); border-color: rgba(232,166,36,0.25); }
button.card:active:not(:disabled) { transform: translateY(1px) scale(0.98); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn-sm { padding:10px 14px; font-size:var(--font-xs); }
.btn:disabled { opacity:0.4; pointer-events:none; filter: grayscale(0.7); animation: none; }
.btn:disabled::after { display: none; }

/* Available action buttons — warm border glow to clearly differentiate from disabled */
.action-btn-available {
  animation: actionAvailablePulse 2.5s ease-in-out infinite;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.action-btn-available:hover {
  background: rgba(232,166,36,0.2) !important;
  border-color: rgba(232,166,36,0.6) !important;
  box-shadow: 0 0 12px rgba(232,166,36,0.25) !important;
}
@keyframes actionAvailablePulse {
  0%, 100% { border-color: rgba(232,166,36,0.45); box-shadow: 0 0 6px rgba(232,166,36,0.1); }
  50% { border-color: rgba(232,166,36,0.65); box-shadow: 0 0 12px rgba(232,166,36,0.2); }
}

/* ===== Flashy button class for special actions (pack buy, confirm night, etc.) ===== */
.btn-flashy {
  animation: btnBreathe 3s ease-in-out infinite, btnFlashyPulse 2s ease-in-out infinite !important;
}
@keyframes btnFlashyPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(232,166,36,0.2), 0 0 24px rgba(232,166,36,0.1); }
  50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(232,166,36,0.4), 0 0 40px rgba(232,166,36,0.15), 0 0 60px rgba(232,166,36,0.05); }
}
.btn-flashy::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: btnFlashyShimmer 2.5s ease-in-out infinite !important;
  pointer-events: none;
}
@keyframes btnFlashyShimmer {
  0%, 60%, 100% { left: -100%; opacity: 0; }
  10% { opacity: 1; }
  40% { left: 200%; opacity: 0; }
}

/* Extra flashy for gacha/recruit pulls - rainbow border + particles */
.btn-gacha-pull {
  animation: btnBreathe 3s ease-in-out infinite, btnGachaPulse 1.8s ease-in-out infinite !important;
  border-width: 2px;
}
@keyframes btnGachaPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(168,85,247,0.3), 0 0 30px rgba(232,166,36,0.15); border-color: rgba(168,85,247,0.5); }
  25% { box-shadow: 0 0 20px rgba(232,166,36,0.4), 0 0 40px rgba(168,85,247,0.15); border-color: rgba(232,166,36,0.5); }
  50% { transform: scale(1.025); box-shadow: 0 0 25px rgba(34,197,94,0.3), 0 0 50px rgba(232,166,36,0.15); border-color: rgba(34,197,94,0.5); }
  75% { box-shadow: 0 0 20px rgba(59,130,246,0.3), 0 0 40px rgba(168,85,247,0.15); border-color: rgba(59,130,246,0.5); }
}
.btn-gacha-pull::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), rgba(168,85,247,0.15), transparent);
  animation: btnGachaShimmer 2s ease-in-out infinite !important;
  pointer-events: none;
}
@keyframes btnGachaShimmer {
  0%, 50%, 100% { left: -100%; opacity: 0; }
  10% { opacity: 1; }
  35% { left: 200%; opacity: 0; }
}

.flex { display:flex; } .flex-col { display:flex; flex-direction:column; } .flex-1 { flex:1; }
.gap-2 { gap:8px; } .gap-3 { gap:12px; } .gap-1 { gap:4px; }
.items-center { align-items:center; } .justify-between { justify-content:space-between; }
.justify-center { justify-content:center; }
.text-center { text-align:center; }
.text-xs { font-size:var(--font-xs); } .text-sm { font-size:var(--font-sm); } .text-lg { font-size:var(--font-lg); } .text-xl { font-size:var(--font-xl); } .text-2xl { font-size:var(--font-2xl); } .text-3xl { font-size:var(--font-2xl); }
.font-bold { font-weight:700; } .font-medium { font-weight:500; }
.text-dim { color:var(--text2); } .text-dim2 { color:var(--text3); }
.text-accent { color:var(--accent); } .text-danger { color:var(--danger); } .text-success { color:var(--success); } .text-info { color:var(--info); }
.mb-1 { margin-bottom:4px; } .mb-2 { margin-bottom:8px; } .mb-3 { margin-bottom:12px; } .mb-4 { margin-bottom:16px; }
.mt-2 { margin-top:8px; } .mt-3 { margin-top:12px; } .mt-4 { margin-top:16px; }
.p-2 { padding:8px; } .p-3 { padding:12px; }
.w-full { width:100%; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; }

.pill {
  display:inline-flex; padding:3px 10px; border-radius:2px; font-size:var(--font-xs); font-weight:700;
  letter-spacing: 0.5px; text-transform: uppercase; font-family: var(--font-mono);
}

.rarity-common { color:var(--common); } .rarity-uncommon { color:var(--uncommon); } .rarity-rare { color:var(--rare); } .rarity-epic { color:var(--purple); } .rarity-legendary { color:var(--legendary); }
.bg-rarity-common { background:rgba(138,128,112,0.15); color:var(--common); border: 1px solid rgba(138,128,112,0.2); }
.bg-rarity-uncommon { background:rgba(61,139,61,0.12); color:var(--uncommon); border: 1px solid rgba(61,139,61,0.2); }
.bg-rarity-rare { background:rgba(74,127,181,0.12); color:var(--rare); border: 1px solid rgba(74,127,181,0.2); }
.bg-rarity-epic { background:rgba(139,95,191,0.12); color:var(--purple); border: 1px solid rgba(139,95,191,0.2); }
.bg-rarity-legendary { background:rgba(232,166,36,0.12); color:var(--legendary); border: 1px solid rgba(232,166,36,0.2); }

.bar-bg { height:8px; background:rgba(255,255,255,0.06); border-radius:2px; overflow:hidden; border: 1px solid rgba(255,255,255,0.04); }
.bar-fill { height:100%; border-radius:1px; transition:width 0.3s; }
.bar-hp { background: linear-gradient(90deg, #2d6b2d, #4a9f4a); }
.bar-fatigue { background: linear-gradient(90deg, #e8a624, #c4382a); }
.bar-morale { background: linear-gradient(90deg, #4a7fb5, #8b5fbf); }

.divider { height:1px; background:var(--border); margin:12px 0; }

.badge {
  display:inline-flex; align-items:center; justify-content:center;
  min-width:20px; height:20px; padding:0 6px; border-radius:2px;
  font-size:11px; font-weight:700; font-family: var(--font-mono);
}

.nav-bar {
  position:fixed; bottom:0; left:0; right:0;
  display:flex; justify-content:space-around;
  background: linear-gradient(180deg, var(--bg2) 0%, #0f0d0a 100%);
  border-top: 1px solid var(--border);
  padding:6px 0; padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 100;
}
.nav-btn {
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding:6px 16px; border-radius: 3px; background:none; color:var(--text3);
  font-size:10px; font-weight:700; letter-spacing: 1px; text-transform: uppercase;
  transition: all 0.15s;
}
.nav-btn:hover {
  color: var(--text);
  background: rgba(232,166,36,0.06);
}
.nav-btn.active {
  color:var(--accent);
  background: rgba(232,166,36,0.08);
  border-bottom: 2px solid var(--accent);
}
.nav-icon { font-size:20px; }

.header {
  padding:12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--bg2) 0%, rgba(26,23,20,0.95) 100%);
  border-bottom: 1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
}

.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.8); z-index:200;
  display:flex; align-items:flex-end; justify-content:center;
  backdrop-filter: blur(4px);
}
.modal {
  background: linear-gradient(180deg, var(--bg3) 0%, var(--bg2) 30%);
  border-radius: var(--radius) var(--radius) 0 0;
  width:100%; max-height:85vh; overflow-y:auto; padding:20px;
  padding-bottom:max(20px, env(safe-area-inset-bottom));
  animation: slideUp 0.25s ease;
  border: 1px solid var(--border);
  border-bottom: none;
}
@keyframes slideUp { from { transform:translateY(100%); } to { transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeOut { from { opacity:1; } to { opacity:0; } }
@keyframes subtlePulse { 0%,100% { opacity:0.7; transform:scale(1); } 50% { opacity:1; transform:scale(1.03); } }
@keyframes popIn { from { opacity:0; transform:scale(0.85) translateY(12px); } to { opacity:1; transform:scale(1) translateY(0); } }
@keyframes slideDown { from { opacity:0; transform:translate(-50%,-12px); } to { opacity:1; transform:translate(-50%,0); } }
@keyframes toastSlideIn { from { opacity:0; transform:translateX(24px); } to { opacity:1; transform:translateX(0); } }
@keyframes titleExit {
  0% { opacity:1; transform:scale(1); filter:brightness(1) blur(0px); }
  40% { opacity:0.9; transform:scale(1.04); filter:brightness(1.2) blur(0px); }
  100% { opacity:0; transform:scale(1.12); filter:brightness(2) blur(6px); }
}
@keyframes titleExitFlash {
  0% { opacity:0; }
  30% { opacity:0.5; }
  100% { opacity:1; }
}
@keyframes diceRoll {
  0% { transform:rotate(0deg) scale(1); }
  25% { transform:rotate(90deg) scale(1.2); }
  50% { transform:rotate(180deg) scale(1); }
  75% { transform:rotate(270deg) scale(1.2); }
  100% { transform:rotate(360deg) scale(1); }
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
@keyframes flicker { 0%,100% { opacity:1; } 50% { opacity:0.85; } }
@keyframes portraitBreath {
  0%,100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.03) translateY(-1px); }
}
@keyframes scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}
@keyframes legendaryShimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}
@keyframes legendaryBorder {
  0%, 100% { border-color: rgba(232,166,36,0.5); }
  50% { border-color: rgba(232,166,36,0.9); }
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(1); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-200px) scale(0.5); opacity: 0; }
}

.dice-anim { animation: diceRoll 0.5s ease; }
.pulse { animation: pulse 1.5s infinite; }
.flicker { animation: flicker 3s infinite; }

.stat-row { display:flex; justify-content:space-between; align-items:center; padding:4px 0; }
.stat-label { color:var(--text2); font-size:var(--font-xs); font-weight: 500; letter-spacing: 0.3px; }
.stat-value { font-weight:700; font-size:var(--font-sm); font-family: var(--font-mono); }

.resource-bar {
  display:flex; align-items:center; gap:6px; padding:6px 10px;
  background: rgba(255,255,255,0.03); border-radius:var(--radius-sm);
  border: 1px solid var(--border-dim);
}
.resource-icon { font-size:16px; }
.resource-val { font-weight:700; font-size:var(--font-sm); font-family: var(--font-mono); color: var(--text); }
.resource-label { font-size:var(--font-xs); color:var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }

.log-entry {
  padding:6px 0; border-bottom:1px solid rgba(255,255,255,0.03);
  font-size:13px; line-height:1.4; font-family: var(--font-mono); font-size: 12px;
  color: var(--text2);
}
.log-entry:last-child { border-bottom:none; }

.emoji-lg { font-size:36px; }
.emoji-xl { font-size:48px; }

/* ============================================================ */
/* TITLE SCREEN STYLES                                           */
/* ============================================================ */

.title-screen {
  background: linear-gradient(180deg, #0c0a09 0%, #1a1510 40%, #0c0a09 100%);
  position: relative; overflow: hidden;
}
.title-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(232,166,36,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(196,56,42,0.04) 0%, transparent 40%);
}

.title-text {
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 38px;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 0 40px rgba(232,166,36,0.15);
}
.title-sub {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 8px;
  text-transform: uppercase;
}
.title-tagline {
  font-family: var(--font-mono);
  color: var(--text3);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.title-screen .btn { max-width: 100%; }

/* Portrait loading shimmer */
@keyframes portraitShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.portrait-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 30%,
    rgba(255,255,255,0.15) 50%,
    rgba(255,255,255,0.08) 70%,
    transparent 100%
  );
  animation: portraitShimmer 1.8s ease-in-out infinite;
}

/* Party grid: always 2-column for even splits (2x2 with 4 characters) */
.party-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Party card hover: smoky glow border with pulse */
@keyframes partyCardPulse {
  0%, 100% {
    box-shadow:
      0 0 8px rgba(232,166,36,0.3),
      0 0 20px rgba(232,166,36,0.15),
      0 0 40px rgba(180,140,60,0.08),
      inset 0 0 12px rgba(232,166,36,0.06);
    border-color: rgba(232,166,36,0.5);
  }
  50% {
    box-shadow:
      0 0 12px rgba(232,166,36,0.45),
      0 0 28px rgba(232,166,36,0.22),
      0 0 50px rgba(180,140,60,0.12),
      inset 0 0 16px rgba(232,166,36,0.1);
    border-color: rgba(232,166,36,0.7);
  }
}
.party-grid > div > button.card {
  transition: border-color 0.25s ease, box-shadow 0.3s ease, transform 0.15s ease;
}
.party-grid > div > button.card:hover:not(:disabled) {
  transform: translateY(-2px);
  animation: partyCardPulse 1.6s ease-in-out infinite;
}

/* Party card dismiss / bench action button hover effects */
.party-dismiss-btn { transition: opacity 0.15s, transform 0.15s, box-shadow 0.15s; }
.party-dismiss-btn:hover { opacity: 1 !important; transform: scale(1.15); box-shadow: 0 0 8px rgba(196,56,42,0.5); }
.bench-action-btn { transition: opacity 0.15s, transform 0.15s; }
.bench-action-btn:hover { opacity: 1 !important; transform: scale(1.1); }

/* Collection / party grid cards as buttons */
.collection-grid > button.card,
.party-grid > button.card,
.char-select-grid > button.card,
.location-grid > button.card,
.location-grid > button.location-card {
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.location-grid > button.location-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(232,166,36,0.15);
}

/* ============================================================ */
/* COMBAT-SPECIFIC STYLES                                        */
/* ============================================================ */

.combat-enemy {
  min-width: 80px; text-align: center; padding: 8px;
  background: var(--bg3); border-radius: var(--radius);
  border: 1px solid rgba(196,56,42,0.15);
}
.combat-enemy-dead { opacity: 0.25; filter: grayscale(0.6); }

.combat-ally {
  min-width: 90px; text-align: center; padding: 8px;
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border-dim);
}
.combat-ally-active { border: 2px solid var(--accent); box-shadow: 0 0 10px var(--glow-amber); }

.combat-actions {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.combat-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; font-size: 11px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  transition: all 0.15s;
}
.combat-action-btn:active { background: rgba(232,166,36,0.1); border-color: var(--accent); }
.combat-action-btn:disabled { opacity: 0.25; filter: grayscale(0.6); }
.combat-action-btn.selected { background: rgba(232,166,36,0.15); border-color: var(--accent); box-shadow: 0 0 8px var(--glow-amber); }
.combat-action-btn:hover:not(:disabled) {
  background: rgba(232,166,36,0.08);
  border-color: rgba(232,166,36,0.3);
  transform: translateY(-1px);
}

/* Target selection buttons */
.target-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; font-size: 11px; min-width: 70px;
  background: rgba(196,56,42,0.08); border: 1px solid rgba(196,56,42,0.2);
  border-radius: var(--radius); color: var(--text); cursor: pointer;
  transition: all 0.15s; text-transform: none; letter-spacing: normal; font-weight: normal;
}
.target-btn:active, .target-btn.selected { background: rgba(196,56,42,0.2); border-color: var(--danger); }
.target-btn.ally { background: rgba(61,139,61,0.08); border-color: rgba(61,139,61,0.2); }
.target-btn.ally:active, .target-btn.ally.selected { background: rgba(61,139,61,0.2); border-color: var(--success); }

/* Status chips */
.status-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 1px 6px; border-radius: 2px; font-size: 9px;
  font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.5px;
}

/* Dice roll display */
.dice-display {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; background: rgba(232,166,36,0.06);
  border: 1px solid rgba(232,166,36,0.15); border-radius: var(--radius);
  font-family: var(--font-mono); font-weight: 700;
}
.dice-value {
  font-size: 28px; color: var(--accent);
  text-shadow: 0 0 12px var(--glow-amber);
}

/* Item bar */
.item-bar {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0;
}
.item-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 8px; min-width: 56px;
  background: rgba(139,95,191,0.06); border: 1px solid rgba(139,95,191,0.2);
  border-radius: var(--radius); color: var(--text); cursor: pointer;
  font-size: 10px; text-transform: none; letter-spacing: normal; font-weight: 600;
  transition: all 0.15s;
}
.item-btn:active { background: rgba(139,95,191,0.15); border-color: var(--purple); }
.item-btn:disabled { opacity: 0.25; filter: grayscale(0.6); pointer-events: none; }

/* Noise meter */
.noise-meter {
  position: relative; height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: visible;
}
.noise-fill {
  height: 100%; border-radius: 3px; transition: width 0.3s;
  background: linear-gradient(90deg, var(--success), var(--accent), var(--danger));
}
.noise-threshold {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--danger); border-radius: 1px;
}

/* Active turn glow */
@keyframes turnGlow {
  0%, 100% { box-shadow: 0 0 8px var(--glow-amber); }
  50% { box-shadow: 0 0 16px var(--glow-amber), 0 0 24px rgba(232,166,36,0.15); }
}
.combat-ally-active { animation: turnGlow 2s ease-in-out infinite; }

/* ============================================================ */
/* GACHA STYLES                                                  */
/* ============================================================ */

.gacha-reveal {
  animation: fadeIn 0.5s ease;
}
.gacha-card {
  border: 1px solid;
  position: relative;
  overflow: visible;
}
.gacha-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%);
}

/* Cinematic reveal animations */
@keyframes revealFlashIn {
  0% { opacity: 0; transform: scale(3); }
  40% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes revealSlideUp {
  0% { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes revealStatPop {
  0% { opacity: 0; transform: scale(0.3) translateY(20px); }
  60% { transform: scale(1.15) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes revealNameSlam {
  0% { opacity: 0; transform: scale(1.4); letter-spacing: 8px; }
  60% { opacity: 1; transform: scale(0.98); letter-spacing: 0px; }
  100% { transform: scale(1); }
}
@keyframes revealRarityBurst {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes revealShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px) rotate(-1deg); }
  20% { transform: translateX(5px) rotate(1deg); }
  30% { transform: translateX(-4px); }
  40% { transform: translateX(3px); }
  50% { transform: translateX(-2px); }
  60% { transform: translateX(1px); }
}
@keyframes revealScanline {
  0% { top: -10%; opacity: 0.6; }
  100% { top: 110%; opacity: 0; }
}
@keyframes revealSparkRing {
  0% { transform: scale(0.2); opacity: 1; border-width: 4px; }
  100% { transform: scale(3); opacity: 0; border-width: 0px; }
}
@keyframes revealGlowPulse {
  0%, 100% { box-shadow: 0 0 20px currentColor; }
  50% { box-shadow: 0 0 60px currentColor, 0 0 100px currentColor; }
}
@keyframes revealTypewriter {
  from { width: 0; }
  to { width: 100%; }
}
@keyframes revealEmberFloat {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.8; }
  50% { opacity: 1; }
  100% { transform: translateY(-300px) rotate(720deg); opacity: 0; }
}

/* Event toast animation */
@keyframes toastFadeIn {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Continuous smoke/steam effects for epic+ cards */
@keyframes smokeRiseLeft {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: 0.35; }
  50% { transform: translate(-20px, -60px) scale(1.8); opacity: 0.2; }
  100% { transform: translate(-35px, -130px) scale(2.5); opacity: 0; }
}
@keyframes smokeRiseRight {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: 0.35; }
  50% { transform: translate(20px, -60px) scale(1.8); opacity: 0.2; }
  100% { transform: translate(35px, -130px) scale(2.5); opacity: 0; }
}
@keyframes smokeRiseCenter {
  0% { transform: translate(0, 0) scale(0.8); opacity: 0; }
  20% { opacity: 0.3; }
  60% { transform: translate(0, -80px) scale(2.0); opacity: 0.15; }
  100% { transform: translate(0, -160px) scale(3.0); opacity: 0; }
}
@keyframes steamWisp {
  0% { transform: translateY(0) scaleX(1); opacity: 0; }
  10% { opacity: 0.4; }
  40% { transform: translateY(-40px) scaleX(1.5); opacity: 0.25; }
  100% { transform: translateY(-100px) scaleX(2.0); opacity: 0; }
}
@keyframes packSmokeBlast {
  0% { transform: scale(0.5); opacity: 0; }
  15% { opacity: 0.6; }
  40% { transform: scale(2.0); opacity: 0.3; }
  100% { transform: scale(4.0); opacity: 0; }
}
@keyframes cardTrailGlow {
  0% { opacity: 0; height: 0; }
  20% { opacity: 0.5; height: 40%; }
  50% { opacity: 0.3; height: 80%; }
  100% { opacity: 0; height: 120%; }
}

/* Pack opening animations */
@keyframes packShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}
@keyframes packFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes packFloat {
  0%   { transform: translateY(0) rotateY(0deg) rotate(0deg); }
  25%  { transform: translateY(-4px) rotateY(18deg) rotate(0.3deg); }
  50%  { transform: translateY(-6px) rotateY(0deg) rotate(0.5deg); }
  75%  { transform: translateY(-4px) rotateY(-18deg) rotate(0.3deg); }
  100% { transform: translateY(0) rotateY(0deg) rotate(0deg); }
}
@keyframes packFlipFront {
  0% { transform: scaleX(1); opacity: 1; }
  45% { transform: scaleX(0.03); opacity: 1; }
  50% { transform: scaleX(0); opacity: 0; }
  100% { transform: scaleX(0); opacity: 0; }
}
@keyframes packFlipBack {
  0% { transform: scaleX(0); opacity: 0; }
  50% { transform: scaleX(0); opacity: 0; }
  55% { transform: scaleX(0.03); opacity: 1; }
  100% { transform: scaleX(1); opacity: 1; }
}
@keyframes tearTopOff {
  /* Top strip rips upward and tumbles away -- longer fade */
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  20% { transform: translateY(-10px) rotate(-1deg); opacity: 1; }
  50% { transform: translateY(-35px) rotate(-4deg); opacity: 0.8; }
  100% { transform: translateY(-80px) rotate(-12deg); opacity: 0; }
}
@keyframes cardAppear {
  /* Card hidden during flip, fades in right after flip completes */
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes cardFlyUp {
  /* Card: peek 1/3, shake, then fly completely offscreen */
  0% { transform: translateY(0); }
  18% { transform: translateY(-33%); }
  /* Shake while peeking */
  22% { transform: translateY(-33%) translateX(2px); }
  24% { transform: translateY(-33%) translateX(-2px); }
  26% { transform: translateY(-34%) translateX(1.5px); }
  28% { transform: translateY(-33%) translateX(-1.5px); }
  30% { transform: translateY(-34%) translateX(2px); }
  32% { transform: translateY(-33%) translateX(-1px); }
  34% { transform: translateY(-34%) translateX(1px); }
  36% { transform: translateY(-33%); }
  /* Fly offscreen — accelerate upward and out of view */
  75% { transform: translateY(-350%); }
  100% { transform: translateY(-350%); }
}
@keyframes packSlideDown {
  /* Pack wrapper: slides fully below card at full opacity, THEN fades */
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(95%) scale(0.9); opacity: 1; }
  80% { transform: translateY(115%) scale(0.82); opacity: 0.6; }
  100% { transform: translateY(135%) scale(0.75); opacity: 0; }
}
@keyframes sparkleFloat {
  0% { opacity: 0; transform: translate(0, 0) scale(0); }
  20% { opacity: 1; transform: translate(var(--fx), var(--fy1)) scale(1); }
  80% { opacity: 0.8; transform: translate(var(--fx2), var(--fy2)) scale(0.7); }
  100% { opacity: 0; transform: translate(var(--fx3), var(--fy3)) scale(0); }
}
@keyframes tearDebris {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx, 5px), var(--dy, -30px)) rotate(var(--dr, 45deg)); }
}
@keyframes buildGlow {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: var(--glow-peak, 0.5); transform: scale(1); }
  100% { opacity: var(--glow-peak, 0.5); transform: scale(1.2); }
}
@keyframes lensFlare {
  0% { opacity: 0; transform: scale(0.3); }
  40% { opacity: 1; transform: scale(1.1); }
  70% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0.95; transform: scale(1.5); }
}
@keyframes cardGlowPulse {
  0%, 100% { box-shadow: 0 0 15px var(--glow-color, rgba(255,255,255,0.3)), 0 0 30px var(--glow-color, rgba(255,255,255,0.1)); }
  50% { box-shadow: 0 0 25px var(--glow-color, rgba(255,255,255,0.5)), 0 0 50px var(--glow-color, rgba(255,255,255,0.2)); }
}
@keyframes cardPulseOutline {
  0%, 100% {
    box-shadow: 0 0 4px var(--rare-col, #e8a624), 0 0 8px var(--rare-col, #e8a624), inset 0 0 2px var(--rare-col-dim, rgba(232,166,36,0.2));
    border-color: var(--rare-col, #e8a624);
  }
  50% {
    box-shadow: 0 0 10px var(--rare-col, #e8a624), 0 0 22px var(--rare-col, #e8a624), 0 0 40px var(--rare-col-dim, rgba(232,166,36,0.3)), inset 0 0 6px var(--rare-col-dim, rgba(232,166,36,0.3));
    border-color: var(--rare-col-bright, #ffd700);
  }
}
@keyframes cardTrailParticle {
  /* Particles trail behind card as it flies offscreen — drift outward and down */
  0% { opacity: 1; transform: translate(var(--tx, 0), 0) scale(1); }
  30% { opacity: 0.9; transform: translate(var(--tx, 0), var(--ty1, 10px)) scale(1.1); }
  60% { opacity: 0.6; transform: translate(var(--tx2, 0), var(--ty1, 10px)) scale(0.7); }
  100% { opacity: 0; transform: translate(var(--tx2, 0), var(--ty2, 40px)) scale(0); }
}
@keyframes cardTrailSparkle {
  /* Larger sparkle particles that burst outward with more drama */
  0% { opacity: 1; transform: translate(0, 0) scale(0.5) rotate(0deg); }
  20% { opacity: 1; transform: translate(var(--sx1, 10px), var(--sy1, -5px)) scale(1.2) rotate(45deg); }
  50% { opacity: 0.7; transform: translate(var(--sx2, 20px), var(--sy2, 15px)) scale(0.8) rotate(120deg); }
  100% { opacity: 0; transform: translate(var(--sx3, 30px), var(--sy3, 40px)) scale(0) rotate(200deg); }
}
@keyframes packTearBurst {
  0% { transform: translate(-50%,-50%) scale(0); opacity: 1; }
  30% { transform: translate(-50%,-50%) scale(1.5); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(4); opacity: 0; }
}
@keyframes packTearBurst2 {
  0% { transform: translate(-50%,-50%) scale(0.5); opacity: 0.8; }
  50% { transform: translate(-50%,-50%) scale(2); opacity: 0.6; }
  100% { transform: translate(-50%,-50%) scale(5); opacity: 0; }
}
@keyframes packTearSpark {
  0% { opacity: 0; filter: brightness(2.5) blur(0px); transform: translate(0,0) scale(1); }
  10% { opacity: 1; filter: brightness(2.5) blur(0px); transform: translate(0,0) scale(1.2); }
  40% { opacity: 0.8; filter: brightness(1.5) blur(0.5px); }
  100% { opacity: 0; filter: brightness(0.2) blur(3px); transform: translate(var(--spark-dx, 0px), var(--spark-dy, 10px)) scale(0.3); }
}
/* Secondary ember animation for smaller trailing particles */
@keyframes packTearEmber {
  0% { opacity: 0; transform: translate(0,0) scale(0.5); }
  20% { opacity: 0.7; transform: translate(var(--ember-dx, 5px), var(--ember-dy, -5px)) scale(1); }
  60% { opacity: 0.4; }
  100% { opacity: 0; transform: translate(var(--ember-dx2, 10px), var(--ember-dy2, 15px)) scale(0.1); }
}
@keyframes packFlameFlicker {
  0% { opacity: 0.5; transform: translateX(-50%) translateY(-50%) scaleY(0.8) scaleX(0.9); filter: blur(3px) brightness(1.2); }
  100% { opacity: 0.9; transform: translateX(-50%) translateY(-60%) scaleY(1.2) scaleX(1.1); filter: blur(2px) brightness(1.5); }
}
@keyframes packTearShake {
  0%, 100% { transform: translate(0, 0); }
  8% { transform: translate(-5px, 3px); }
  16% { transform: translate(6px, -4px); }
  24% { transform: translate(-4px, 5px); }
  32% { transform: translate(5px, -2px); }
  40% { transform: translate(-2px, 4px); }
  48% { transform: translate(4px, -5px); }
  56% { transform: translate(-5px, 2px); }
  64% { transform: translate(3px, -3px); }
  72% { transform: translate(-3px, 4px); }
  80% { transform: translate(2px, -2px); }
  88% { transform: translate(-1px, 1px); }
}
@keyframes packTearFlash {
  0% { opacity: 0; transform: scale(0.8); }
  5% { opacity: 1; transform: scale(1.1); }
  15% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.3); }
}
@keyframes packTearRing {
  0% { transform: translate(-50%,-50%) scale(0); opacity: 1; border-width: 5px; }
  30% { opacity: 0.8; border-width: 3px; }
  100% { transform: translate(-50%,-50%) scale(3.5); opacity: 0; border-width: 0.5px; }
}
/* Energy crackle along the tear seam */
@keyframes packTearCrackle {
  0% { opacity: 0; clip-path: inset(0 48% 0 48%); }
  8% { opacity: 1; clip-path: inset(0 30% 0 30%); }
  20% { opacity: 0.7; clip-path: inset(0 10% 0 10%); }
  100% { opacity: 0; clip-path: inset(0 0% 0 0%); }
}
@keyframes packCardFanIn {
  0% { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes packTapPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes packGlowEdge {
  0%, 100% { box-shadow: 0 0 15px rgba(255,255,255,0.1); }
  50% { box-shadow: 0 0 30px rgba(255,255,255,0.25), 0 0 60px rgba(255,255,255,0.1); }
}
@keyframes packTapFade {
  0%, 100% { opacity: 0.3; letter-spacing: 2px; }
  50% { opacity: 0.7; letter-spacing: 4px; }
}
@keyframes statDropIn {
  0% { opacity: 0; transform: translateY(-15px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
/* Nav badge pulse for free rolls */
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
/* Fanfare animations for card reveals */
@keyframes fanfareStarBurst {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { opacity: 1; }
  100% { transform: scale(2.5) rotate(180deg); opacity: 0; }
}
@keyframes fanfareConfetti {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(200px) rotate(720deg); opacity: 0; }
}
@keyframes fanfareRaysSpin {
  0% { transform: translate(-50%,-50%) rotate(0deg); }
  100% { transform: translate(-50%,-50%) rotate(360deg); }
}
@keyframes fanfareLightPillar {
  0% { opacity: 0; transform: scaleY(0); }
  30% { opacity: 1; transform: scaleY(1.2); }
  100% { opacity: 0; transform: scaleY(1); }
}

/* Lens flare burst -- fades in then out like a burst of light */
@keyframes lensFlareInOut {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.3); }
  25% { opacity: 1; transform: translate(-50%,-50%) scale(1.2); }
  50% { opacity: 0.9; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.4); }
}
@keyframes lensFlareRay {
  0% { opacity: 0; transform: translate(-50%,-50%) scaleX(0.2); }
  20% { opacity: 0.9; transform: translate(-50%,-50%) scaleX(1.3); }
  50% { opacity: 0.7; transform: translate(-50%,-50%) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scaleX(1.5); }
}
@keyframes lensFlareHexagon {
  0% { opacity: 0; transform: translate(0,0) scale(0.5); }
  30% { opacity: 0.6; transform: translate(var(--hex-dx), var(--hex-dy)) scale(1); }
  60% { opacity: 0.3; transform: translate(calc(var(--hex-dx) * 1.3), calc(var(--hex-dy) * 1.3)) scale(0.8); }
  100% { opacity: 0; transform: translate(calc(var(--hex-dx) * 1.5), calc(var(--hex-dy) * 1.5)) scale(0.4); }
}
@keyframes lensParticleBurst {
  0% { opacity: 0; transform: translate(0,0) scale(1); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}
/* Dismiss button pulse -- matches subtlePulse centering (no translateY) */
@keyframes dismissFloat {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.03); opacity: 1; }
}

/* ============================================================ */
/* RESPONSIVE DESKTOP LAYOUT                                     */
/* ============================================================ */

/* ============================================================ */
/* COMBAT MISSION RESPONSIVE STYLES                              */
/* ============================================================ */

/* Party rail: horizontal scroll on small screens */
.combat-party-rail {
  display: flex; gap: 8px; overflow-x: auto; flex-shrink: 0;
  padding: 8px 10px; background: var(--bg);
  border-bottom: 1px solid var(--border-dim);
  scrollbar-width: none;
}
.combat-party-rail::-webkit-scrollbar { display: none; }

.combat-party-card {
  flex: 1 0 auto; min-width: 120px; padding: 8px 12px;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  transition: all 0.15s; border: 1px solid var(--border-dim);
  background: rgba(255,255,255,0.02);
}
.combat-party-card.selected {
  background: rgba(232,166,36,0.12);
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 8px rgba(232,166,36,0.15);
}

/* Action dock: ensure 44px+ tap targets on mobile */
.combat-action-dock .mode-tab {
  min-height: 36px; padding: 6px 4px; font-size: 10px;
}
.combat-action-dock .action-btn {
  min-height: 44px; padding: 10px 12px;
}

/* Zombie toasts: responsive positioning */
.zombie-toast-container {
  position: fixed; z-index: 190; display: flex;
  flex-direction: column; gap: 6; pointer-events: none;
  right: 12px; top: 100px; max-width: 260px;
}

/* Zombie banner: responsive */
.zombie-banner {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 200; padding: 8px 20px; border-radius: 8px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: #fff; letter-spacing: 0.04em;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideDown 0.3s ease;
  pointer-events: none; white-space: nowrap;
  max-width: calc(100vw - 32px);
}

/* Combat center scrollable area */
.combat-center {
  flex: 1; overflow: hidden; min-height: 0;
}

/* Desktop combat layout: side-by-side map + room panel */
.combat-main-layout {
  display: flex; flex-direction: column;
  height: 100%; overflow-y: auto;
}

/* ---- SMALL SCREENS (<=480px) ---- */
@media (max-width: 480px) {
  .combat-party-card { min-width: 72px; padding: 5px 8px; gap: 6px; }
  .combat-party-card .callsign { font-size: 9px; }
  .combat-party-card .role-icon { font-size: 14px; }
  .combat-party-card .ap-label { font-size: 8px; }

  /* Zombie toasts: narrower, left-aligned to avoid overflow */
  .zombie-toast-container { right: 8px; max-width: 200px; top: 56px; }
  .zombie-toast-container .toast-text { font-size: 10px; }

  /* Zombie banner: smaller on phones */
  .zombie-banner { font-size: 11px; padding: 6px 14px; top: 48px; }

  /* Room info panel: tighter on mobile */
  .combat-room-info { padding: 0 10px 4px; }
  .combat-room-info .room-name { font-size: 12px; }
  .combat-room-info .room-flavor { font-size: 9px; }

  /* Threat cards: tighter */
  .combat-threat-card { min-width: 80px; padding: 5px 8px; }
  .combat-threat-card .threat-name { font-size: 10px; }

  /* Action dock buttons: enforce 44px minimum */
  .combat-action-dock .action-btn {
    min-height: 46px; padding: 12px 10px; font-size: 12px;
  }
  .combat-action-dock .end-turn-btn {
    min-height: 44px; padding: 10px 12px;
  }

  /* Searchable items: tighter */
  .combat-searchable { padding: 6px 8px; }

  /* Map container: give it more space on small screens */
  .combat-map-container { padding: 6px 8px; }
}

/* ---- MEDIUM SCREENS (481px - 767px) ---- */
@media (min-width: 481px) and (max-width: 767px) {
  .combat-party-card { min-width: 90px; }
  .zombie-toast-container { max-width: 280px; }
}

/* ---- TABLET+ SCREENS (768px+) — combat side-by-side ---- */
@media (min-width: 768px) {
  .combat-main-layout {
    flex-direction: row; gap: 0; overflow: hidden;
  }
  .combat-main-layout .combat-map-col {
    flex: 1 1 55%; min-width: 0; overflow-y: auto;
    border-right: 1px solid var(--border-dim);
    padding-bottom: 12px;
  }
  .combat-main-layout .combat-detail-col {
    flex: 0 0 40%; max-width: 380px; overflow-y: auto;
    padding-top: 10px;
  }
  .combat-party-rail { justify-content: center; gap: 10px; padding: 10px 14px; }
  .combat-party-card { min-width: 160px; max-width: 240px; padding: 10px 14px; }
  .combat-party-card .callsign { font-size: 13px; }
  .combat-party-card .ap-badge { font-size: 11px; }
  .zombie-toast-container { right: 400px; }
  /* Scale up room panel text */
  .combat-room-info .room-name { font-size: 15px; }
  .combat-room-info .room-flavor { font-size: 11px; }
}

/* ---- LARGE SCREENS (1024px+) ---- */
@media (min-width: 1024px) {
  .combat-main-layout .combat-detail-col {
    flex: 0 0 400px; max-width: 440px;
  }
  .combat-party-rail { gap: 12px; padding: 12px 18px; }
  .combat-party-card { min-width: 180px; max-width: 280px; padding: 12px 16px; gap: 12px; }
  .combat-party-card .callsign { font-size: 14px; }
  .combat-party-card .ap-badge { font-size: 12px; }
  .zombie-toast-container { right: 460px; }
  /* Scale up room panel */
  .combat-room-info .room-name { font-size: 16px; }
  .combat-room-info .room-flavor { font-size: 12px; }
  .combat-threat-card .threat-name { font-size: 13px; }
}

/* ---- XL SCREENS (1440px+) ---- */
@media (min-width: 1440px) {
  .combat-party-card { min-width: 200px; max-width: 320px; padding: 14px 18px; }
  .combat-party-card .callsign { font-size: 15px; }
  .combat-main-layout .combat-detail-col {
    flex: 0 0 460px; max-width: 500px;
  }
}

/* ============================================================ */
/* TOOLTIP STYLES                                                */
/* ============================================================ */

.info-tooltip {
  font-family: var(--font-main);
}

/* Prevent tooltip overflow on small screens */
@media (max-width: 400px) {
  .info-tooltip {
    min-width: 150px !important;
    max-width: 200px !important;
    font-size: 11px !important;
  }
}

/* Detail screen layout — mobile-first (stacked) */
.detail-layout { display: flex; flex-direction: column; gap: 12px; }
.detail-viewer { }
.detail-info-grid { display: flex; flex-direction: column; gap: 8px; }
.detail-info-grid > .card { display: flex; flex-direction: column; }

/* Watch screen layout */
.watch-layout { display: flex; flex-direction: column; }
.watch-sidebar { }
.watch-roster { }
.watch-grid { display: flex; flex-direction: column; gap: 8px; }

@media (min-width: 768px) {
  /* #root stays full-width so backgrounds fill viewport.
     Content is constrained via scroll/header max-width instead. */
  #root { position: relative; }

  .scroll { padding: 20px 24px; max-width: 900px; margin: 0 auto; width: 100%; }
  .header { padding: 14px 24px; max-width: 900px; margin: 0 auto; width: 100%; }

  .modal { max-width: 500px; margin: 0 auto; border-radius: var(--radius); }

  .nav-bar {
    max-width: 900px; left: 50%; transform: translateX(-50%);
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .party-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .collection-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .location-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .char-select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .ops-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ops-actions-grid .btn { max-width: 100%; }

  .card { padding: 16px; }
  .btn { max-width: 400px; margin-left: auto; margin-right: auto; }
  .btn.w-full { max-width: 100%; }
  /* Don't auto-center buttons inside flex rows (e.g. shelter upgrades) */
  .flex > .btn, .flex > .btn-sm { margin-left: 0; margin-right: 0; max-width: none; }
  .flex-col > .btn { max-width: 400px; margin-left: auto; margin-right: auto; }

  .detail-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
  .detail-viewer { position: sticky; top: 0; }
  .detail-info-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: auto; gap: 8px; align-items: stretch; }
  .detail-info-grid > .card { display: flex; flex-direction: column; min-height: 0; }

  .resource-bar { padding: 8px 14px; }
  .resource-val { font-size: 16px; }

  /* Watch screen: side-by-side on tablet+ */
  .watch-layout { flex-direction: row; gap: 20px; align-items: flex-start; }
  .watch-sidebar { flex: 0 0 260px; position: sticky; top: 10px; }
  .watch-roster { flex: 1; min-width: 0; }
  .watch-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .watch-sidebar .btn { max-width: 100%; }
}

@media (min-width: 1024px) {
  html { font-size: 16px; }
  .scroll, .header { max-width: 1080px; }
  .party-grid { grid-template-columns: 1fr 1fr; }
  .collection-grid { grid-template-columns: 1fr 1fr 1fr; }
  .location-grid { grid-template-columns: 1fr 1fr; }
  .char-select-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .watch-sidebar { flex: 0 0 300px; }
  .watch-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   DICE ROLL OVERLAY ANIMATIONS
   ============================================================ */
@keyframes diceOverlaySpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(15deg) scale(1.05); }
  100% { transform: rotate(-15deg) scale(1); }
}
@keyframes diceOverlayReveal {
  0% { transform: scale(0.5); opacity: 0.3; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes diceTextReveal {
  0% { transform: translateY(20px) scale(0.7); opacity: 0; }
  60% { transform: translateY(-4px) scale(1.05); opacity: 1; }
  100% { transform: translateY(0) scale(1); }
}
@keyframes diceParticleFly {
  0% { transform: translate(0, 0) scale(1); opacity: 0.9; }
  100% { transform: translate(var(--px), var(--py)) scale(0); opacity: 0; }
}
@keyframes diceRingBurst {
  0% { width: 0; height: 0; opacity: 0.9; border-width: 3px; }
  100% { width: 250px; height: 250px; opacity: 0; border-width: 1px; margin-left: -125px; margin-top: -125px; }
}

/* =============================================================
   TUTORIAL MACHINE GLOW
   ============================================================ */
@keyframes tutorialMachineGlow {
  0% { box-shadow: 0 0 15px rgba(34,197,94,0.2), 0 0 30px rgba(34,197,94,0.1); }
  50% { box-shadow: 0 0 25px rgba(34,197,94,0.4), 0 0 50px rgba(34,197,94,0.2), 0 0 80px rgba(34,197,94,0.08); }
  100% { box-shadow: 0 0 15px rgba(34,197,94,0.2), 0 0 30px rgba(34,197,94,0.1); }
}

/* ============================================================
   PWA STANDALONE MODE
   ============================================================ */
@media all and (display-mode: standalone) {
  /* Safe area padding for notched phones */
  .header {
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .nav-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* ---- VERY SMALL SCREENS (<=360px) ---- */
@media (max-width: 360px) {
  .scroll { padding: 10px; }
  .card { padding: 10px; margin-bottom: 8px; }
  .btn { padding: 10px 14px; font-size: 12px; }
  .header { padding: 8px 10px; }
  .modal { padding: 14px; }
}

/* ---- LARGE LANDSCAPE / TABLET (768px+ width, landscape) ---- */
@media (min-width: 768px) and (orientation: landscape) {
  .scroll { padding: 24px 32px; }
  .card { padding: 16px; }
  .btn { padding: 16px 24px; font-size: 15px; }
}

/* Android install banner hint */
@media all and (display-mode: browser) {
  .pwa-install-hint { display: block; }
}
@media all and (display-mode: standalone) {
  .pwa-install-hint { display: none; }
}

/* ============================================================
   SHELTER STAT CARD STYLES
   ============================================================ */

.shelter-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  min-height: 80px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dim);
  text-align: center;
}
.shelter-stat-card .stat-icon { font-size: 20px; margin-bottom: 4px; }
.shelter-stat-card .stat-value { font-weight: 700; font-size: var(--font-lg); font-family: var(--font-mono); }
.shelter-stat-card .stat-label { font-size: var(--font-xs); color: var(--text2); text-transform: uppercase; }

/* ============================================================
   SCROLL FADE INDICATORS
   ============================================================ */

.scroll-fade-container {
  position: relative;
}
.scroll-fade-top,
.scroll-fade-bottom {
  position: sticky;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.scroll-fade-top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg2) 0%, transparent 100%);
}
.scroll-fade-bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--bg2) 0%, transparent 100%);
}
.scroll-fade-top.visible,
.scroll-fade-bottom.visible {
  opacity: 1;
}

/* ============================================================
   SCROLL ARROW INDICATORS (auto-attached to .scroll)
   ============================================================ */
.scroll { position: relative; }

.scroll-arrow {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.scroll-arrow.visible {
  opacity: 1;
}
.scroll-arrow-up {
  top: 60px; /* fallback; dynamically set by JS based on scroll element position */
}
.scroll-arrow-down {
  bottom: 60px; /* fallback; dynamically set by JS based on scroll element position */
  top: auto;
}

.scroll-arrow-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 6px 16px 4px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, rgba(15,12,8,0.92) 0%, rgba(15,12,8,0.7) 70%, transparent 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.scroll-arrow-up .scroll-arrow-inner {
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, rgba(15,12,8,0.92) 0%, rgba(15,12,8,0.7) 70%, transparent 100%);
}
.scroll-arrow-down .scroll-arrow-inner {
  border-radius: 12px 12px 0 0;
  background: linear-gradient(0deg, rgba(15,12,8,0.92) 0%, rgba(15,12,8,0.7) 70%, transparent 100%);
  padding: 4px 16px 6px;
}

.scroll-arrow-chevron {
  display: block;
  width: 28px;
  height: 28px;
  position: relative;
}
.scroll-arrow-chevron::before,
.scroll-arrow-chevron::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  top: 50%;
  box-shadow: 0 0 10px rgba(232,166,36,0.6), 0 0 20px rgba(232,166,36,0.2);
}
/* Up chevron */
.scroll-arrow-up .scroll-arrow-chevron::before {
  left: 1px;
  transform: rotate(-40deg);
  transform-origin: left center;
}
.scroll-arrow-up .scroll-arrow-chevron::after {
  right: 1px;
  transform: rotate(40deg);
  transform-origin: right center;
}
/* Down chevron */
.scroll-arrow-down .scroll-arrow-chevron::before {
  left: 1px;
  transform: rotate(40deg);
  transform-origin: left center;
}
.scroll-arrow-down .scroll-arrow-chevron::after {
  right: 1px;
  transform: rotate(-40deg);
  transform-origin: right center;
}

/* Bouncing animation for the chevrons */
@keyframes scrollBounceUp {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(-6px); opacity: 1; }
}
@keyframes scrollBounceDown {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(6px); opacity: 1; }
}
.scroll-arrow-up .scroll-arrow-chevron {
  animation: scrollBounceUp 1.2s ease-in-out infinite;
}
.scroll-arrow-down .scroll-arrow-chevron {
  animation: scrollBounceDown 1.2s ease-in-out infinite;
}

/* Subtle glow pulse on the text */
.scroll-arrow-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.7;
  animation: scrollLabelPulse 2.5s ease-in-out infinite;
}
@keyframes scrollLabelPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

/* ===== NEW ANIMATIONS FOR ENHANCED GACHA EXPERIENCE ===== */

@keyframes silverShimmer {
  0%, 100% { background-position: -100% 0; }
  50% { background-position: 200% 0; }
}

@keyframes legendaryTextReveal {
  0% { transform: scale(2); opacity: 0; filter: blur(8px) brightness(3); }
  40% { transform: scale(1.1); opacity: 1; filter: blur(0px) brightness(1.5); }
  100% { transform: scale(1); opacity: 1; filter: blur(0px) brightness(1); }
}

@keyframes legendaryScreenShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, -3px); }
  40% { transform: translate(3px, 3px); }
  50% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  70% { transform: translate(-1px, 2px); }
  80% { transform: translate(1px, -1px); }
  90% { transform: translate(-1px, 0); }
}

@keyframes legendaryFullFlash {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}
@keyframes popoverFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes popoverSlideIn {
  0% { opacity: 0; transform: translateY(-8px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
