:root {
  --wood-top: #5d3a1f;
  --wood-mid: #472a14;
  --wood-dark: #2f1b0c;
  --brass: #f5b942;
  --brass-bright: #ffe680;
  --parchment: #fbf2dc;
  --parchment-dark: #ead7b0;
  --ink: #24180e;
  --ink-soft: #644d35;
  --outline: 2.5px solid #24180e;
  --shadow-hard: 0 4px 0 #1b1109;
  --card-w: clamp(60px, 5.9vw, 88px);
  --card-h: clamp(64px, 6.2vw, 82px);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, #37533c 0%, #19241b 65%, #0e1510 100%);
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding:
    max(clamp(5px, 0.7vw, 12px), env(safe-area-inset-top))
    max(clamp(6px, 1vw, 16px), env(safe-area-inset-right))
    max(clamp(5px, 0.7vw, 12px), env(safe-area-inset-bottom))
    max(clamp(6px, 1vw, 16px), env(safe-area-inset-left));
  gap: clamp(5px, 0.65vw, 10px);
}

/* ===== Carved Oak & Brass Top HUD ===== */
#hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 18px, transparent 18px 36px),
    linear-gradient(180deg, var(--wood-top) 0%, var(--wood-mid) 55%, var(--wood-dark) 100%);
  border: 3px solid var(--ink);
  box-shadow:
    inset 0 2px 0 rgba(255, 224, 150, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.45),
    var(--shadow-hard);
  border-radius: 15px;
  padding: 6px 12px;
  flex-shrink: 0;
  color: #fef3c7;
}

