:root {
    color-scheme: dark;
    --bg: #08111f;
    --bg-2: #0f172a;
    --panel: rgba(15, 23, 42, 0.84);
    --panel-strong: rgba(17, 24, 39, 0.96);
    --line: rgba(148, 163, 184, 0.22);
    --text: #ecfeff;
    --muted: #a5b4fc;
    --soft: #94a3b8;
    --accent: #22d3ee;
    --accent-2: #a3e635;
    --danger: #fb7185;
    --gold: #facc15;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at 20% 0%, rgba(34, 211, 238, 0.18), transparent 34rem),
        radial-gradient(circle at 88% 16%, rgba(163, 230, 53, 0.14), transparent 28rem),
        linear-gradient(160deg, #020617 0%, #08111f 44%, #111827 100%);
}

body {
    min-height: 100%;
    margin: 0;
    color: var(--text);
    overflow-x: hidden;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 78%);
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.35);
    opacity: 0.48;
}

.app-shell {
    width: min(100%, 920px);
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) 14px max(96px, env(safe-area-inset-bottom));
}

.topbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid rgba(34, 211, 238, 0.42);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(34, 211, 238, 0.2), rgba(163, 230, 53, 0.15));
    box-shadow: inset 0 0 24px rgba(34, 211, 238, 0.16), 0 10px 28px rgba(0, 0, 0, 0.22);
    font-size: 1.55rem;
}

.eyebrow {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.28rem, 5vw, 2rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 8px;
    font-size: clamp(1.25rem, 4.4vw, 1.8rem);
}

h3 {
    margin-bottom: 6px;
}

.name-button,
.save-pill {
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(18px);
}

.name-button {
    max-width: 42vw;
    padding: 10px 12px;
    overflow: hidden;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.save-pill {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--soft);
    font-size: 0.75rem;
}

.save-pill::before {
    width: 8px;
    height: 8px;
    border-radius: 99px;
    background: var(--accent-2);
    content: "";
    box-shadow: 0 0 12px var(--accent-2);
}

.save-pill.offline::before {
    background: var(--danger);
    box-shadow: 0 0 12px var(--danger);
}

.status-grid,
.mini-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.stat,
.panel,
.coach,
.enemy-card,
.choice-card,
.deck-panel,
.log-panel,
.leaderboard,
.welcome-card,
.loading-card {
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.stat {
    min-height: 68px;
    padding: 10px;
    border-radius: 18px;
}

.stat span {
    display: block;
    color: var(--soft);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat strong {
    display: block;
    margin-top: 4px;
    font-size: 1.08rem;
}

.bar {
    position: relative;
    height: 8px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.17);
}

.bar > i {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--value, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.bar.hp > i {
    background: linear-gradient(90deg, #fb7185, #fda4af);
}

.bar.enemy > i {
    background: linear-gradient(90deg, #f97316, #fb7185);
}

.coach {
    position: relative;
    margin-bottom: 12px;
    padding: 14px;
    overflow: hidden;
    border-color: rgba(34, 211, 238, 0.34);
    border-radius: 22px;
}

.coach::after {
    position: absolute;
    inset: -60% -30% auto auto;
    width: 200px;
    height: 200px;
    border-radius: 999px;
    background: rgba(34, 211, 238, 0.14);
    content: "";
    filter: blur(8px);
}

.coach p {
    margin-bottom: 12px;
    color: #dbeafe;
}

.panel,
.welcome-card,
.loading-card {
    padding: 16px;
    border-radius: 24px;
}

.welcome-card {
    overflow: hidden;
}

.welcome-card .hero-copy {
    position: relative;
    padding: 22px 16px;
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 22px;
    background:
        radial-gradient(circle at 22% 20%, rgba(163, 230, 53, 0.18), transparent 15rem),
        linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(99, 102, 241, 0.1));
}

.welcome-card p,
.panel p,
.choice-card p,
.deck-panel p,
.leaderboard p {
    color: #cbd5e1;
}

.primary,
.secondary,
.ghost,
.choice-card,
.perk-button {
    min-height: 44px;
    border-radius: 16px;
    font-weight: 900;
    transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.primary:active,
.secondary:active,
.ghost:active,
.choice-card:active,
.perk-button:active,
.die:active {
    transform: translateY(1px) scale(0.99);
}

.primary {
    padding: 12px 16px;
    color: #03131d;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 14px 30px rgba(34, 211, 238, 0.18);
}

.secondary {
    padding: 12px 16px;
    color: var(--text);
    border: 1px solid rgba(34, 211, 238, 0.28);
    background: rgba(34, 211, 238, 0.13);
}

.ghost {
    padding: 10px 12px;
    color: #cbd5e1;
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.6);
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.action-row.single {
    grid-template-columns: 1fr;
}

.enemy-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    padding: 14px;
    overflow: hidden;
    border-radius: 24px;
}

.enemy-emoji {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border: 1px solid rgba(251, 113, 133, 0.35);
    border-radius: 22px;
    background: rgba(251, 113, 133, 0.11);
    font-size: 2rem;
}

.enemy-card h2 {
    margin-bottom: 2px;
}

.intent {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.72);
    font-size: 0.76rem;
    font-weight: 800;
}

.tag.gold {
    color: #fef3c7;
    border-color: rgba(250, 204, 21, 0.28);
    background: rgba(250, 204, 21, 0.12);
}

.dice-tray {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.die {
    position: relative;
    display: grid;
    min-height: 88px;
    padding: 8px 5px;
    place-items: center;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 20px;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.16), transparent 44%),
        linear-gradient(160deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.94));
    box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.04), 0 14px 24px rgba(0, 0, 0, 0.25);
}

