/* Motion and feedback: loading screen, banners, menu animations, music chip.
   Kept apart from style.css so layout and animation can be read separately. */

/* ---------- loading screen ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1c2a18 0%, #050705 75%); cursor: pointer;
  transition: opacity .4s ease, transform .4s ease;
}
#splash.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 16px; text-align: center; }
.splash-sigil { width: 64px; height: 64px; image-rendering: pixelated; filter: drop-shadow(0 0 12px #c9b27a88); animation: sigil 2.3s ease-out both; }
@keyframes sigil { 0% { opacity: 0; transform: translateY(-20px) scale(.6); } 25% { opacity: 1; transform: none; } 100% { transform: translateY(-2px); } }
.splash-title { font-family: var(--pixel); color: var(--gold-hi); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.splash-name {
  font-size: clamp(14px, 4.2vw, 34px); white-space: nowrap; overflow: hidden; display: inline-block; width: 0;
  text-shadow: 3px 3px 0 #000, 0 0 18px #c9b27a66; border-right: .5em solid transparent;
  animation: type 1s steps(14, end) .25s forwards, caret .35s step-end 6;
}
@keyframes type { to { width: 14.5ch; } }
@keyframes caret { 50% { border-right-color: var(--gold-hi); } }
.splash-games { font-size: clamp(10px, 2.4vw, 18px); letter-spacing: .9em; padding-left: .9em; color: var(--gold); opacity: 0; animation: games .5s ease-out 1.3s forwards; }
@keyframes games { from { opacity: 0; letter-spacing: 2em; } to { opacity: 1; letter-spacing: .9em; } }
.splash-bar { width: min(260px, 70vw); height: 8px; border: 2px solid var(--gold); background: #000; box-shadow: 0 0 0 2px #000; }
.splash-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a6d2e, var(--gold-hi)); animation: load 2s cubic-bezier(.3, .1, .3, 1) .1s forwards; }
@keyframes load { to { width: 100%; } }
.splash-skip { font-size: 16px; color: var(--muted); opacity: 0; animation: games .4s 1.6s forwards; }

/* ---------- floating spores on the menus ---------- */
#spores { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #e8d88a, transparent), radial-gradient(2px 2px at 30% 80%, #c9b27a, transparent),
    radial-gradient(3px 3px at 55% 35%, #9be36f88, transparent), radial-gradient(2px 2px at 75% 65%, #e8d88a, transparent),
    radial-gradient(2px 2px at 90% 15%, #c9b27a, transparent), radial-gradient(3px 3px at 20% 55%, #9be36f66, transparent),
    radial-gradient(2px 2px at 65% 90%, #e8d88a, transparent), radial-gradient(2px 2px at 45% 5%, #c9b27a, transparent);
  background-size: 600px 500px; animation: drift 40s linear infinite; }
@keyframes drift { from { background-position: 0 0; } to { background-position: 600px -1000px; } }
body:has(#view-battle.active) #spores { display: none; }
.view { position: relative; z-index: 1; }

/* ---------- home ---------- */
.logo { background: linear-gradient(100deg, var(--gold-hi) 40%, #fff8dc 50%, var(--gold-hi) 60%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: none; filter: drop-shadow(4px 4px 0 #000); animation: logo-in .6s cubic-bezier(.2, 1.4, .4, 1) both, shimmer 5s linear 1s infinite; }
.logo span { -webkit-text-fill-color: var(--muted); }
@keyframes logo-in { from { opacity: 0; transform: translateY(-24px) scale(.9); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.home-grid > .window { animation: rise .45s cubic-bezier(.2, 1.2, .4, 1) both; transition: transform .15s, box-shadow .15s; }
.home-grid > .window:nth-child(2) { animation-delay: .08s; }
.home-grid > .window:nth-child(3) { animation-delay: .16s; }
@media (hover: hover) { .home-grid > .window:hover { transform: translateY(-3px); box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #0006, 0 10px 24px #000c, 0 0 18px #c9b27a33; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* ---------- buttons and menus ---------- */
.btn { transition: transform .08s, background .12s, box-shadow .12s, filter .12s; }
@media (hover: hover) { .btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 0 #000, 0 0 10px #c9b27a55; } }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.97); box-shadow: none; filter: brightness(1.2); }
.btn.primary:not(:disabled) { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 2px 0 #000, 0 0 14px #f0dca066; } }
.cmd { transition: background .1s, padding-left .1s; }
.cmd.on { padding-left: 22px; }
.cmd.on::before { animation: cursor .5s ease-in-out infinite alternate; }
@media (hover: hover) {
  .cmd:hover:not(:disabled) { padding-left: 22px; }
  .cmd:hover::before { animation: cursor .5s ease-in-out infinite alternate; }
}
@keyframes cursor { from { transform: translateX(-2px); } to { transform: translateX(2px); } }
.cmd-list > .cmd, .cmd-cats > .cmd, .cmd-tabs > .cmd, .targeting > *, .prompt-box .opts > .btn { animation: item-in .2s ease-out both; }
.cmd-list > .cmd:nth-child(2), .prompt-box .opts > .btn:nth-child(2) { animation-delay: .02s; }
.cmd-list > .cmd:nth-child(3), .prompt-box .opts > .btn:nth-child(3) { animation-delay: .04s; }
.cmd-list > .cmd:nth-child(4), .prompt-box .opts > .btn:nth-child(4) { animation-delay: .06s; }
.cmd-list > .cmd:nth-child(5) { animation-delay: .08s; }
.cmd-list > .cmd:nth-child(6) { animation-delay: .1s; }
.cmd-list > .cmd:nth-child(n+7) { animation-delay: .12s; }
@keyframes item-in { from { opacity: 0; transform: translateX(-8px); } }
.turn-pips .pip { transition: color .2s, border-color .2s; }
.turn-pips .pip.on { box-shadow: 0 0 6px #7fd36a55; }

/* windows that open */
.modal:not(.hidden) { animation: fade-in .15s ease-out; }
.modal:not(.hidden) .modal-box { animation: pop .22s cubic-bezier(.2, 1.4, .4, 1); }
.drawer:not(.hidden) { animation: slide-in .22s cubic-bezier(.2, 1, .3, 1); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(100%); } }
.toast { animation: toast-in .25s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } }

/* ---------- battle panels ---------- */
.hpbar i { transition: width .45s cubic-bezier(.2, 1, .3, 1); }
.order-win li { transition: background .2s, transform .2s; }
@media (hover: hover) { .order-win li:hover { background: #ffffff0d; } }
.order-win li.cur { animation: cur-pulse 1.4s ease-in-out infinite; transform: translateX(4px); }
@keyframes cur-pulse { 50% { background: #c9b27a55; box-shadow: 0 0 10px #c9b27a44; } }
#log > div:last-child { animation: log-in .3s ease-out; }
@keyframes log-in { from { opacity: 0; transform: translateY(4px); background: #c9b27a22; } }
#log .k-round { animation: none; }

/* board shake on heavy blows */
#board.shake { animation: shake .25s linear; }
#board.shake-big { animation: shake-big .4s linear; }
@keyframes shake { 20% { transform: translate(-3px, 1px); } 40% { transform: translate(3px, -1px); } 60% { transform: translate(-2px, 2px); } 80% { transform: translate(2px, 0); } }
@keyframes shake-big { 10% { transform: translate(-7px, 3px); } 25% { transform: translate(6px, -4px); } 40% { transform: translate(-5px, 2px); } 55% { transform: translate(4px, 3px); } 70% { transform: translate(-3px, -2px); } 85% { transform: translate(2px, 1px); } }

/* dice popup: tumbles, then lands */
.dice-pop .die { display: inline-block; min-width: 2ch; text-align: center; }
.dice-pop.rolling .die { animation: tumble .09s linear infinite; color: var(--gold-hi); }
.dice-pop.landed { animation: land .25s cubic-bezier(.2, 1.6, .4, 1); }
.dice-pop.landed.ok .die { color: var(--good); }
.dice-pop.landed.fail .die { color: var(--bad); }
.dice-pop.crit { box-shadow: 0 0 22px var(--gold-hi); }
@keyframes tumble { 50% { transform: rotate(14deg) scale(1.15); } }
@keyframes land { from { transform: scale(1.35); } }

/* "ROUND 2", "YOUR TURN!" banners */
.banner { position: fixed; left: 0; right: 0; top: 34%; z-index: 44; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 0; background: linear-gradient(90deg, transparent, #000c 20%, #000c 80%, transparent); opacity: 0; transform: scaleY(0); }
.banner span { font-family: var(--pixel); font-size: clamp(14px, 3vw, 26px); color: var(--gold-hi); text-shadow: 3px 3px 0 #000; }
.banner small { font-size: 18px; color: var(--muted); }
.banner.show { animation: banner 0.85s cubic-bezier(.2, 1, .3, 1) forwards; }
.banner.big.show { animation-duration: 1.1s; }
.banner:not(.big):not(.mine) { top: 12%; padding: 6px 0; }
.banner.big span { font-size: clamp(22px, 5vw, 44px); letter-spacing: 4px; }
.banner.fight span { color: #ff8a6a; }
.banner.mine span { color: #fff2b0; }
.banner.party span { color: var(--party); } .banner.enemy span { color: var(--enemy); } .banner.neutral span { color: var(--neutral); }
.banner.show span { animation: banner-text 0.85s cubic-bezier(.2, 1, .3, 1); }
.banner.mine.show span { animation: banner-text 0.85s cubic-bezier(.2, 1, .3, 1), mine .2s ease-in-out .2s 2 alternate; }
@keyframes banner { 0% { opacity: 0; transform: scaleY(0); } 15% { opacity: 1; transform: scaleY(1); } 80% { opacity: 1; transform: scaleY(1); } 100% { opacity: 0; transform: scaleY(.2); } }
@keyframes banner-text { 0% { transform: translateX(-40vw); } 20% { transform: translateX(0); } 80% { transform: translateX(0); } 100% { transform: translateX(40vw); } }
@keyframes mine { to { transform: scale(1.12); } }

/* ---------- music ---------- */
.music-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; }
.music-chip #music-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-chip.blocked { animation: glow 1s ease-in-out infinite; border-color: var(--gold-hi); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 10px; }
.eq i { width: 3px; height: 3px; background: var(--gold-hi); }
.playing .eq i, .now-playing.on .eq i { animation: eq .6s ease-in-out infinite alternate; }
.playing .eq i:nth-child(2), .now-playing.on .eq i:nth-child(2) { animation-delay: .2s; }
.playing .eq i:nth-child(3), .now-playing.on .eq i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { from { height: 2px; } to { height: 10px; } }
.sound-panel { display: flex; flex-direction: column; gap: 8px; }
.now-playing { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #0008; border: 1px solid #5a5236; border-radius: 4px; }
.now-playing.on { border-color: var(--gold); }
.np-name { flex: 1; font-size: 22px; color: var(--gold-hi); }
.vol input[type=range] { accent-color: var(--gold); padding: 0; border: 0; background: none; }
.tracks { display: flex; flex-direction: column; gap: 4px; max-height: 45vh; overflow: auto; min-height: 60px; border: 1px dashed #5a5236; border-radius: 4px; padding: 6px; }
.track { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 3px; transition: background .12s; }
@media (hover: hover) { .track:hover { background: #c9b27a1a; } }
.track.on { background: #c9b27a33; outline: 1px solid var(--gold); }
.track-play { font-size: 16px; width: 30px; height: 30px; border: 2px solid var(--gold); background: #0008; color: var(--gold-hi); border-radius: 50%; cursor: pointer; flex: none; }
.track.on .track-play { animation: glow 1.2s infinite; }
.track-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.drop-hint { text-align: center; margin: 14px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .splash-name { width: 14.5ch; }
}