.brand-block {
  min-width: 220px;
  flex: 1 1 260px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.brand-title {
  font-family: "Bangers", "Fredoka", sans-serif;
  font-size: clamp(1.4rem, 1.8vw, 1.95rem);
  letter-spacing: 0.04em;
  line-height: 0.9;
  color: var(--brass-bright);
  text-shadow: 0 3px 0 var(--ink), 0 0 12px rgba(250, 204, 21, 0.45);
}

.brand-tag {
  font-size: clamp(0.68rem, 0.8vw, 0.78rem);
  font-weight: 700;
  background: linear-gradient(180deg, #2b1d12, #18100a);
  border: 1.5px solid var(--brass);
  color: var(--brass-bright);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.gimmick-pill {
  font-size: clamp(0.66rem, 0.78vw, 0.75rem);
  font-weight: 700;
  background: linear-gradient(180deg, #fef08a, #f59e0b);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  padding: 1px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}

.ticker-bar {
  margin-top: 3px;
  font-size: clamp(0.72rem, 0.85vw, 0.84rem);
  font-style: italic;
  color: #fde68a;
  text-shadow: 0 1px 2px rgba(0,0,0,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-cluster {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  padding: 3px 9px;
  color: var(--ink);
  box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--ink);
  transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

.faith-pill {
  background: linear-gradient(180deg, #fffbeb 0%, #fde047 100%);
  border-color: #78350f;
  min-width: 88px;
}
.faith-pill.pop {
  transform: scale(1.12);
  box-shadow: 0 0 18px rgba(253, 224, 71, 0.85), 0 3px 0 var(--ink);
}

.village-pill.danger {
  background: linear-gradient(180deg, #fee2e2, #fca5a5);
  animation: heartPulse 0.85s infinite;
}
@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.stat-orb { font-size: 1.15rem; filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.85)); }
.stat-icon { font-size: 1.1rem; }
.stat-text { display: flex; flex-direction: column; line-height: 1.02; }
.stat-label { font-size: 0.56rem; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-soft); }
.stat-value { font-size: clamp(0.9rem, 1.05vw, 1.1rem); font-weight: 700; }

.wave-box {
  width: clamp(132px, 13vw, 178px);
  background: linear-gradient(180deg, var(--parchment), var(--parchment-dark));
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  padding: 4px 8px;
  color: var(--ink);
  box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--ink);
}

.wave-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.wave-track {
  position: relative;
  height: 9px;
  background: #cbb38a;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.wave-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #84cc16, #facc15, #ef4444);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45);
  transition: width 0.25s ease;
}

.wave-markers { position: absolute; inset: 0; pointer-events: none; }
.wave-marker { position: absolute; top: -1px; width: 3px; height: 9px; background: var(--ink); }

.controls-cluster { display: flex; gap: 4px; }

.icon-btn {
  width: clamp(30px, 2.6vw, 36px);
  height: clamp(30px, 2.6vw, 36px);
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #fff9eb, #e8d3a7);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: inset 0 2px 0 #fff, 0 3px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
}
.icon-btn:hover { background: linear-gradient(180deg, #fef08a, #f59e0b); transform: translateY(-2px); }
.icon-btn:active { transform: translateY(1px); box-shadow: none; }
.icon-btn.active { background: linear-gradient(180deg, #fb923c, #ea580c); color: #fff; }

/* ===== Stage & Canvas ===== */
#stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #121a13;
  border: 3.5px solid var(--ink);
  border-radius: 18px;
  box-shadow:
    0 0 0 2px rgba(245, 185, 66, 0.35),
    0 6px 0 #100b06,
    0 14px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#active-perks-strip {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
  z-index: 8;
}

.perk-chip {
  background: linear-gradient(180deg, rgba(45, 29, 16, 0.94), rgba(26, 16, 9, 0.94));
  color: #fef08a;
  border: 2px solid var(--brass);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0,0,0,0.45);
}

#selection-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(36, 24, 14, 0.95);
  color: #fef08a;
  border: 2px solid var(--brass);
  border-radius: 14px;
  padding: 6px 10px 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  z-index: 14;
  max-width: 95%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.55);
}
#selection-hint-text {
  line-height: 1.25;
}

#dock-tooltip {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fdf6e3, #ead7b0);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  padding: 7px 14px;
  font-size: 0.78rem;
  line-height: 1.3;
  max-width: min(560px, 94%);
  text-align: center;
  pointer-events: none;
  z-index: 13;
  box-shadow: 0 4px 0 var(--ink), 0 10px 20px rgba(0,0,0,0.45);
}

.deck-card-role {
  font-size: 0.58rem;
  font-weight: 700;
  background: rgba(36, 24, 14, 0.1);
  color: #7c2d12;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.2;
}

.deck-spotlight {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #fffdf6, #f5e6c8);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  padding: 7px 12px;
  margin-bottom: 10px;
  box-shadow: 0 3px 0 var(--ink);
}
.spot-sprite { width: 46px; height: 46px; object-fit: contain; flex-shrink: 0; }
.spot-body { min-width: 0; flex: 1; }
.spot-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 0.86rem; }
.spot-role {
  background: var(--ink);
  color: var(--brass-bright);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.spot-stats { font-size: 0.74rem; font-weight: 700; color: #92400e; }
.spot-desc { font-size: 0.76rem; color: var(--ink-soft); margin-top: 2px; line-height: 1.3; }
.hint-cancel-btn {
  border: 1.5px solid #24180e;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  padding: 3px 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* In-Match Shrine Tier II/III Upgrade Inspector Bar */
#shrine-inspector {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #fdf6e3 0%, #ead7b0 100%);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 7px 12px;
  z-index: 16;
  max-width: 95%;
  box-shadow: 0 6px 0 var(--ink), 0 12px 24px rgba(0,0,0,0.55);
}
.insp-sprite { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.insp-info { min-width: 0; text-align: left; }
.insp-title { font-size: 0.88rem; font-weight: 700; color: var(--ink); }
.insp-sub { font-size: 0.72rem; color: var(--ink-soft); max-width: 280px; }
.insp-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.hero-cta-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.btn-daily {
  background: linear-gradient(180deg, #c084fc 0%, #7c3aed 100%);
  color: #fff;
}
.btn-heroic {
  background: linear-gradient(180deg, #fca5a5 0%, #dc2626 100%);
  color: #fff;
}

.patron-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.patron-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffdf6;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 10px 13px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
}
.patron-card.active {
  background: linear-gradient(180deg, #fef9c3, #fde047);
  border-color: #b45309;
  box-shadow: 0 0 0 2px #f59e0b, 0 4px 0 var(--ink);
}
.patron-card.locked { opacity: 0.55; filter: grayscale(0.75); cursor: not-allowed; }
.patron-emoji { font-size: 2rem; flex-shrink: 0; }
.patron-name { font-size: 0.96rem; font-weight: 700; }
.patron-title { font-size: 0.72rem; font-weight: 700; color: #9a3412; }
.patron-desc { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }

/* Live Comic Hype Streak Meter */
#streak-badge {
  position: absolute;
  top: 12px;
  right: 16px;
  background: linear-gradient(135deg, #b91c1c, #ea580c);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 5px 14px;
  text-align: center;
  box-shadow: 0 4px 0 var(--ink), 0 0 18px rgba(249, 115, 22, 0.65);
  pointer-events: none;
  z-index: 10;
  transform: rotate(3deg);
  animation: streakBounce 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.streak-count {
  font-family: "Bangers", sans-serif;
  font-size: 1.85rem;
  line-height: 0.95;
  color: #fef08a;
  text-shadow: 0 3px 0 var(--ink);
}
.streak-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; color: #fff; }
@keyframes streakBounce {
  from { transform: scale(1.35) rotate(-3deg); }
  to   { transform: scale(1) rotate(3deg); }
}

#wave-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #b91c1c 0%, #7f1d1d 100%);
  color: #fef3c7;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 26px;
  text-align: center;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.28), 0 6px 0 var(--ink), 0 12px 26px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 15;
  max-width: 92%;
  animation: bannerPop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.banner-title { font-family: "Bangers", sans-serif; font-size: clamp(1.35rem, 2vw, 1.85rem); letter-spacing: 0.06em; text-shadow: 0 3px 0 var(--ink); }
.banner-sub { font-size: 0.85rem; opacity: 0.95; }

@keyframes bannerPop {
  from { opacity: 0; transform: translate(-50%, -20px) scale(0.85); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ===== Overlays & Modals ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 19, 15, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 1.2vw, 18px);
  z-index: 25;
}

.hidden { display: none !important; }

.modal {
  background: linear-gradient(180deg, #fdf6e3 0%, #eddab2 100%);
  border: 3.5px solid var(--ink);
  border-radius: 20px;
  padding: clamp(12px, 1.5vw, 22px);
  max-width: 520px;
  width: 100%;
  max-height: 96%;
  overflow-y: auto;
  text-align: center;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.7), 0 8px 0 var(--ink), 0 20px 44px rgba(0,0,0,0.6);
}

.modal-wide { max-width: 940px; }
.modal-hub { max-width: 1120px; text-align: left; }

/* ===== Live Animated Cartoon Hero Diorama (Zero Text Overlap!) ===== */
.hero-diorama {
  position: relative;
  min-height: clamp(104px, 12vw, 138px);
  border-radius: 15px;
  border: 3px solid var(--ink);
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 4px 0 var(--ink);
  background: #233322;
}

.diorama-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.86) saturate(1.12);
}

.diorama-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(22,14,8,0.88) 0%, rgba(22,14,8,0.68) 38%, rgba(22,14,8,0.16) 58%, rgba(22,14,8,0.52) 100%);
}

.diorama-cast {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.diorama-sprite {
  position: absolute;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.45));
}

.spr-goat    { width: clamp(54px, 6.8vw, 84px); bottom: 4px;  left: 44%; animation: floatBob 2.2s ease-in-out infinite; }
.spr-peasant { width: clamp(50px, 6.2vw, 76px); bottom: 6px;  left: 51%; animation: floatBob 2.6s ease-in-out infinite 0.3s; }
.spr-bolt    { width: clamp(54px, 6.8vw, 86px); top: 4px;     left: 59%; animation: boltPulse 1.4s ease-in-out infinite; }
.spr-goblin  { width: clamp(46px, 5.8vw, 72px); bottom: 8px;  left: 66%; animation: panicShake 0.45s ease-in-out infinite; }
.spr-ogre    { width: clamp(66px, 8.2vw, 102px); bottom: -4px; left: 72%; animation: floatBob 2.9s ease-in-out infinite 0.5s; }

@keyframes floatBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes boltPulse {
  0%, 100% { transform: scale(1) rotate(-4deg); filter: drop-shadow(0 0 10px #38bdf8); }
  50% { transform: scale(1.1) rotate(3deg); filter: drop-shadow(0 0 18px #fde047); }
}
@keyframes panicShake {
  0%, 100% { transform: translate(0, 0) rotate(-3deg); }
  50% { transform: translate(3px, -4px) rotate(4deg); }
}

.diorama-overlay-bar {
  position: relative;
  z-index: 3;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.diorama-copy {
  max-width: 42%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.hero-title {
  margin: 0;
  font-family: "Bangers", "Fredoka", sans-serif;
  font-size: clamp(2.1rem, 3.2vw, 3.3rem);
  letter-spacing: 0.04em;
  line-height: 0.88;
  color: var(--brass-bright);
  text-shadow: 0 4px 0 var(--ink), 0 0 18px rgba(250, 204, 21, 0.65);
}

.hero-sub-line {
  font-size: clamp(0.7rem, 0.88vw, 0.84rem);
  font-weight: 700;
  color: #fef3c7;
  text-shadow: 0 2px 3px rgba(0,0,0,0.9);
  line-height: 1.25;
}

.btn-sm {
  padding: 5px 12px !important;
  font-size: 0.78rem !important;
  margin-top: 2px;
}

.hub-meta-pills { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.meta-pill {
  background: linear-gradient(180deg, #fffdf5, #f2e1bc);
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  padding: 4px 12px;
  font-size: clamp(0.76rem, 0.9vw, 0.88rem);
  box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap;
}
.tribute-pill { background: linear-gradient(180deg, #fef9c3 0%, #facc15 100%); }

/* Hub Tabs */
.hub-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2.5px solid rgba(43,33,24,0.18);
}

.tab-btn {
  padding: 6px 12px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #f8ecd2, #e5cfa4);
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(0.74rem, 0.85vw, 0.84rem);
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}
.tab-btn.active {
  background: linear-gradient(180deg, #fef08a, #f59e0b);
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--ink);
}

.notif-dot {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

.hub-toggles { margin-left: auto; display: flex; gap: 5px; flex-wrap: wrap; }

.chip-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fffaf0;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.74rem;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}
.chip-btn.active { background: linear-gradient(180deg, #fb923c, #ea580c); color: #fff; }
.chip-btn.chip-danger { background: #fee2e2; color: #991b1b; }
.chip-btn.chip-danger.confirming { background: #dc2626; color: #fff; animation: heartPulse 0.6s infinite; }
.chip-btn:hover { background: #fef08a; color: var(--ink); }

.chapter-bar { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.chap-btn {
  flex: 1 1 112px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: #fffaf0;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(0.7rem, 0.82vw, 0.8rem);
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}
.chap-btn.active { background: linear-gradient(180deg, #4b2d16, #2b180b); color: var(--brass-bright); }

/* Divine Challenges Grid */
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.challenge-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fffdf6;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 9px 12px;
  box-shadow: 0 3px 0 var(--ink);
  text-align: left;
}
.challenge-card.cleared {
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
  border-color: #15803d;
}
.chal-left { min-width: 0; flex: 1; }
.chal-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chal-emoji { font-size: 1.35rem; line-height: 1; }
.chal-name { font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.chal-badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  text-transform: uppercase;
}
.chal-badge.diff-fun { background: #bbf7d0; color: #14532d; }
.chal-badge.diff-spicy { background: #fed7aa; color: #9a3412; }
.chal-badge.diff-tricky { background: #ddd6fe; color: #4c1d95; }
.chal-badge.diff-brutal { background: #fecaca; color: #991b1b; }
.chal-badge.diff-chaotic { background: #fef08a; color: #854d0e; }
.chal-desc { font-size: 0.73rem; color: var(--ink-soft); margin: 3px 0 4px; line-height: 1.3; }
.chal-meta { font-size: 0.69rem; font-weight: 700; color: #7c2d12; }
.chal-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chal-medal { font-size: 0.7rem; font-weight: 700; color: #15803d; }

.flick-only-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #fef9c3, #fde047);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 8px 14px;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 3px 0 #180f08;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

.map-card {
  display: flex;
  flex-direction: column;
  border: 2.5px solid var(--ink);
  border-radius: 15px;
  overflow: hidden;
  background: #fffdf6;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.map-card:hover:not(.locked) {
  transform: translateY(-4px);
  box-shadow: 0 8px 0 var(--ink), 0 0 18px rgba(250, 204, 21, 0.45);
  background: #fefce8;
}
.map-card.locked { opacity: 0.6; filter: grayscale(0.75); cursor: not-allowed; }

.map-thumb-wrap { position: relative; height: clamp(92px, 10vw, 134px); background: #222; overflow: hidden; }
.map-thumb { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.map-card:hover:not(.locked) .map-thumb { transform: scale(1.06); }
.map-num-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(36, 24, 14, 0.9); border: 1.5px solid var(--brass);
  color: var(--brass-bright); font-size: 0.66rem; font-weight: 700; padding: 2px 7px; border-radius: 6px;
}
.map-stars-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(36, 24, 14, 0.9); color: #fde047; font-size: 0.78rem; padding: 1px 7px; border-radius: 6px;
}
.map-body { padding: 8px 11px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.map-title { font-size: 0.96rem; font-weight: 700; }
.map-gimmick { font-size: 0.72rem; font-weight: 700; color: #9a3412; }
.map-reward { font-size: 0.72rem; color: var(--ink-soft); margin-top: auto; padding-top: 4px; }

/* Shop & Quests */
.panel-intro { margin: 0 0 10px; font-size: 0.84rem; color: var(--ink-soft); }
.shop-grid, .quest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }

.shop-card, .quest-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fffdf6; border: 2.5px solid var(--ink); border-radius: 13px; padding: 9px 12px; box-shadow: 0 3px 0 var(--ink);
}
.shop-info, .quest-info { min-width: 0; flex: 1; }
.shop-name, .quest-name { font-weight: 700; font-size: 0.89rem; }
.shop-desc, .quest-desc { font-size: 0.74rem; color: var(--ink-soft); margin-top: 2px; }
.shop-pips { display: flex; gap: 4px; margin-top: 5px; }
.pip { width: 15px; height: 7px; border-radius: 4px; border: 1.5px solid var(--ink); background: #e5d5b5; }
.pip.filled { background: linear-gradient(180deg, #fde047, #f59e0b); }

.buy-btn {
  padding: 7px 12px; border-radius: 10px; border: 2px solid var(--ink);
  background: linear-gradient(180deg, #fef08a, #f59e0b); font-family: inherit;
  font-weight: 700; font-size: 0.78rem; cursor: pointer; white-space: nowrap; box-shadow: 0 2px 0 var(--ink);
}
.buy-btn:disabled { opacity: 0.48; cursor: not-allowed; background: #e5d5b5; box-shadow: none; }
.buy-btn.claimed { background: #86efac; }

/* Almanac */
.combo-banner {
  background: linear-gradient(90deg, #fef3c7, #ede9fe);
  border: 2px solid var(--ink); border-radius: 11px; padding: 7px 11px;
  font-size: 0.75rem; line-height: 1.45; margin-bottom: 10px;
}
.almanac-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.almanac-two-col h3 { margin: 0 0 6px; font-size: 0.9rem; }
.mini-roster { display: grid; grid-template-columns: 1fr; gap: 6px; max-height: 265px; overflow-y: auto; padding-right: 4px; }
.roster-row {
  display: flex; align-items: center; gap: 8px; background: #fffdf6;
  border: 1.5px solid var(--ink); border-radius: 10px; padding: 5px 8px; font-size: 0.74rem; line-height: 1.25;
}
.roster-row img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.roster-row.locked-row { opacity: 0.52; filter: grayscale(0.8); }

/* ===== Single-Page Deck Builder ===== */
.deck-modal { text-align: left; padding: 12px 16px !important; }
.deck-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 7px; flex-wrap: wrap; }
.deck-title-wrap { min-width: 0; flex: 1; }
.deck-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deck-top h2 { margin: 0; font-size: clamp(1.05rem, 1.4vw, 1.35rem); }
.deck-sub { margin: 2px 0 0; font-size: 0.76rem; color: var(--ink-soft); }
.deck-top-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

.scout-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: rgba(36, 24, 14, 0.08);
  border: 1.5px solid rgba(36, 24, 14, 0.22);
  border-radius: 10px;
  padding: 4px 9px;
  margin-bottom: 6px;
}
.scout-label { font-size: 0.68rem; font-weight: 700; color: #7c2d12; white-space: nowrap; }
.scout-icons { display: flex; gap: 5px; flex-wrap: wrap; }
.scout-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #fffdf6;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 1px 7px 1px 3px;
  font-size: 0.66rem;
  font-weight: 700;
}
.scout-pill img { width: 20px; height: 20px; object-fit: contain; }
.deck-smites-preview { margin-left: auto; font-size: 0.72rem; font-weight: 700; color: #5b21b6; }

.deck-section-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.deck-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-bottom: 7px; }

.deck-card {
  display: flex; flex-direction: column; align-items: center; padding: 4px 4px;
  border-radius: 10px; border: 2px solid var(--ink); background: #fffdf6;
  cursor: pointer; text-align: center; gap: 1px; box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.09s ease;
}
.deck-card:hover:not(.locked) { transform: translateY(-2px); }
.deck-card img { width: clamp(32px, 3.4vw, 42px); height: clamp(32px, 3.4vw, 42px); object-fit: contain; }
.deck-card.picked { background: linear-gradient(180deg, #fef9c3, #fde047); border-color: #b45309; box-shadow: 0 0 0 2px #f59e0b, 0 2px 0 var(--ink); }
.deck-card.locked { opacity: 0.45; filter: grayscale(0.9); cursor: not-allowed; }
.deck-card-name { font-size: 0.66rem; font-weight: 700; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.deck-card-cost { font-size: 0.64rem; font-weight: 700; color: #92400e; }

/* ===== Perk Draft ===== */
.perk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.perk-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 12px;
  border-radius: 16px; border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #fffdf5 0%, #fef3c7 100%);
  box-shadow: 0 5px 0 var(--ink); cursor: pointer; color: var(--ink); font-family: inherit;
  transition: transform 0.1s ease;
}
.perk-card:hover { transform: translateY(-5px); background: linear-gradient(180deg, #fef9c3, #fde047); }
.perk-emoji { font-size: 2.2rem; }
.perk-name { font-size: 1rem; font-weight: 700; }
.perk-desc { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.3; }

/* ===== Compact Single-Page End Screen & Celestial Yelp ===== */
.end-modal { max-width: 560px; padding: 14px 18px !important; }
.end-top-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.end-heading { flex: 1; text-align: center; }
.end-heading h2 { margin: 0; font-size: 1.45rem; }
.end-icon { font-size: 2.1rem; line-height: 1; }
.end-stars-row { font-size: 1.35rem; margin: 2px 0 0; }
.unlock-banner {
  background: linear-gradient(90deg, #fef08a, #facc15); border: 2px solid var(--ink);
  border-radius: 10px; padding: 5px 10px; margin: 6px 0;
  display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 2px 0 var(--ink); font-size: 0.84rem;
}
.unlock-tag { background: #dc2626; color: #fff; font-size: 0.66rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.yelp-card {
  background: #fffdf7; border: 2px solid var(--ink); border-radius: 12px;
  padding: 8px 12px; text-align: left; margin: 6px 0; box-shadow: 0 2px 0 var(--ink);
}
.yelp-head { display: flex; justify-content: space-between; font-size: 0.74rem; font-weight: 700; }
.yelp-logo { color: #b91c1c; }
.yelp-rank { font-size: 0.78rem; font-weight: 700; color: #7c2d12; margin-top: 2px; }
.yelp-card blockquote { margin: 4px 0 6px; font-size: 0.78rem; font-style: italic; color: var(--ink); }
.yelp-card.monster-review { background: #fff1f2; border-color: #991b1b; }
.yelp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 10px; }
.end-stat { background: #fffdf6; border: 2px solid var(--ink); border-radius: 9px; padding: 5px; }
.end-stat strong { display: block; font-size: 1rem; }
.end-stat span { font-size: 0.64rem; color: var(--ink-soft); font-weight: 700; }

.modal-actions { display: flex; justify-content: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  padding: 9px 18px; border-radius: 12px; border: 2.5px solid var(--ink);
  font-family: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), 0 3px 0 var(--ink); transition: transform 0.08s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn-primary { background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%); color: var(--ink); }
.btn-secondary { background: linear-gradient(180deg, #fffdf6, #eddcb8); color: var(--ink); }
.btn-ghost { background: #e5d5b5; color: var(--ink); }

.almanac-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.almanac-head h2 { margin: 0; }
.almanac-modal { text-align: left; }

/* ===== Fluid Responsive Carved Oak & Gold Bottom Action Dock ===== */
#hud-bottom {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 18px, transparent 18px 36px),
    linear-gradient(180deg, var(--wood-top) 0%, var(--wood-mid) 55%, var(--wood-dark) 100%);
  border: 3px solid var(--ink);
  box-shadow:
    inset 0 2px 0 rgba(255, 224, 150, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.45),
    var(--shadow-hard);
  border-radius: 15px;
  padding: 6px 10px 8px;
  flex-shrink: 0;
}

.dock-section { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ult-tool-group { flex-direction: row; gap: 6px; }
.dock-label {
  font-size: clamp(0.56rem, 0.68vw, 0.68rem);
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--brass-bright);
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  white-space: nowrap;
}
.key-hint { opacity: 0.8; }
.dock-divider { width: 2px; background: rgba(255, 224, 150, 0.24); margin: 4px 0; }
.card-row { display: flex; gap: clamp(4px, 0.45vw, 7px); flex-wrap: nowrap; }

.action-card {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 12px;
  border: 2.5px solid var(--ink);
  background: linear-gradient(180deg, #fffef9 0%, #f3e2bc 100%);
  color: var(--ink);
  padding: 3px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.85), 0 4px 0 #180f08;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}

.action-card.smite-card {
  background: linear-gradient(180deg, #faf5ff 0%, #d8b4fe 100%);
  border-color: #3b0764;
}
.action-card.smite-card:not(.disabled):not(.locked-smite) {
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.85), 0 0 12px rgba(192, 132, 252, 0.45), 0 4px 0 #180f08;
}

.action-card.ult-card {
  width: clamp(66px, 6.4vw, 90px);
  background: linear-gradient(180deg, #2b1d12 0%, #1c120a 100%);
  border-color: var(--brass);
  color: #fef3c7;
}
.action-card.ult-card .card-cost { color: #fde047; position: relative; z-index: 2; }
.action-card.ult-card .card-name,
.action-card.ult-card .ult-icon { position: relative; z-index: 2; }
.action-card.ult-card .card-key { z-index: 3; }

.ult-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 55%, #dc2626 100%);
  opacity: 0.78; transition: height 0.2s ease; z-index: 1;
}
.action-card.ult-card.ready {
  border-color: #fef08a; color: var(--ink);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.95), 0 0 0 2.5px #facc15, 0 4px 0 #180f08;
  animation: ultPulse 0.9s ease-in-out infinite;
}
.action-card.ult-card.ready .card-cost { color: #7f1d1d; }
@keyframes ultPulse {
  0%, 100% { transform: translateY(-1px) scale(1); }
  50% { transform: translateY(-4px) scale(1.06); }
}

.action-card.tool-card {
  width: clamp(58px, 5.2vw, 74px);
  background: linear-gradient(180deg, #fff1f2 0%, #fecaca 100%);
}
.action-card:hover:not(.disabled):not(.locked-smite) { transform: translateY(-3px); }
.action-card.selected {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fef9c3 0%, #facc15 100%);
  transform: translateY(-4px);
  box-shadow: 0 6px 0 #180f08, 0 0 0 2.5px #fde047, 0 0 16px rgba(250, 204, 21, 0.7);
}
.action-card.smite-card.selected {
  border-color: #a855f7;
  background: linear-gradient(180deg, #f3e8ff 0%, #c084fc 100%);
  box-shadow: 0 6px 0 #180f08, 0 0 0 2.5px #e879f9, 0 0 18px rgba(192, 132, 252, 0.85);
}
.action-card.disabled { opacity: 0.46; filter: grayscale(0.55); cursor: not-allowed; }
.action-card.locked-smite { opacity: 0.34; filter: grayscale(1); cursor: not-allowed; }

.card-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.56rem;
  font-weight: 700;
  background: rgba(36, 24, 14, 0.84);
  color: var(--brass-bright);
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1.3;
}

.card-sprite { width: clamp(30px, 3.1vw, 44px); height: clamp(30px, 3.1vw, 44px); object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 1px rgba(0,0,0,0.2)); }
.card-emoji { font-size: clamp(1.15rem, 1.4vw, 1.5rem); line-height: 1.05; }
.card-name { font-size: clamp(0.56rem, 0.62vw, 0.67rem); font-weight: 700; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 94%; }
.card-cost { font-size: clamp(0.56rem, 0.64vw, 0.67rem); font-weight: 700; color: #92400e; }
.smite-card .card-cost { color: #581c87; }

.cd-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: rgba(18, 15, 28, 0.68); pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.78rem; text-shadow: 0 1px 2px #000;
}

/* ===== Responsive Scaling Down (Tablets, Split-Screen, Mobile) ===== */
@media (max-width: 1080px) {
  .dock-divider { display: none; }
  #hud-bottom { justify-content: center; }
  .deck-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .diorama-copy { max-width: 56%; }
  .spr-goat { left: 56%; }
  .spr-peasant { display: none; }
  .spr-bolt { left: 65%; }
  .spr-goblin { display: none; }
  .spr-ogre { left: 73%; }
}

@media (max-width: 820px) {
  #hud-top { padding: 5px 9px; gap: 5px; }
  .brand-block { flex: 1 1 100%; }
  .stats-cluster { width: 100%; justify-content: space-between; }
  .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-grid, .quest-grid, .challenge-grid, .almanac-two-col { grid-template-columns: 1fr; }
  .perk-grid { grid-template-columns: 1fr; }
  .diorama-cast { display: none; }
  .diorama-copy { max-width: 68%; }
  .card-row { overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .deck-dock, .smite-section { max-width: 100%; }
}

@media (max-width: 540px) {
  :root { --card-w: 58px; --card-h: 62px; }
  .map-grid { grid-template-columns: 1fr; }
  .patron-grid { grid-template-columns: 1fr; }
  .deck-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .end-stats { grid-template-columns: repeat(2, 1fr); }
  .ticker-bar { display: none; }
  .key-hint { display: none; }
  .card-row { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .card-row::-webkit-scrollbar { display: none; }
  #shrine-inspector { flex-wrap: wrap; justify-content: center; padding: 6px 9px; gap: 6px; }
  .insp-sub { max-width: 210px; }
}

/* Dedicated Ultra-Compact iPhone Landscape Mode (e.g. 844x390)! */
@media (max-height: 460px) and (orientation: landscape) {
  :root { --card-w: 56px; --card-h: 52px; }
  #app { padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left)); gap: 3px; }
  #hud-top { padding: 3px 8px; gap: 6px; border-radius: 10px; }
  .brand-block { flex: 0 1 auto; min-width: 0; }
  .ticker-bar, .gimmick-pill, .dock-label, .card-name { display: none; }
  .stat-pill { padding: 2px 6px; }
  .wave-box { width: 112px; padding: 2px 6px; }
  .icon-btn { width: 28px; height: 28px; font-size: 0.78rem; }
  #hud-bottom { padding: 3px 6px; border-radius: 10px; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  .dock-divider { display: none; }
  .card-sprite { width: 28px; height: 28px; }
  .action-card.ult-card { width: 60px; }
  .action-card.tool-card { width: 52px; }
  .modal-hub { padding: 8px 12px; }
  .hero-diorama { min-height: 68px; margin-bottom: 6px; }
  .map-thumb-wrap { height: 64px; }
}

@media (max-height: 700px) and (min-width: 821px) {
  .modal-hub { padding: 10px 16px 12px; }
  .hero-diorama { min-height: 92px; margin-bottom: 7px; }
  .diorama-overlay-bar { padding: 8px 14px; }
  .hub-tabs { margin-bottom: 7px; padding-bottom: 6px; }
  .chapter-bar { margin-bottom: 7px; }
  .map-thumb-wrap { height: 86px; }
  .map-body { padding: 6px 10px 7px; }
}