.die.locked {
    border-color: rgba(163, 230, 53, 0.82);
    background:
        radial-gradient(circle at 50% 18%, rgba(163, 230, 53, 0.22), transparent 46%),
        linear-gradient(160deg, rgba(22, 101, 52, 0.64), rgba(15, 23, 42, 0.94));
}

.die.locked::after {
    position: absolute;
    top: 7px;
    right: 7px;
    color: var(--accent-2);
    content: "●";
    font-size: 0.7rem;
}

.die-icon {
    font-size: 1.72rem;
    line-height: 1;
}

.die-name {
    color: #e0f2fe;
    font-size: 0.72rem;
    font-weight: 900;
}

.die-desc {
    color: var(--soft);
    font-size: 0.66rem;
    line-height: 1.15;
}

.choice-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.choice-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    width: 100%;
    padding: 14px;
    color: var(--text);
    text-align: left;
}

.choice-card strong {
    display: block;
    margin-bottom: 3px;
    font-size: 1rem;
}

.choice-card p {
    margin: 0;
    font-size: 0.88rem;
}

.choice-icon {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 16px;
    background: rgba(34, 211, 238, 0.13);
    font-size: 1.45rem;
}

.deck-panel,
.log-panel,
.leaderboard {
    margin-top: 12px;
    padding: 14px;
    border-radius: 22px;
}

.deck-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.deck-chip {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #dbeafe;
    font-size: 0.78rem;
    font-weight: 800;
}

.log-panel ul,
.leaderboard ol {
    padding-left: 18px;
    margin: 8px 0 0;
    color: #cbd5e1;
}

.log-panel li,
.leaderboard li {
    margin-bottom: 6px;
}

.perk-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.perk-button {
    width: 100%;
    padding: 13px;
    color: var(--text);
    border: 1px solid var(--line);
    background: rgba(15, 23, 42, 0.72);
    text-align: left;
}

.perk-button strong {
    display: block;
}

.perk-button span {
    display: block;
    margin-top: 3px;
    color: var(--soft);
    font-size: 0.82rem;
}

