* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background:
    repeating-linear-gradient(0deg, rgba(240,198,107,0.025) 0px, rgba(240,198,107,0.025) 1px, transparent 1px, transparent 28px),
    repeating-linear-gradient(90deg, rgba(240,198,107,0.025) 0px, rgba(240,198,107,0.025) 1px, transparent 1px, transparent 28px),
    radial-gradient(ellipse at top, #2a221c 0%, #14100c 60%, #0a0807 100%);
  color: #e9dfc9;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* #app is a fixed 1280x800 "design resolution" canvas, centered in the
   window and scaled as a whole to fit — see updateUiScale() in game.js.
   Everything inside it keeps using the same fixed pixel values it always
   has; only the single transform on #app changes as the window resizes,
   which is far simpler than making every hardcoded layout value fluid. */
#app {
  width: 1280px; height: 800px;
  position: absolute; left: 50%; top: 50%; margin-left: -640px; margin-top: -400px;
  transform: scale(1);
  display: flex; flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

/* Sits outside #app on purpose (see index.html) — a fixed viewport corner,
   not the scaled 1280x800 canvas, so it's always a consistent click target. */
.sfx-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 500;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(20, 16, 12, 0.7);
  border: 1px solid #7a5c2e;
  color: #f0c66b;
  font-size: 16px; line-height: 1;
  cursor: pointer;
}
.sfx-toggle:hover { background: rgba(40, 32, 22, 0.85); }

