/* Item grades (src/game/rarity.js): white, blue, purple, red, gold. */
:root { --rarity-common: #e6e9ef; --rarity-rare: #4b69ff; --rarity-very-rare: #8847ff; --rarity-mythic: #eb4b4b; --rarity-legendary: #e4ae39; }
/* Feedback overlays (src/fx/fx.js). All pointer-events:none so they can
   never block a tap, and short-lived. */

/* ---- Easy flourish around the Easy button ---- */
.fx-easy-ring {
  position: fixed; z-index: 9000; pointer-events: none; border-radius: 12px;
  box-shadow: 0 0 0 2px #3ddc84, 0 0 18px 4px rgba(61, 220, 132, .7);
  animation: fx-easy-ring .6s ease-out forwards;
}
@keyframes fx-easy-ring {
  0% { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1.25); opacity: 0; }
}
.fx-easy-spark {
  position: fixed; z-index: 9001; pointer-events: none; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px;
  border-radius: 50%; background: #b8ffd6; box-shadow: 0 0 8px 2px #3ddc84;
  animation: fx-easy-spark .6s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes fx-easy-spark {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; }
}

/* ---- XP orbs ---- */
.fx-xp-orb {
  position: fixed; left: 0; top: 0; z-index: 9002; pointer-events: none;
  width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 18%, #7ef9ff 35%, #1fb6ff 70%, rgba(31, 182, 255, 0) 72%);
  box-shadow: 0 0 10px 3px rgba(80, 220, 255, .75);
}