.loading-card {
    display: grid;
    min-height: 220px;
    place-items: center;
    margin-top: 20vh;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(148, 163, 184, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.toast {
    position: fixed;
    right: 14px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 14px;
    z-index: 10;
    max-width: 480px;
    padding: 12px 14px;
    margin: auto;
    border: 1px solid rgba(34, 211, 238, 0.32);
    border-radius: 16px;
    color: var(--text);
    background: rgba(15, 23, 42, 0.94);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.landing-card,
.choice-stage,
.sanctuary-panel,
.roll-panel,
.battle-scene {
    animation: cardIn 0.34s ease both;
}

.landing-card {
    display: grid;
    gap: 14px;
}

.landing-scene {
    position: relative;
    display: grid;
    min-height: 260px;
    place-items: center;
    overflow: hidden;
    border: 1px solid rgba(34, 211, 238, 0.24);
    border-radius: 28px;
    background:
        radial-gradient(circle at 50% 55%, rgba(34, 211, 238, 0.2), transparent 8rem),
        radial-gradient(circle at 30% 20%, rgba(163, 230, 53, 0.18), transparent 9rem),
        linear-gradient(150deg, rgba(15, 23, 42, 0.1), rgba(8, 17, 31, 0.74));
}

.portal-ring {
    position: absolute;
    width: 170px;
    height: 170px;
    border: 2px dashed rgba(34, 211, 238, 0.5);
    border-radius: 50%;
    animation: spin 18s linear infinite;
    box-shadow: 0 0 70px rgba(34, 211, 238, 0.22), inset 0 0 45px rgba(163, 230, 53, 0.12);
}

.landing-hero {
    z-index: 1;
    font-size: 4.4rem;
    animation: heroFloat 2.5s ease-in-out infinite;
    filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.35));
}

.landing-die {
    position: absolute;
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
    font-size: 1.7rem;
    animation: orbit 5s ease-in-out infinite;
}

.landing-die.d1 { top: 38px; left: 18%; animation-delay: -1s; }
.landing-die.d2 { top: 60px; right: 16%; animation-delay: -2s; }
.landing-die.d3 { bottom: 40px; left: 23%; animation-delay: -3s; }
.landing-die.d4 { right: 22%; bottom: 32px; animation-delay: -4s; }

.feature-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.feature-row span {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.62);
    color: #dbeafe;
    font-weight: 900;
}

.coach-compact {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
}

.coach-compact h3,
.coach-compact p {
    margin-bottom: 2px;
}

.coach-compact p:not(.eyebrow) {
    font-size: 0.9rem;
    line-height: 1.35;
}

.coach-orb {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 18px;
    background: rgba(34, 211, 238, 0.14);
    font-size: 1.45rem;
    animation: pulseGlow 1.6s ease-in-out infinite;
}

.battle-scene {
    position: relative;
    min-height: 330px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid rgba(34, 211, 238, 0.24);
    border-radius: 30px;
    background:
        radial-gradient(circle at 24% 24%, rgba(34, 211, 238, 0.2), transparent 11rem),
        radial-gradient(circle at 82% 18%, rgba(251, 113, 133, 0.18), transparent 10rem),
        linear-gradient(180deg, rgba(30, 41, 59, 0.82), rgba(2, 6, 23, 0.9));
    box-shadow: var(--shadow);
    isolation: isolate;
}

.battle-scene::before,
.battle-scene::after {
    position: absolute;
    right: -10%;
    bottom: -18%;
    left: -10%;
    height: 48%;
    content: "";
    border-radius: 50% 50% 0 0;
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.12), rgba(15, 23, 42, 0.5));
    transform: rotate(-2deg);
}

.battle-scene::after {
    bottom: -28%;
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.11), rgba(15, 23, 42, 0.72));
    transform: rotate(3deg);
}

.scene-0 { background-color: #0f172a; }
.scene-1 { background-color: #111827; }
.scene-2 { background-color: #132018; }
.scene-elite { border-color: rgba(250, 204, 21, 0.4); }
.scene-boss { border-color: rgba(251, 113, 133, 0.55); box-shadow: 0 28px 80px rgba(127, 29, 29, 0.38); }

.scene-orb {
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 999px;
    opacity: 0.55;
    filter: blur(10px);
    animation: drift 7s ease-in-out infinite;
}

.orb-a {
    top: 18%;
    left: -50px;
    background: rgba(34, 211, 238, 0.28);
}

.orb-b {
    right: -46px;
    bottom: 8%;
    background: rgba(163, 230, 53, 0.2);
    animation-delay: -3s;
}

.scene-stars {
    position: absolute;
    inset: 24px 18px auto;
    color: rgba(255, 255, 255, 0.36);
    letter-spacing: 1.2rem;
    animation: twinkle 2.4s ease-in-out infinite;
}

.scene-topline {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 12px;
}

.scene-chip,
.reroll-badge,
.combo-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.5);
    color: #e0f2fe;
    font-size: 0.8rem;
    font-weight: 950;
}

.scene-chip.gold { color: #fef3c7; }
.scene-chip.poison { color: #bbf7d0; }

.combatants {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr minmax(84px, 0.7fr) 1fr;
    gap: 8px;
    align-items: end;
    min-height: 250px;
    padding: 8px 12px 24px;
}

.combatant {
    position: relative;
    display: grid;
    min-height: 210px;
    place-items: end center;
}

.sprite {
    position: relative;
    z-index: 2;
    display: grid;
    width: clamp(86px, 22vw, 138px);
    height: clamp(86px, 22vw, 138px);
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 32px;
    background:
        radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.2), transparent 44%),
        linear-gradient(160deg, rgba(15, 23, 42, 0.84), rgba(2, 6, 23, 0.86));
    box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.05), 0 20px 34px rgba(0, 0, 0, 0.32);
    font-size: clamp(3.1rem, 13vw, 5.6rem);
    animation: idleBob 2.2s ease-in-out infinite;
}