/* ---------- Preloader (see preloader.js) ---------- */
.preloader {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background:
    radial-gradient(ellipse at top, #2a221c 0%, #14100c 60%, #0a0807 100%);
  transition: opacity 0.5s ease;
}
.preloader.preloader-hidden { opacity: 0; pointer-events: none; }
.preloader-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 42px; letter-spacing: 2px; color: #f0c66b;
  text-shadow: 0 2px 16px rgba(240, 198, 107, 0.35);
}
.preloader-bar-track {
  width: 300px; height: 10px; border-radius: 6px;
  background: rgba(240, 198, 107, 0.12);
  border: 1px solid #7a5c2e;
  overflow: hidden;
}
.preloader-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7a5c2e, #f0c66b);
  transition: width 0.2s ease;
}
.preloader-pct { color: #d8c48a; font-size: 13px; letter-spacing: 1px; }

h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; color: #f0c66b; margin: 0.3em 0; }

/* ---------- Icons (inline hand-drawn SVGs, tinted via currentColor) ---------- */
.icon { display: inline-flex; align-items: center; justify-content: center; color: #d8c48a; flex-shrink: 0; }
.icon svg { width: 100%; height: 100%; display: block; }
.icon-tiny { width: 14px; height: 14px; }
.icon-sm { width: 24px; height: 24px; }
.icon-md { width: 36px; height: 36px; }
.icon-lg { width: 56px; height: 56px; }
.icon-xl { width: 96px; height: 96px; margin-bottom: 6px; }

.btn {
  background: linear-gradient(#3a2f22, #241c14);
  color: #f0c66b;
  border: 1px solid #7a5c2e;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  margin: 6px;
}
.btn:hover:not(:disabled) { background: linear-gradient(#4a3c2a, #2e2418); border-color: #f0c66b; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-large { font-size: 20px; padding: 16px 32px; }
.btn-small { font-size: 12px; padding: 5px 10px; }

/* ---------- Menu ---------- */
.menu-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px; overflow-y: auto;
}
.title-hero { width: 110px; height: 110px; color: #cfd6de; filter: drop-shadow(0 0 18px rgba(240,198,107,0.35)); }
.title-hero svg path[fill="#e0824a"] {
  transform-origin: 32px 46px;
  animation: flameFlicker 0.45s ease-in-out infinite alternate;
}
@keyframes flameFlicker { 0% { transform: scaleY(1) scaleX(1); opacity: 1; } 100% { transform: scaleY(1.18) scaleX(0.9); opacity: 0.85; } }
.title-hero-img { width: 200px; height: 200px; object-fit: contain; filter: drop-shadow(0 0 24px rgba(240,198,107,0.4)); margin-bottom: 6px; }
.title { font-size: 56px; letter-spacing: 6px; text-shadow: 0 0 20px rgba(240,198,107,0.5); }
.subtitle { color: #b3a482; margin-bottom: 20px; }
.help-box {
  max-width: 560px; text-align: left; background: rgba(0,0,0,0.3);
  border: 1px solid #4a3c2a; border-radius: 8px; padding: 16px 22px; margin-top: 20px;
}
.help-box li { margin-bottom: 8px; line-height: 1.4; }

/* ---------- Character select ---------- */
.character-select-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; padding: 24px;
  overflow-y: auto; text-align: center;
}
.character-select-grid { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.character-select-card {
  width: 260px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(#241c14, #16110c); border: 2px solid #4a3c2a; border-radius: 12px;
  padding: 18px; cursor: pointer; transition: transform 0.15s, border-color 0.15s;
}
.character-select-card:hover { transform: translateY(-6px); border-color: #f0c66b; }
.character-select-avatar {
  width: 160px; height: 200px; object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 10px 10px rgba(0,0,0,0.6));
}
.character-select-avatar-fallback { color: #8a7a5e; margin: 20px 0; }
.character-select-tagline { color: #f0c66b; font-style: italic; font-size: 13px; margin: 0; }
.character-select-desc { color: #cfc4a4; font-size: 13px; line-height: 1.4; margin: 4px 0; }
.character-select-starters { color: #a99968; font-size: 11.5px; margin: 0 0 6px; }

/* ---------- Topbar / stats ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  background: rgba(0,0,0,0.35); border-bottom: 1px solid #3a2f22; flex-wrap: wrap;
}
.stat { font-weight: bold; color: #f0c66b; }
.relic-row { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.relic-icon {
  display: flex; align-items: center; gap: 5px;
  background: rgba(240,198,107,0.12); border: 1px solid #7a5c2e; border-radius: 4px;
  padding: 3px 8px; font-size: 12px; color: #d8c48a;
}

/* ---------- Map ----------
   The map is a tall pixel-space canvas (start at the bottom, boss at the
   top) panned by dragging, clipped by its viewport. See mountMapPan() /
   handleMapPointerMove() in game.js for the drag logic. */
.map-wrap {
  position: relative; flex: 1; margin: 10px 20px; overflow: hidden;
  cursor: grab; touch-action: none;
}
.map-wrap.grabbing { cursor: grabbing; }
.map-canvas { position: absolute; top: 0; left: 50%; }
.map-svg { position: absolute; top: 0; left: 0; pointer-events: none; }
.map-edge { stroke: #4a3c2a; stroke-width: 2; }
.map-edge-done { stroke: #7a5c2e; }
.map-fade { position: absolute; left: 0; right: 0; height: 44px; pointer-events: none; }
.map-fade-top { top: 0; background: linear-gradient(rgba(10,8,6,0.9), rgba(10,8,6,0)); }
.map-fade-bottom { bottom: 0; background: linear-gradient(rgba(10,8,6,0), rgba(10,8,6,0.9)); }
.map-node {
  position: absolute; transform: translate(-50%, -50%);
  width: 54px; height: 54px; border-radius: 50%; padding: 0;
  background: #241c14; border: 2px solid #4a3c2a; color: #7a6a4e;
  display: flex; align-items: center; justify-content: center;
  cursor: not-allowed;
}
.map-node:not(.map-node-reachable) { pointer-events: none; }
.map-node .node-icon { width: 28px; height: 28px; display: flex; }
.map-node .node-icon svg { width: 100%; height: 100%; display: block; }
.map-node .node-icon-img { width: 34px; height: 34px; object-fit: contain; }
.map-node-visited { border-color: #5a4a30; color: #a99968; opacity: 0.6; }
.map-node-current { border-color: #f0c66b; color: #f0c66b; box-shadow: 0 0 14px rgba(240,198,107,0.6); }
.map-node-reachable {
  cursor: pointer; border-color: #f0c66b; color: #f0c66b;
  animation: pulse 1.6s infinite;
}
.map-node-reachable:hover { background: #3a2f22; }
.map-node-elite { border-color: #b0483f; }
.map-node-elite.map-node-reachable { border-color: #e06052; color: #e06052; }
.map-node-boss { width: 66px; height: 66px; }
.map-node-boss .node-icon { width: 36px; height: 36px; }
.map-node-boss .node-icon-img { width: 46px; height: 46px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 4px rgba(240,198,107,0.4); } 50% { box-shadow: 0 0 16px rgba(240,198,107,0.9); } }

.map-legend { display: flex; gap: 16px; justify-content: center; padding: 8px; font-size: 12px; color: #a99968; }

/* ---------- Cards ---------- */
.card-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 12px 0; }

/* MTG-style frame: black card body, a colored title bar and type line per
   card color, a framed art window, and a parchment-toned rules box. */
.card {
  width: 154px; min-height: 300px; border-radius: 11px; padding: 6px;
  background: linear-gradient(#161310, #0d0b09);
  border: 2px solid #060504; box-shadow: 0 0 0 1px #3a3226, 0 3px 8px rgba(0,0,0,0.5);
  position: relative; cursor: pointer; touch-action: none;
  display: flex; flex-direction: column; gap: 5px; transition: transform 0.1s;
}
.card:hover { transform: translateY(-6px); }
.card.dragging { transition: none; cursor: grabbing; touch-action: none; }
.card.drag-ready { box-shadow: 0 0 0 3px #6fcf7a, 0 6px 16px rgba(0,0,0,0.6); }
.card-upgraded { box-shadow: 0 0 0 1px #3a3226, 0 0 10px rgba(240,198,107,0.55); }
.card-disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.card-selected { outline: 3px solid #f0c66b; transform: translateY(-6px); }

.card-title-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  border-radius: 5px; padding: 4px 6px; border: 1px solid rgba(0,0,0,0.5);
}
.card-name { font-weight: bold; color: #f7ecd2; font-size: 12.5px; line-height: 1.15; text-shadow: 0 1px 1px rgba(0,0,0,0.6); }
.card-cost-gem {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a3c22, #12100e);
  border: 1.5px solid #f0c66b; color: #f7dfa0;
  display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 12px;
}

.card-attack .card-title-bar, .card-attack .card-type-line { background: linear-gradient(#6b2c24, #431a15); }
.card-skill .card-title-bar, .card-skill .card-type-line { background: linear-gradient(#1f4260, #14293b); }
.card-power .card-title-bar, .card-power .card-type-line { background: linear-gradient(#4a2c68, #2c1a3f); }
.card-starter .card-title-bar, .card-starter .card-type-line { background: linear-gradient(#5a4726, #372c17); }
.card-curse { opacity: 0.85; }
.card-curse .card-title-bar, .card-curse .card-type-line { background: linear-gradient(#3a3a3a, #1a1a1a); }
.card-curse .card-name { color: #b8ada0; }
.card-curse .card-cost-gem { border-color: #8a7a5e; color: #b8ada0; }

.card-art-wrap {
  width: 100%; height: 118px; border-radius: 4px; overflow: hidden;
  position: relative;
  background: linear-gradient(#3a2f22, #1a140e);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.4);
}
.card-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-art-placeholder { display: flex; align-items: center; justify-content: center; opacity: 0.5; }

/* ---------- Card art animation: short seamless CSS loops, no new art needed ----------
   Every card gets the diagonal foil-shimmer sweep below. Rares layer two more
   on top: a pulsing gold frame glow and a slow Ken Burns zoom on the art
   itself. All three run on different periods, so on a rare they drift in and
   out of phase with each other rather than reading as one repetitive cycle.
   Every keyframe's 0%/100% match, so each loops with no visible seam. */
.card-rare {
  animation: card-rare-glow 2.6s ease-in-out infinite;
}
@keyframes card-rare-glow {
  0%, 100% { box-shadow: 0 0 0 1px #3a3226, 0 0 8px rgba(240,198,107,0.35), 0 3px 8px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 0 1px #f0c66b, 0 0 22px rgba(240,198,107,0.9), 0 3px 8px rgba(0,0,0,0.5); }
}
.card-rare .card-art {
  animation: card-rare-kenburns 6s ease-in-out infinite;
}
@keyframes card-rare-kenburns {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.card-art-shimmer {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.6) 48%, rgba(255,238,180,0.35) 52%, transparent 70%);
  transform: translateX(-130%);
  animation: card-rare-shimmer 3.4s linear infinite;
  mix-blend-mode: overlay;
}
@keyframes card-rare-shimmer {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}

.card-type-line {
  display: flex; align-items: center; gap: 5px; border-radius: 4px; padding: 3px 6px;
  font-size: 9.5px; text-transform: uppercase; color: #ecdfc0; letter-spacing: 0.5px;
  border: 1px solid rgba(0,0,0,0.5);
}
.card-type-line .icon { color: #ecdfc0; opacity: 0.9; }

.card-rules-box {
  flex: 1; background: rgba(238,223,181,0.06); border: 1px solid rgba(238,223,181,0.15);
  border-radius: 5px; padding: 6px 7px; display: flex; flex-direction: column; gap: 5px;
}
.card-desc { font-size: 11.5px; color: #ddd0ae; line-height: 1.35; }
.card-flavor {
  font-size: 10px; font-style: italic; color: #9c8f6c; line-height: 1.3;
  border-top: 1px solid rgba(238,223,181,0.15); padding-top: 4px; margin-top: auto;
}
.card-price { font-size: 12px; font-weight: bold; color: #f0c66b; text-align: right; }

/* ---------- Combat ---------- */
.combat-screen {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative;
  background-size: cover; background-position: center; background-repeat: no-repeat;
}

/* Player vitals + potions live in a slim strip at the very top, Slay the
   Spire style, instead of a tall bar wedged between the enemies and the
   hand — that bar used to eat into the hand's space and clip card tops. */
.top-hud {
  flex-shrink: 0; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 14px 24px 4px;
}
.player-focus-block { display: flex; flex-direction: column; gap: 4px; }

/* Characters are anchored toward the bottom of their band rather than
   centered in it, and sit on a matching ground shadow — both meant to line
   up with the floor plane the battle-background art now composes for,
   rather than looking pasted over an unrelated backdrop. */
.enemies-row { flex: 1; min-height: 0; display: flex; align-items: flex-end; justify-content: center; gap: 40px; padding: 20px 20px 36px; }
.enemy {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 150px;
  padding: 10px; border-radius: 8px;
}
/* The player's own character, standing on the same floor as the enemies —
   shares .enemy-portrait-wrap/.enemy-ground-shadow for identical grounding. */
.player-avatar { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 150px; padding: 10px; }
.player-avatar-name { font-weight: bold; color: #f0e6c8; text-shadow: 0 1px 3px rgba(0,0,0,0.8); font-size: 13px; }
.enemy.targetable { cursor: crosshair; outline: 2px dashed #b0483f; border-radius: 10px; }
.enemy.targetable:hover { background: rgba(176,72,63,0.15); }
.enemy.drag-hover-target { outline: 3px solid #6fcf7a; border-radius: 10px; background: rgba(111,207,122,0.18); }
.enemy-dead { opacity: 0.25; }
.enemy-portrait { color: #dba572; }
.enemy-portrait-wrap {
  position: relative; width: 150px; height: 210px;
  display: flex; align-items: flex-end; justify-content: center;
}
.enemy-portrait-wrap .enemy-portrait-img {
  width: 100%; height: 100%; object-fit: contain; object-position: bottom center;
  display: block; filter: drop-shadow(0 10px 12px rgba(0,0,0,0.65)) drop-shadow(0 0 18px rgba(0,0,0,0.35));
}
.enemy-ground-shadow {
  position: absolute; left: 50%; bottom: 4px; width: 96px; height: 20px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.28) 55%, rgba(0,0,0,0) 78%);
  z-index: -1; pointer-events: none;
}
/* Enemy intent — the single most important thing to read at a glance, so it
   gets big bold icon+number pills rather than small plain text. */
.enemy-intent { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 30px; }
.intent-chip {
  display: flex; align-items: center; gap: 4px; font-weight: bold; font-size: 16px;
  padding: 3px 9px; border-radius: 14px; background: rgba(10,8,6,0.72);
  border: 1.5px solid currentColor; box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.intent-chip .icon { width: 15px; height: 15px; }
.intent-multiplier { font-size: 11px; opacity: 0.85; margin-left: -1px; }
.intent-attack { color: #ff7a68; }
.intent-defend { color: #7cc3ec; }
.intent-buff { color: #f0c66b; }
.intent-debuff { color: #cf9ce8; }
.intent-poison { color: #8fe09f; }
.intent-dead { font-size: 12px; font-weight: normal; font-style: italic; color: #a99968; border: none; background: none; box-shadow: none; }

/* A dark plate behind an enemy's vitals keeps them legible over any art. */
.enemy-stat-plate {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(8,6,5,0.55); border-radius: 8px; padding: 6px 10px; width: 100%;
}
.enemy-name { font-weight: bold; color: #f0e6c8; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.enemy-hp-row { display: flex; align-items: center; gap: 6px; }
.enemy-hptext { font-size: 12px; color: #cfc4a4; }

.hpbar { width: 120px; height: 13px; background: #2a1a1a; border-radius: 6px; overflow: hidden; border: 1px solid #4a2a2a; }
.hpbar-fill {
  height: 100%; background: linear-gradient(#c0433a, #7a231d);
  transition: width 0.45s cubic-bezier(.2,.7,.3,1);
}
.hpbar-fill.bar-flash-damage { animation: bar-flash-red 0.5s ease-out; }
.hpbar-fill.bar-flash-heal { animation: bar-flash-white 0.5s ease-out; }
@keyframes bar-flash-red {
  0% { filter: brightness(2.2) saturate(1.5); }
  100% { filter: brightness(1) saturate(1); }
}
@keyframes bar-flash-white {
  0% { filter: brightness(2.4) saturate(0.6); }
  100% { filter: brightness(1) saturate(1); }
}

/* The player's own Focus bar — amber to distinguish it from enemies' red
   health bars, same animated-transition treatment. */
.focus-bar-row { display: flex; align-items: center; gap: 8px; }
.focus-bar { width: 180px; height: 16px; background: #241a10; border-radius: 7px; overflow: hidden; border: 1px solid #5a4420; }
.focus-bar .hpbar-fill { background: linear-gradient(#f0c66b, #b8862e); }

/* A currently-held Block value, shown as its own shield badge next to HP —
   distinct from the intent chip, which previews an upcoming action. */
/* Solid, lit-up look for currently-active Block — deliberately more "on"
   than the darker intent-chip forecast (.intent-defend), so the two blue
   shield readouts don't get mistaken for each other. */
.block-badge {
  display: inline-flex; align-items: center; gap: 3px; font-weight: bold; font-size: 12px;
  color: #eaf6ff; background: rgba(95,160,214,0.35); border: 1.5px solid #7cc3ec;
  border-radius: 10px; padding: 1px 7px; box-shadow: 0 0 6px rgba(124,195,236,0.5);
}
.block-badge .icon { width: 12px; height: 12px; }

.status-row { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.badge {
  font-size: 10px; font-weight: bold; border-radius: 4px; padding: 2px 6px;
  background: rgba(255,255,255,0.06); border: 1px solid currentColor;
}
.badge-str { color: #f0c66b; }
.badge-dex { color: #7cc3ec; }
.badge-weak { color: #b8a8d8; }
.badge-vuln { color: #ff8a7a; }
.badge-poison { color: #8fe09f; }
.badge-power { color: #e0a8f0; }

.targeting-banner {
  position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); border: 1px solid #f0c66b; color: #f0c66b;
  padding: 8px 16px; border-radius: 6px; z-index: 5;
}

.player-hp { font-weight: bold; color: #f0e6c8; }
.potion-row { display: flex; gap: 6px; }
.potion-slot {
  width: 46px; height: 46px; border-radius: 6px; background: #241c14; border: 1px solid #5a4a30;
  display: flex; align-items: center; justify-content: center; font-size: 9px; text-align: center;
  color: #d8c48a; cursor: pointer; padding: 2px;
}
.potion-empty { opacity: 0.3; cursor: default; }

/* Draw/discard/exhaust and the energy orb are floating corner widgets now,
   not a row competing with the hand for vertical space. */
.corner-hud {
  position: absolute; bottom: 22px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; z-index: 4;
}
.corner-hud-energy { left: 24px; }
.corner-hud-piles { right: 190px; }
.pile-counter {
  font-size: 12px; font-weight: bold; color: #d8c48a; background: rgba(8,6,5,0.6);
  border: 1px solid #4a3c2a; border-radius: 10px; padding: 3px 10px; white-space: nowrap;
}
.energy-display {
  font-size: 24px; font-weight: bold; color: #f0c66b;
  width: 50px; height: 50px; border-radius: 50%; border: 2px solid #f0c66b;
  background: rgba(8,6,5,0.6);
  display: flex; align-items: center; justify-content: center;
}
.end-turn-btn {
  position: absolute; right: 20px; bottom: 20px; z-index: 4;
  background: linear-gradient(#8a6c2e, #5a4014); border-color: #f0c66b;
  color: #fff6dc; font-weight: bold;
}
.end-turn-btn:hover:not(:disabled) { background: linear-gradient(#9c7c3a, #6a501c); }

.hand-row {
  display: flex; gap: 8px; justify-content: center; padding: 14px 250px 14px 110px;
  overflow-x: auto; overflow-y: visible; min-height: 330px; flex-shrink: 0; align-items: flex-end;
}

/* ---------- Reward / Rest / Shop / Relic / Game over ---------- */
.reward-screen, .rest-screen, .shop-screen, .relic-found-screen, .gameover-screen, .event-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; padding: 30px; overflow-y: auto; text-align: center;
}
.pickup-line { color: #d8c48a; }

/* ---------- Side Quest events ---------- */
.event-screen { background-size: cover; background-position: center; background-repeat: no-repeat; }
.event-screen h1 { text-shadow: 0 2px 6px rgba(0,0,0,0.8); }
.event-desc {
  max-width: 520px; color: #f0e6c8; font-size: 15px; line-height: 1.5; margin: 10px 0 22px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.event-choices { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }
.event-choice-btn {
  text-align: left; white-space: normal; line-height: 1.3;
  background: linear-gradient(rgba(36,28,20,0.92), rgba(20,16,12,0.92));
}
.event-outcome-label { color: #d8c9a0; font-size: 13px; margin-bottom: 4px; text-shadow: 0 1px 4px rgba(0,0,0,0.9); }
.event-outcome-text {
  max-width: 520px; color: #f0e6c8; font-size: 15px; line-height: 1.5;
  background: rgba(10,8,6,0.65); border: 1px solid #3a2f22; border-radius: 8px; padding: 14px 18px; margin-bottom: 10px;
}
.rest-options { display: flex; gap: 16px; margin-top: 20px; }
.shop-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.shop-tile {
  width: 190px; padding: 12px; border-radius: 8px; background: linear-gradient(#2a2118, #1a140e);
  border: 2px solid #5a4a30; cursor: pointer; text-align: left;
}
.shop-tile .icon { margin-bottom: 6px; color: #d8c48a; }
.shop-tile .card-desc { min-height: 40px; }

/* ---------- Drag targeting arc & ghost card ----------
   These sit in dedicated top-level fixed layers (siblings of #app, not
   descendants of the scrolling/clipping .hand-row) with very high z-index
   so a dragged card and its arc always paint above everything else in the
   app, including modals. */
.drag-arc-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 900; }
.drag-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 950; }
.drag-ghost-card { position: fixed; margin: 0; pointer-events: none; }

/* ---------- Particle effects (hit impacts, block pulses) ---------- */
.particle-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 850; overflow: visible; }
.particle {
  position: absolute; border-radius: 50%; transform: translate(-50%, -50%);
  animation-name: particle-burst; animation-timing-function: cubic-bezier(.2,.7,.3,1); animation-fill-mode: forwards;
}
@keyframes particle-burst {
  0% { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.15); opacity: 0; }
}
.particle-ring {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; border-radius: 50%;
  border: 3px solid; transform: translate(-50%, -50%) scale(0.3); opacity: 0.9;
  animation: particle-ring-pulse 480ms ease-out forwards;
}
@keyframes particle-ring-pulse {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

/* Comic-panel "POW" starburst — layered under the particle dots for a
   punchier flash right at the moment of impact. */
.impact-star {
  position: absolute; width: 74px; height: 74px;
  background: var(--impact-color, #ffb545);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  mix-blend-mode: screen; opacity: 0;
  animation: impact-pop 0.38s ease-out forwards;
}
@keyframes impact-pop {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); opacity: 1; }
  55% { transform: translate(-50%, -50%) scale(1.15) rotate(4deg); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(1.35) rotate(8deg); opacity: 0; }
}

/* Shield icon that slams in and settles — used for any Block gain, player
   or enemy, alongside the expanding ring. */
.shield-slam {
  position: absolute; width: 58px; height: 58px; color: #7cc3ec;
  filter: drop-shadow(0 0 10px rgba(124,195,236,0.9));
  opacity: 0; animation: shield-slam-in 0.48s cubic-bezier(.2,.9,.3,1) forwards;
}
.shield-slam svg { width: 100%; height: 100%; display: block; }
@keyframes shield-slam-in {
  0% { transform: translate(-50%, -50%) scale(2.4) rotate(-12deg); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(0.85) rotate(3deg); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1.05) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.1) rotate(0deg); opacity: 0; }
}

/* Floating combat text — the clearest possible readout of what an action
   actually did, popping in, rising, and fading. */
.floating-text {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 23px; white-space: nowrap; font-family: Georgia, serif;
  text-shadow: 0 2px 3px rgba(0,0,0,0.85), 0 0 12px currentColor;
  animation: floating-text-rise 0.9s ease-out forwards;
}
@keyframes floating-text-rise {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  18% { transform: translate(-50%, -66%) scale(1.2); opacity: 1; }
  35% { transform: translate(-50%, -78%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -150%) scale(1); opacity: 0; }
}
.text-damage { color: #ff5a46; }
.text-blocked { color: #7cc3ec; font-size: 16px; }
.text-block-gain { color: #7cc3ec; }
.text-heal { color: #6fcf7a; }
@keyframes enemy-hit-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(4px, -3px); }
  60% { transform: translate(-4px, 1px); }
  80% { transform: translate(3px, -1px); }
}
.enemy.hit-flash { animation: enemy-hit-shake 0.28s ease-in-out; }
.enemy.hit-flash .enemy-portrait-img { filter: drop-shadow(0 10px 12px rgba(0,0,0,0.65)) drop-shadow(0 0 18px rgba(224,96,82,0.9)) brightness(1.4); }

@keyframes enemy-attack-lunge {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(22px) scale(1.06); }
  60% { transform: translateY(22px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}
.enemy.enemy-attacking { animation: enemy-attack-lunge 0.36s cubic-bezier(.3,.6,.4,1); z-index: 2; }
.enemy.enemy-attacking .enemy-portrait-img { filter: drop-shadow(0 10px 12px rgba(0,0,0,0.65)) drop-shadow(0 0 14px rgba(240,198,107,0.7)); }

@keyframes combat-screen-hit-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(7px, -5px); }
  45% { transform: translate(-6px, 3px); }
  60% { transform: translate(5px, -3px); }
  75% { transform: translate(-3px, 2px); }
  90% { transform: translate(2px, -1px); }
}
.combat-screen.player-hit { animation: combat-screen-hit-shake 0.32s ease-in-out; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; z-index: 20;
}
.modal-box {
  background: #1a140e; border: 1px solid #5a4a30; border-radius: 10px; padding: 24px;
  max-width: 90vw; max-height: 85vh; overflow-y: auto; text-align: center;
}
