/* All battle overrides are scoped to maze room IDs. Cards are already maze-only components. */
[id^="room-battle-gen9cherishmaze-"] {
  --maze-ink: #ece9fa; --maze-muted: #b9b5cf; --maze-edge: #a8a1ca38;
  background: #101221 url('/cherish/ui/maze-battle-atmosphere-v1.webp?v=1') center top / cover !important;
}
[id^="room-battle-gen9cherishmaze-"] .cw-bshell {
  background: linear-gradient(180deg, #0c10232e, #0c1023bd 66%, #0c1023f2) !important;
  color: var(--maze-ink); min-height: 100%; isolation: isolate;
}
[id^="room-battle-gen9cherishmaze-"] .cw-bfield {
  border: 1px solid #aba4d74d; border-radius: 20px; overflow: hidden;
  box-shadow: 0 22px 70px #05071270; margin-top: 22px;
}
[id^="room-battle-gen9cherishmaze-"] .battle .backdrop {
  background-image: url('/cherish/ui/maze-battle-atmosphere-v1.webp?v=1') !important;
  background-size: cover !important; background-position: center 20% !important;
}
[id^="room-battle-gen9cherishmaze-"] .cw-bpanel {
  background: #131628ed !important; color: var(--maze-ink) !important;
  border: 1px solid var(--maze-edge) !important; border-radius: 18px !important;
  box-shadow: 0 18px 56px #03061166; margin-top: 16px;
}
[id^="room-battle-gen9cherishmaze-"] .controls,
[id^="room-battle-gen9cherishmaze-"] .cw-bbar,
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze {
  background: transparent !important; color: var(--maze-ink) !important;
}
[id^="room-battle-gen9cherishmaze-"] .cw-bbar { border-bottom: 1px solid var(--maze-edge); }
[id^="room-battle-gen9cherishmaze-"] .cw-bbar button,
[id^="room-battle-gen9cherishmaze-"] .controls .button {
  color: #edeafa; background: #262b43; border-color: #77739970; text-shadow: none;
}
[id^="room-battle-gen9cherishmaze-"] .cw-bbar-stage { color: #dfd6ff; letter-spacing: .04em; }
[id^="room-battle-gen9cherishmaze-"] .movemenu .movebutton { border-radius: 12px; box-shadow: none; }
[id^="room-battle-gen9cherishmaze-"] .switchmenu button { border-radius: 10px; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-mon,
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-hp,
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-q,
[id^="room-battle-gen9cherishmaze-"] .cw-end-note { color: #d2cce6; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-team { background: #ffffff05; border-color: var(--maze-edge); }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-team li { border-color: #ffffff0c; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-bar { background: #ffffff12; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-bar i { background: #b2d8c2; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-depth { color: #e4def7; padding: 20px 0 12px; letter-spacing: .03em; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-depth b { font-size: 28px; font-weight: 600; }
[id^="room-battle-gen9cherishmaze-"] .cw-end-maze-got { background: #b8a6ed12; border: 1px solid #b8a6ed30; color: #e2d8ff; border-radius: 12px; }
.cw-maze-cardrow, .cw-end-maze-row { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px !important; align-items: stretch; }
.cw-maze-card[data-maze-kind], .cw-end-maze-card[data-maze-kind] {
  --card-color: #d0bdf5; position: relative; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-end; gap: 6px;
  box-sizing: border-box; min-width: 0; width: 100%; min-height: 160px; padding: 48px 12px 12px !important; overflow: hidden;
  text-align: left; border: 1px solid #b7acd74d !important; border-radius: 15px !important;
  background: linear-gradient(180deg, #14182755, #17182aed 63%), url('/cherish/ui/maze-battle-atmosphere-v1.webp?v=1') center / cover !important;
  color: #f1eaff !important; box-shadow: 0 12px 32px #090b242e !important;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
  animation: maze-card-in .55s both; cursor: pointer; font-family: inherit;
}
.cw-maze-card[data-maze-kind]::before, .cw-end-maze-card[data-maze-kind]::before {
  content: '✦'; position: absolute; left: 12px; top: 10px; display: grid; place-items: center;
  width: 28px; height: 28px; margin: 0; border-radius: 50%;
  border: 1px solid #ffffff25; color: var(--card-color); font-size: 20px; background: #10122577;
}
[data-maze-kind="heal"] { --card-color: #b1e6ce !important; }
[data-maze-kind="heal"]::before { content: '+' !important; }
[data-maze-kind="revive"] { --card-color: #e9dbb4 !important; }
[data-maze-kind="revive"]::before { content: '↑' !important; }
[data-maze-kind="boost_gamble"] { --card-color: #ecb2c9 !important; }
[data-maze-kind="boost_gamble"]::before { content: '±' !important; }
[data-maze-kind="boost_pick_stat"]::before, [data-maze-kind="boost_random_stat"]::before { content: '↗' !important; }
.cw-maze-card[data-maze-kind] b, .cw-end-maze-card[data-maze-kind] b {
  color: #f4f0ff !important; font-size: 14px !important; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere;
}
.cw-maze-card[data-maze-kind] small, .cw-end-maze-card[data-maze-kind] small {
  color: #c0bbd4 !important; font-size: 12px !important; line-height: 1.45; white-space: normal; overflow-wrap: anywhere;
}
.cw-maze-card[data-maze-kind]:nth-child(2), .cw-end-maze-card[data-maze-kind]:nth-child(2) { animation-delay: .07s; }
.cw-maze-card[data-maze-kind]:nth-child(3), .cw-end-maze-card[data-maze-kind]:nth-child(3) { animation-delay: .14s; }
.cw-maze-card[data-maze-kind]:hover:not(:disabled), .cw-end-maze-card[data-maze-kind]:hover:not(:disabled) {
  transform: translateY(-5px); border-color: var(--card-color) !important; box-shadow: 0 18px 40px #05071d66 !important;
}
.cw-maze-card[data-maze-kind]:active:not(:disabled), .cw-end-maze-card[data-maze-kind]:active:not(:disabled) { transform: translateY(-1px) scale(.985); }
.cw-maze-card[data-maze-kind]:focus-visible, .cw-end-maze-card[data-maze-kind]:focus-visible,
.cw-maze-reveal button:focus-visible { outline: 2px solid #e1d4ff; outline-offset: 4px; }
.cw-maze-card[data-maze-kind]:disabled, .cw-end-maze-card[data-maze-kind]:disabled { cursor: wait; opacity: .55; }
.cw-maze-entry { position: absolute; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; background: #0e1125e6; color: #f1eafa; animation: maze-enter 1.8s both; }
.cw-maze-entry span { font-size: clamp(24px, 5vw, 48px); letter-spacing: .22em; font-weight: 300; }
.cw-maze-entry small { margin-top: 20px; letter-spacing: .15em; color: #c1b7d8; }
.cw-maze-reveal { box-sizing: border-box; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); padding: 30px;
  border: 1px solid #b7acd76b; border-radius: 24px; background: #141627 url('/cherish/ui/maze-battle-atmosphere-v1.webp?v=1') center / cover;
  color: #f1eaff; box-shadow: 0 30px 120px #0009; font-family: Pretendard, 'Malgun Gothic', sans-serif; overflow-y: auto; }
.cw-maze-reveal::backdrop { background: #070918c9; backdrop-filter: blur(8px); }
.cw-maze-reveal[open] { animation: maze-card-in .35s both; }
.cw-maze-reveal-head { text-align: center; margin-bottom: 25px; }
.cw-maze-eyebrow { font-size: 11px; letter-spacing: .16em; color: #c3b7df; }
.cw-maze-reveal h2 { margin: 12px 0 8px; font-size: 28px; font-weight: 500; }
.cw-maze-reveal-head p { font-size: 13px; color: #bfb7d0; }
.cw-maze-result-list { display: grid; gap: 12px; }
.cw-maze-result { display: flex; align-items: center; gap: 18px; min-height: 122px; padding: 18px;
  border: 1px solid #c5b5ef40; border-radius: 16px; background: #1c2035f2; opacity: 0; transform: translateY(12px);
  transition: opacity .4s, transform .4s; }
.cw-maze-result.is-revealed { opacity: 1; transform: none; }
.cw-maze-result.is-loss { border-color: #da98af55; background: #2b1b2bf2; }
.cw-maze-result-portrait { flex: 0 0 66px; height: 66px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #ccbaf235; color: #cdbaf2; font-size: 30px; }
.cw-maze-result-portrait img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.cw-maze-result-copy { min-width: 0; }
.cw-maze-result-label { font-size: 10px; color: #bfb0e4; letter-spacing: .08em; }
.cw-maze-result h3 { font-size: 15px; line-height: 1.5; margin: 6px 0; overflow-wrap: anywhere; }
.cw-maze-result-stat { margin: 5px 0; font-size: 25px; color: #ded0ff; opacity: 0; transform: translateY(6px); transition: .35s; }
.cw-maze-result.is-complete .cw-maze-result-stat { opacity: 1; transform: none; }
.cw-maze-result-copy small { opacity: 0; transition: opacity .35s; }
.cw-maze-result.is-complete .cw-maze-result-copy small { opacity: 1; }
.cw-maze-result small { color: #b6b0c6; font-size: 11px; }
.cw-maze-result.is-loss .cw-maze-result-stat, .cw-maze-result.is-loss .cw-maze-result-label { color: #efb2c9; }
.cw-maze-restored { text-align: center; padding: 32px 20px; background: #172b29ed; color: #c5e9d8; border: 1px solid #b0dcc344; border-radius: 16px; line-height: 1.8; }
.cw-maze-reveal-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.cw-maze-reveal button { font: inherit; font-size: 13px; padding: 12px 23px; min-height: 44px; border-radius: 10px; cursor: pointer; }
.cw-maze-continue { background: #d6c8f2; color: #231b37; border: 1px solid #d6c8f2; }
.cw-maze-skip { color: #c6bbd9; background: #16182b; border: 1px solid #b9a6e044; }
.cw-maze-sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
@keyframes maze-card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes maze-enter { 0% { opacity: 0; } 20%, 55% { opacity: 1; } 100% { opacity: 0; } }
@media (max-width: 600px) {
  [id^="room-battle-gen9cherishmaze-"] .cw-bfield { margin-top: 10px; border-radius: 12px; }
  .cw-maze-cardrow, .cw-end-maze-row { grid-template-columns: 1fr !important; gap: 6px !important; }
  .cw-maze-card[data-maze-kind], .cw-end-maze-card[data-maze-kind] { justify-content: center; }
  .cw-maze-reveal { padding: 24px 18px; }
  .cw-maze-result { gap: 12px; padding: 14px; }
  .cw-maze-result-portrait { flex-basis: 52px; height: 52px; }
  .cw-maze-result-portrait img { width: 50px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .cw-maze-entry { display: none; }
  .cw-maze-card[data-maze-kind], .cw-end-maze-card[data-maze-kind], .cw-maze-reveal,
  .cw-maze-result, .cw-maze-result-stat { animation: none !important; transition: none !important; }
}

[id^="room-battle-gen9cherishmaze-"] .cw-end { background: transparent !important; color: #eee8fa; border-color: #b7acd738; }
[id^="room-battle-gen9cherishmaze-"] .cw-end .cw-end-hero { background: #15182c99 !important; color: #ede6fc; }
[id^="room-battle-gen9cherishmaze-"] .cw-end .cw-end-hero::before { display: none; }
[id^="room-battle-gen9cherishmaze-"] .whatdo, [id^="room-battle-gen9cherishmaze-"] .whatdo em { color: #e4ddf5 !important; }

/* Illustrated card families; rules stay in text, artwork supplies the silhouette. */
.cw-maze-card[data-maze-kind], .cw-end-maze-card[data-maze-kind] {
  --maze-art: url('/cherish/ui/maze-card-growth-v2.webp');
  background: linear-gradient(180deg, #10142608 10%, #131628bb 48%, #131628fa 73%), var(--maze-art) center top / cover !important;
  min-height: 160px;
}
[data-maze-kind="heal"] { --maze-art: url('/cherish/ui/maze-card-heal-v2.webp') !important; }
[data-maze-kind="revive"] { --maze-art: url('/cherish/ui/maze-card-revive-v2.webp') !important; }
[data-maze-kind="boost_gamble"] { --maze-art: url('/cherish/ui/maze-card-gamble-v2.webp') !important; border-radius: 5px 22px 5px 22px !important; }
[data-maze-kind="boost_pick_stat"]::before { border-radius: 9px !important; }
[data-maze-kind="boost_random_stat"]::before { border-style: dashed !important; }
[data-maze-kind="boost_pick_random"]::before { content: '✧' !important; }
[data-maze-kind="boost_random"]::before { content: '⁂' !important; border-style: dashed !important; }
[data-maze-stat="atk"]::before { content: '⚔' !important; }
[data-maze-stat="def"]::before { content: '⬡' !important; }
[data-maze-stat="spa"]::before { content: '✦' !important; }
[data-maze-stat="spd"]::before { content: '◈' !important; }
[data-maze-stat="spe"]::before { content: '➶' !important; }
.cw-maze-reveal { transition: border-color .6s, box-shadow .6s; }
.cw-maze-reveal.is-price { border-color: #e2a2c2aa; box-shadow: 0 30px 120px #180817bb; }
.cw-maze-reveal[data-kind="heal"] { background-image: linear-gradient(#101b2680, #101b26e8), url('/cherish/ui/maze-card-heal-v2.webp'); }
.cw-maze-reveal[data-kind="revive"] { background-image: linear-gradient(#171b2680, #171b26e8), url('/cherish/ui/maze-card-revive-v2.webp'); }
.cw-maze-reveal[data-kind="boost_gamble"] { background-image: linear-gradient(#18142680, #181426ed), url('/cherish/ui/maze-card-gamble-v2.webp'); }
.cw-maze-phase { min-height: 38px; line-height: 1.6; }
.cw-maze-health-result { background: #122726ed; border: 1px solid #adcfc344; border-radius: 12px; padding: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cw-maze-health-result strong { flex: 1; font-size: 14px; }
.cw-maze-health-result span { font-size: 12px; color: #bfdccd; }
.cw-maze-health-track { width: 100%; height: 7px; border-radius: 5px; background: #ffffff16; overflow: hidden; }
.cw-maze-health-track i { display: block; height: 100%; background: #b0dcc4; border-radius: inherit; }
.cw-maze-team li, .cw-end-maze-team li { position: relative; flex-wrap: wrap; }
.cw-maze-applied { flex: 0 0 100%; box-sizing: border-box; padding: 8px 12px; margin-top: 8px; border-radius: 8px; background: #bda5f019; color: #e3d5fa; font-size: 12px; line-height: 1.6; animation: maze-card-in .4s both; }
[id^="room-battle-gen9cherishmaze-"] .cw-bfield { position: relative; }
[id^="room-battle-gen9cherishmaze-"] .cw-bfield::after {
  content: ''; position: absolute; inset: 0 -15%; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 20% 90%, #c6c5ef24, transparent 38%), radial-gradient(ellipse at 80% 70%, #b9b2d419, transparent 35%);
  animation: maze-mist 18s ease-in-out infinite alternate;
}
[id^="room-battle-gen9cherishmaze-"] .battle .backdrop::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 18% 4% at 28% 87%, #0c102178 35%, #a6a1bd28 67%, transparent 73%), radial-gradient(ellipse 14% 3% at 72% 47%, #0c102166 35%, #a6a1bd24 67%, transparent 73%);
}
@keyframes maze-mist { from { transform: translateX(-5%); opacity: .45; } to { transform: translateX(5%); opacity: .9; } }
@media (max-width: 600px) {
  .cw-maze-card[data-maze-kind], .cw-end-maze-card[data-maze-kind] {
    min-height: 88px; padding: 10px 12px 10px 76px !important;
    background: linear-gradient(90deg, #13162800, #13162888 16%, #131628fa 30%), var(--maze-art) left center / 100px 100px no-repeat, #131628 !important;
  }
  .cw-maze-card[data-maze-kind]::before, .cw-end-maze-card[data-maze-kind]::before { left: 16px; top: 50%; transform: translateY(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  [id^="room-battle-gen9cherishmaze-"] .cw-bfield::after { animation: none; opacity: .4; }
  .cw-maze-applied { animation: none; }
}