.hero-sprite {
    background:
        radial-gradient(circle at 50% 20%, rgba(34, 211, 238, 0.22), transparent 44%),
        linear-gradient(160deg, rgba(14, 116, 144, 0.48), rgba(2, 6, 23, 0.88));
}

.foe-sprite {
    background:
        radial-gradient(circle at 50% 20%, rgba(251, 113, 133, 0.2), transparent 44%),
        linear-gradient(160deg, rgba(127, 29, 29, 0.45), rgba(2, 6, 23, 0.9));
}

.fx-clash .hero-sprite,
.fx-defeat .hero-sprite { animation: heroHit 0.52s ease both; }
.fx-clash .foe-sprite,
.fx-block .foe-sprite,
.fx-victory .foe-sprite { animation: enemyHit 0.58s ease both; }
.fx-victory .foe-sprite { filter: saturate(1.4) brightness(1.25); }
.fx-enter .hero-sprite { animation: enterHero 0.75s ease both; }

.shadow {
    position: absolute;
    bottom: 0;
    width: 80%;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.34);
    filter: blur(5px);
}

.enemy-name {
    position: absolute;
    top: 6px;
    z-index: 3;
    max-width: 170px;
    padding: 6px 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.55);
    color: #fee2e2;
    font-size: 0.78rem;
    font-weight: 950;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scene-hp {
    position: absolute;
    right: 6%;
    bottom: 2px;
    left: 6%;
    z-index: 3;
    height: 10px;
}

.rune-lane {
    align-self: center;
    display: grid;
    gap: 8px;
    place-items: center;
    min-height: 150px;
}

.rune-lane strong {
    max-width: 150px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.54);
    color: #ecfeff;
    font-size: 0.76rem;
    text-align: center;
}

.flying-rune {
    display: inline-grid;
    width: 42px;
    height: 42px;
    margin: -10px 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    font-size: 1.35rem;
    animation: runeFloat 2.2s ease-in-out infinite;
    animation-delay: calc(var(--i) * -0.22s);
}

.fx-roll .flying-rune,
.fx-clash .flying-rune,
.fx-block .flying-rune,
.fx-victory .flying-rune {
    animation: runeStrike 0.72s ease both;
    animation-delay: calc(var(--i) * 0.045s);
}

.float {
    position: absolute;
    z-index: 5;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.74);
    font-weight: 1000;
    animation: floatUp 1.15s ease both;
    pointer-events: none;
}