/* ---- XP bar pulse (an orb landed) and shine sweep (bar filling) ---- */
.fx-bar-pulse { animation: fx-bar-pulse .25s ease-out; }
@keyframes fx-bar-pulse {
  0% { filter: brightness(1.8) drop-shadow(0 0 6px #7ef9ff); }
  100% { filter: none; }
}
.fx-bar-shine { animation: fx-bar-shine .7s ease-out; }
@keyframes fx-bar-shine {
  0% { filter: brightness(1.6) saturate(1.4); }
  100% { filter: none; }
}
/* While orbs pour in (fx.js spillDrops): the bar glows and pulses the whole
   time, and still flashes as each orb lands. !important and the doubled
   class beat theme.css's own pulse rules, which load later. */
.fx-bar-charging { animation: fx-bar-charge .5s ease-in-out infinite alternate !important; }
.fx-bar-charging.fx-bar-pulse, .fx-bar-charging.fx-bar-shine {
  animation: fx-bar-charge .5s ease-in-out infinite alternate, fx-bar-pulse .3s ease-out !important;
}
@keyframes fx-bar-charge {
  from { box-shadow: 0 0 4px 1px rgba(126, 249, 255, .35); filter: brightness(1.05); }
  to { box-shadow: 0 0 14px 4px rgba(126, 249, 255, .85), 0 0 26px 8px rgba(80, 220, 255, .35); filter: brightness(1.35) saturate(1.3); }
}
[data-reduced-motion=true] .fx-bar-charging, .study-focus .fx-bar-charging { animation: none !important; box-shadow: 0 0 8px 2px rgba(126, 249, 255, .6); }

/* ---- Level-up banner ---- */
.fx-levelup {
  position: fixed; inset: 0; z-index: 9100; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  animation: fx-levelup-fade 2.2s ease forwards;
}
.fx-levelup-rays {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 214, 102, .35) 0 8deg, rgba(255, 214, 102, 0) 8deg 20deg);
  mask: radial-gradient(circle, #000 20%, transparent 68%);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%);
  animation: fx-levelup-spin 2.2s linear forwards;
}
.fx-levelup-title {
  position: relative; font: 900 44px/1 system-ui, sans-serif; letter-spacing: 2px; color: #ffd166;
  -webkit-text-stroke: 2px #6b3a00; text-shadow: 0 4px 0 #6b3a00, 0 0 24px rgba(255, 209, 102, .8);
  animation: fx-levelup-pop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.fx-levelup-level {
  position: relative; font: 800 22px/1 system-ui, sans-serif; color: #fff; text-shadow: 0 2px 4px #000;
  animation: fx-levelup-pop .5s .12s cubic-bezier(.2, 1.6, .4, 1) both;
}
.fx-levelup-stats {
  position: relative; font: 700 16px/1 system-ui, sans-serif; color: #b8ffd6; text-shadow: 0 2px 4px #000;
  animation: fx-levelup-rise .5s .35s ease-out both; white-space: pre;
}
.fx-levelup.is-calm .fx-levelup-rays { display: none; }
@keyframes fx-levelup-pop { 0% { transform: scale(.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fx-levelup-rise { 0% { transform: translateY(10px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes fx-levelup-spin { 0% { transform: rotate(0) scale(.6); } 100% { transform: rotate(60deg) scale(1.1); } }
@keyframes fx-levelup-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---- Fight HUD strip above the card (EncounterPanel) ---- */
.sheet-hud {
  display: none; align-items: center; gap: 8px; padding: 4px 8px 2px;
  font: 700 11px/1.1 system-ui, sans-serif; flex: none;
}
.encounter-sheet.is-reading .sheet-hud { display: flex; }
.sheet-hud-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet-hud-side.is-mob { text-align: left; }
/* Your own HP is always in the top-left header, so the strip shows only the mob. */
.sheet-hud-side.is-player { display: none; }
.sheet-hud-label { display: flex; justify-content: space-between; gap: 6px; opacity: .85; white-space: nowrap; overflow: hidden; }
.sheet-hud-bar { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .18); overflow: hidden; }
.sheet-hud-fill { height: 100%; border-radius: 3px; transition: width .35s cubic-bezier(.2, .8, .3, 1); }
.sheet-hud-side.is-player .sheet-hud-fill { background: linear-gradient(90deg, #2ecc71, #7bed9f); }
.sheet-hud-side.is-mob .sheet-hud-fill { background: linear-gradient(90deg, #ff6b6b, #e84118); }
.sheet-hud-side.is-mob .sheet-hud-bar { height: 8px; }
.sheet-hud-double {
  flex: none; padding: 2px 5px; border-radius: 6px; font-size: 10px; color: #3a2400;
  background: linear-gradient(180deg, #ffe08a, #ffb627); box-shadow: 0 0 8px rgba(255, 182, 39, .7);
}
.sheet-hud-double[hidden] { display: none; }

/* ---- Practice tab: just the card (full view) and the XP bar ---- */
.view.practice-view.is-active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
/* no HP bars, Flee or drag handle: practice is only cards (!important: the themes force the HUD visible) */
.practice-card :is(.sheet-hud, .sheet-handle) { display: none !important; }
/* the world's bottom bar (active deck and XP), borrowed while practicing (app.js placeProgressBar) */
.practice-view > .world-progress { position: relative; flex: none; --world-progress-height: 46px; height: var(--world-progress-height); }
.practice-card { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.practice-card .encounter-sheet {
  position: absolute !important; inset: 0 !important; height: auto !important; max-height: none !important;
  top: 0 !important; bottom: 0 !important;
}
.practice-empty { padding: 24px 16px; text-align: center; }

/* ---- Loot drop reveal ---- */
.fx-drop {
  position: fixed; left: 0; top: 0; z-index: 9050; pointer-events: none;
  width: 44px; height: 44px; margin: -22px 0 0 -22px; display: grid; place-items: center;
}
.fx-drop img { width: 40px; height: 40px; position: relative; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); }
.fx-drop-beam {
  position: absolute; bottom: 10px; left: 50%; width: 26px; height: 0; margin-left: -13px; border-radius: 13px;
  background: linear-gradient(0deg, var(--rarity), transparent); opacity: .85; transition: height .35s ease-out;
}
.fx-drop.is-revealed .fx-drop-beam { height: 120px; }
.fx-drop.is-very-rare.is-revealed .fx-drop-beam, .fx-drop.is-mythic.is-revealed .fx-drop-beam, .fx-drop.is-legendary.is-revealed .fx-drop-beam {
  height: 190px; box-shadow: 0 0 30px 8px var(--rarity);
}
.fx-drop-name {
  position: absolute; top: 46px; white-space: nowrap; font: 800 12px/1 system-ui, sans-serif;
  color: var(--rarity); text-shadow: 0 1px 2px #000, 0 0 6px #000; opacity: 0; transition: opacity .2s;
}
.fx-drop.is-revealed .fx-drop-name { opacity: 1; }
.fx-material {
  position: fixed; z-index: 9040; pointer-events: none; transform: translateX(-50%);
  font: 800 12px/1 system-ui, sans-serif; color: #f1d991; text-shadow: 0 1px 2px #000;
  animation: fx-material 1.4s ease-out forwards;
}
@keyframes fx-material { 0% { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px); } }

/* ---- Chest button + roulette ---- */
.chest-button {
  position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: min(calc(var(--nav-h, 64px) + 60px), calc(100dvh - 70px)); z-index: 800;
  width: 54px; height: 54px; border-radius: 14px; border: 2px solid #6b3a00;
  background: linear-gradient(180deg, #ffd166, #e09b1f); box-shadow: 0 4px 0 #6b3a00, 0 0 16px rgba(255, 209, 102, .7);
  font-size: 26px; cursor: pointer; animation: chest-bob 1.6s ease-in-out infinite;
}
.chest-button[hidden] { display: none; }
.chest-button-count {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #d1453b; color: #fff; font: 800 12px/20px system-ui, sans-serif;
}
body.in-combat .chest-button { display: none; }
@keyframes chest-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px) rotate(-3deg); } }

.roulette {
  position: fixed; inset: 0; z-index: 9200; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; max-height: 100dvh; overflow: hidden; box-sizing: border-box; padding: 12px; background: rgba(10, 14, 24, .82);
}
.roulette-title { font: 900 26px/1 system-ui, sans-serif; color: #ffd166; -webkit-text-stroke: 1px #6b3a00; text-shadow: 0 3px 0 #6b3a00; }
.roulette-window {
  position: relative; width: min(92vw, 520px); height: 104px; overflow: hidden; border-radius: 14px;
  background: #1d2230; border: 3px solid #ffd166; box-shadow: 0 0 30px rgba(255, 209, 102, .35) inset;
}
.roulette-strip { position: absolute; top: 10px; left: 0; display: flex; gap: 8px; will-change: transform; }
.roulette-marker {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; background: #ffd166; z-index: 2;
  box-shadow: 0 0 10px #ffd166;
}
.roulette-tile {
  flex: none; width: 76px; height: 84px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; background: #2b3246; border-bottom: 5px solid var(--rarity, #b8bcc6);
  font: 800 12px/1.1 system-ui, sans-serif; color: #fff;
}
.roulette-tile img { width: 40px; height: 40px; }
.roulette-tile-icon { font-size: 30px; line-height: 40px; }
.roulette-tile.is-item { background: linear-gradient(180deg, #2b3246 55%, color-mix(in srgb, var(--rarity, #b8bcc6) 35%, #2b3246)); }
.roulette-tile.is-item img { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.roulette-tile-name { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.roulette-tile.is-win { animation: roulette-win .6s cubic-bezier(.2, 1.6, .4, 1) forwards; box-shadow: 0 0 24px 6px var(--rarity, #ffd166); }
@keyframes roulette-win { 0% { transform: scale(1); } 50% { transform: scale(1.25); } 100% { transform: scale(1.12); } }
.roulette-prize { min-height: 22px; font: 800 18px/1.2 system-ui, sans-serif; color: #fff; text-align: center; }
.roulette-hint { font: 600 12px/1 system-ui, sans-serif; color: #aab; }

/* ---- Inventory rarity ---- */
.inventory-item[data-rarity] { border-left: 4px solid var(--rarity, transparent); }
.item-rarity { font-weight: 800; color: var(--rarity); }

/* ---- Fight entrance/exit: the card sheet slides instead of popping ---- */
.encounter-sheet.is-entering { animation: sheet-enter .4s cubic-bezier(.16, 1, .3, 1) both; }
@keyframes sheet-enter { from { transform: translateY(105%); } to { transform: none; } }
.encounter-sheet.is-entering .sheet-content,
.encounter-sheet.is-entering .sheet-hud { animation: sheet-content-in .28s .12s ease-out both; }
@keyframes sheet-content-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.encounter-sheet.is-leaving { animation: sheet-leave .22s cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes sheet-leave { to { transform: translateY(105%); } }
@media (prefers-reduced-motion: reduce) {
  .encounter-sheet.is-entering, .encounter-sheet.is-leaving,
  .encounter-sheet.is-entering .sheet-content, .encounter-sheet.is-entering .sheet-hud { animation-duration: .01s; }
}

/* ---- Daily: streak badge, toast, mastered pop ---- */
.streak-badge {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 1px 6px; border-radius: 9px;
  font: 800 11px/16px system-ui, sans-serif; color: #fff; background: linear-gradient(180deg, #ff9f43, #e8590c);
  box-shadow: 0 0 8px rgba(255, 140, 26, .6);
}
.streak-badge[hidden] { display: none; }
.streak-badge.is-bumped { animation: streak-bump .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes streak-bump { 0% { transform: scale(1); } 40% { transform: scale(1.6); } 100% { transform: scale(1); } }
.fx-toast {
  position: fixed; top: 64px; left: 50%; z-index: 9150; pointer-events: none; transform: translateX(-50%);
  min-width: 220px; padding: 10px 16px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, #2b3246, #1d2230); border: 2px solid #ffd166; color: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45); animation: fx-toast 2.8s ease forwards;
}
.fx-toast-title { font: 900 16px/1.2 system-ui, sans-serif; color: #ffd166; }
.fx-toast-detail { margin-top: 2px; font: 600 12px/1.3 system-ui, sans-serif; color: #dde; }
@keyframes fx-toast {
  0% { opacity: 0; transform: translate(-50%, -14px) scale(.9); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  16% { transform: translate(-50%, 0) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}
.fx-mastered {
  position: fixed; z-index: 9060; pointer-events: none; transform: translateX(-100%);
  padding: 3px 8px; border-radius: 10px; font: 800 12px/1.2 system-ui, sans-serif; color: #062c3a;
  background: linear-gradient(180deg, #b8f3ff, #56c8ff); box-shadow: 0 0 12px rgba(86, 200, 255, .8);
  animation: fx-mastered 1.6s ease-out forwards;
}
@keyframes fx-mastered {
  0% { opacity: 0; transform: translate(-100%, 6px) scale(.7); }
  15% { opacity: 1; transform: translate(-100%, 0) scale(1.1); }
  25% { transform: translate(-100%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-100%, -16px); }
}

/* Chat would sit on top of the small fight view; hide it during fights. */
body.in-combat .chat-log, body.in-combat .chat-input { display: none !important; }

/* ---- Fight start: crossed swords flash ---- */
.fx-engage {
  position: fixed; z-index: 9050; pointer-events: none; transform: translate(-50%, -50%);
  font-size: 64px; filter: drop-shadow(0 0 12px rgba(255, 255, 255, .9)) drop-shadow(0 3px 0 rgba(0, 0, 0, .6));
  animation: fx-engage .7s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes fx-engage {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-25deg); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.15) rotate(0); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}
.tutorial-name-input { flex: 1 1 140px; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .25); font: inherit; }

/* While a card is up: the joystick/A/B move nothing and sat over the card;
   the pomodoro timer shrinks into the top-right corner so the mob's HP
   strip stays readable. */
body.in-combat.sheet-reading-card .world-controls { display: none !important; }
body.in-combat .pomodoro-pill { left: auto !important; right: 6px !important; transform: scale(.72) !important; transform-origin: top right; opacity: .85; }

/* Level Up screen (src/fx/level-up-screen.js): a transparent full-screen frame over
   the game, above every other effect layer (9000-9200). color-scheme normal matches
   the embedded page so it stays transparent. */
.fx-levelup-frame { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; z-index: 9500;
  background: transparent; color-scheme: normal; }
.fx-levelup-frame[hidden] { display: none; }

/* ---- Small notes (fx.note): a quiet line near the bottom, e.g. materials ---- */
.fx-notes {
  position: fixed; left: 50%; bottom: 172px; z-index: 9050; transform: translateX(-50%); /* above the chat box and the bottom bars */
  display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; pointer-events: none;
}
.fx-note {
  padding: 3px 10px; border-radius: 999px;
  background: rgba(20, 18, 14, .62); color: #efe6cf;
  font: 600 12px/1.4 var(--font-ui, system-ui, sans-serif);
  animation: fx-note 2.8s ease forwards;
}
@keyframes fx-note { 0% { opacity: 0; transform: translateY(6px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
[data-reduced-motion=true] .fx-note { animation: none; } /* shown, then removed after 2.8 s (fx.note) */