.fx-damage,
.fx-wound { color: #fecdd3; }
.fx-heal { color: #bbf7d0; left: 16%; top: 30%; }
.fx-shield { color: #bfdbfe; left: 24%; top: 48%; animation-delay: 0.08s; }
.fx-wound { left: 34%; top: 18%; }
.fx-damage { right: 28%; top: 18%; }
.fx-poison { right: 16%; top: 42%; color: #bbf7d0; animation-delay: 0.12s; }

.roll-panel {
    overflow: hidden;
}

.roll-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.big-action {
    min-height: 56px;
    font-size: 1.02rem;
}

.combo-preview {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    padding: 9px 10px;
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 18px;
    background: rgba(2, 6, 23, 0.34);
}

.combo-preview strong {
    color: #ecfeff;
    font-size: 0.9rem;
}

.combo-preview > div {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-end;
}

.die {
    overflow: hidden;
    touch-action: manipulation;
}

.die::before {
    position: absolute;
    inset: -45%;
    background: conic-gradient(from 180deg, transparent, rgba(34, 211, 238, 0.18), transparent 34%);
    content: "";
    opacity: 0;
    transform: rotate(0deg);
}

.die.locked::before {
    opacity: 1;
    animation: spin 2.8s linear infinite;
}

.die.rolling {
    animation: diceTumble 0.58s ease both;
    animation-delay: calc(var(--i) * 0.045s);
}

.die.rolling .die-icon {
    animation: iconFlip 0.58s ease both;
}

.die-attack { border-color: rgba(251, 113, 133, 0.24); }
.die-shield { border-color: rgba(96, 165, 250, 0.28); }
.die-heal { border-color: rgba(134, 239, 172, 0.3); }
.die-gold { border-color: rgba(250, 204, 21, 0.3); }
.die-wild { border-color: rgba(216, 180, 254, 0.32); }

.choice-stage {
    position: relative;
    overflow: hidden;
}

.reward-scene {
    position: relative;
    display: grid;
    min-height: 150px;
    place-items: center;
    margin-bottom: 14px;
    overflow: hidden;
    border: 1px solid rgba(163, 230, 53, 0.2);
    border-radius: 24px;
    background:
        radial-gradient(circle at 50% 42%, rgba(163, 230, 53, 0.22), transparent 9rem),
        linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(15, 23, 42, 0.7));
}

.reward-icon {
    display: grid;
    width: 86px;
    height: 86px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 32px;
    background: rgba(15, 23, 42, 0.68);
    font-size: 3rem;
    animation: rewardPop 1.2s ease-in-out infinite;
}

.reward-spark {
    position: absolute;
    color: #fef08a;
    font-size: 1.4rem;
    animation: sparkOrbit 2.2s ease-in-out infinite;
}

.reward-spark.s1 { top: 28px; left: 26%; }
.reward-spark.s2 { top: 42px; right: 24%; animation-delay: -0.7s; }
.reward-spark.s3 { bottom: 30px; left: 52%; animation-delay: -1.4s; }

.compact-copy {
    max-width: 58ch;
    color: #cbd5e1;
}

.choice-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    border-color: rgba(34, 211, 238, 0.2);
}

.choice-card::after {
    position: absolute;
    inset: auto -20% -60% 20%;
    height: 90px;
    border-radius: 50%;
    background: rgba(34, 211, 238, 0.12);
    content: "";
    transition: transform 0.18s ease;
}

.choice-card:hover::after,
.choice-card:focus-visible::after {
    transform: translateY(-20px) scale(1.2);
}

.choice-icon {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    font-size: 2rem;
}

.choice-card p {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sanctuary-panel {
    overflow: hidden;
}

.sanctuary-scene {
    position: relative;
    display: grid;
    min-height: 150px;
    place-items: center;
    margin-bottom: 14px;
    border: 1px solid rgba(250, 204, 21, 0.18);
    border-radius: 24px;
    background:
        radial-gradient(circle at 50% 72%, rgba(250, 204, 21, 0.17), transparent 8rem),
        linear-gradient(160deg, rgba(15, 23, 42, 0.52), rgba(2, 6, 23, 0.72));
}

.sanctuary-scene span {
    position: absolute;
    filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.3));
}

.moon { top: 26px; right: 25%; font-size: 2.7rem; animation: heroFloat 3s ease-in-out infinite; }
.campfire { bottom: 22px; font-size: 3.2rem; animation: pulseGlow 1.3s ease-in-out infinite; }
.sleepy-die { bottom: 38px; left: 27%; font-size: 2.2rem; animation: orbit 2.8s ease-in-out infinite; }

.perk-button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    min-height: 78px;
}

.perk-button strong {
    display: flex;
    gap: 7px;
    align-items: center;
}

.perk-button strong > span {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 14px;
    background: rgba(34, 211, 238, 0.13);
    font-size: 1.35rem;
}

.perk-button em {
    color: var(--soft);
    font-style: normal;
}

.perk-button > span {
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(250, 204, 21, 0.12);
    color: #fef3c7;
    font-weight: 1000;
}

.compact-details {
    overflow: hidden;
}

.compact-details summary {
    min-height: 46px;
    margin: -4px;
    padding: 12px;
    border-radius: 17px;
    color: #e0f2fe;
    cursor: pointer;
    font-weight: 950;
    list-style: none;
}

.compact-details summary::-webkit-details-marker {
    display: none;
}

.compact-details summary::after {
    float: right;
    content: "+";
    color: var(--accent);
}

.compact-details[open] summary::after {
    content: "–";
}

.compact-details[open] .deck-list,
.compact-details[open] ul {
    animation: cardIn 0.22s ease both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes heroFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-9px); }
}

@keyframes orbit {
    0%, 100% { transform: translate(0, 0) rotate(-4deg); }
    50% { transform: translate(8px, -10px) rotate(7deg); }
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.2); }
}

@keyframes drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, -18px) scale(1.08); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 0.75; transform: translateY(-3px); }
}

@keyframes idleBob {
    0%, 100% { transform: translateY(0) rotate(-1deg); }
    50% { transform: translateY(-7px) rotate(1deg); }
}

@keyframes enterHero {
    0% { transform: translate(-80px, 30px) scale(0.7); opacity: 0; }
    70% { transform: translate(6px, -8px) scale(1.06); opacity: 1; }
    100% { transform: translate(0, 0) scale(1); opacity: 1; }
}

@keyframes heroHit {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-13px) rotate(-5deg); }
    65% { transform: translateX(6px) rotate(3deg); }
}

@keyframes enemyHit {
    0%, 100% { transform: translateX(0) scale(1); }
    35% { transform: translateX(14px) scale(1.08) rotate(5deg); }
    70% { transform: translateX(-6px) scale(0.98) rotate(-3deg); }
}

@keyframes runeFloat {
    0%, 100% { transform: translateY(0) rotate(-4deg); }
    50% { transform: translateY(-8px) rotate(5deg); }
}

@keyframes runeStrike {
    0% { transform: translateX(-54px) rotate(-120deg) scale(0.4); opacity: 0; }
    60% { transform: translateX(22px) rotate(12deg) scale(1.08); opacity: 1; }
    100% { transform: translateX(0) rotate(0) scale(1); opacity: 1; }
}

@keyframes floatUp {
    0% { opacity: 0; transform: translateY(12px) scale(0.72); }
    18% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-42px) scale(1.12); }
}

@keyframes diceTumble {
    0% { transform: translateY(0) rotate(0); }
    45% { transform: translateY(-15px) rotate(12deg) scale(1.06); }
    100% { transform: translateY(0) rotate(0); }
}

@keyframes iconFlip {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(180deg) scale(1.2); }
    100% { transform: rotateY(360deg); }
}

@keyframes rewardPop {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-7px) scale(1.05); }
}

@keyframes sparkOrbit {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.65; }
    50% { transform: translate(10px, -12px) scale(1.28); opacity: 1; }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 720px) {
    .main-grid {
        display: grid;
        grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
        gap: 12px;
        align-items: start;
    }

    .choice-grid,
    .perk-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .app-shell {
        padding-inline: 10px;
    }

    .status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar h1 {
        font-size: 1.2rem;
    }

    .coach-compact {
        grid-template-columns: auto 1fr;
    }

    .coach-compact .secondary {
        grid-column: 1 / -1;
        width: 100%;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .dice-tray {
        gap: 6px;
    }

    .die {
        min-height: 82px;
        border-radius: 16px;
    }

    .die-icon {
        font-size: 1.45rem;
    }

    .die-name {
        font-size: 0.64rem;
    }

    .die-desc {
        display: none;
    }

    .landing-scene {
        min-height: 210px;
    }

    .battle-scene {
        min-height: 284px;
        border-radius: 24px;
    }

    .combatants {
        grid-template-columns: 1fr 68px 1fr;
        min-height: 218px;
        padding: 0 8px 18px;
    }

    .combatant {
        min-height: 184px;
    }

    .sprite {
        width: 82px;
        height: 82px;
        border-radius: 24px;
        font-size: 3rem;
    }

    .rune-lane strong {
        display: none;
    }

    .flying-rune {
        width: 34px;
        height: 34px;
        border-radius: 12px;
        font-size: 1.1rem;
    }

    .combo-preview {
        align-items: flex-start;
        flex-direction: column;
    }

    .choice-card {
        min-height: 104px;
    }
}
