/* Royal Stacks web teaser — studio look (#060A13, cyan→violet gradient),
   Stacks game tokens (Theme.kt), portrait 360px primary, tap-first.
   100dvh layout: the whole fight fits one screen, no vertical scroll. */
:root {
    --bg: #060A13;
    --surface: #11151F;
    --panel: #1B2440;
    --panel-2: #141B33;
    --text: #E8ECF5;
    --text-dim: #AEB6C9;
    --gold: #FFC107;
    --accent: #FF6B6B;
    --accent-2: #E84545;
    --cyan: #22D3EE;
    --violet: #A78BFA;
    --spades: #3FD8FF;
    --hearts: #FF5C7A;
    --diamonds: #B57BFF;
    --clubs: #3DFFA0;
    --card-w: clamp(40px, 11.5vw, 56px);
    --card-h: calc(var(--card-w) * 1.45);
    --ease-out: cubic-bezier(.22, .9, .3, 1.15);
    --motion-ms: 340ms;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
h1, h2, .brand, .monster-name, .cta, .action-btn { font-family: Cinzel, Georgia, serif; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: var(--cyan); }
.hidden { display: none !important; }

#app {
    height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(120% 60% at 50% -10%, rgba(167, 139, 250, .14), transparent 60%),
        radial-gradient(120% 60% at 50% 110%, rgba(34, 211, 238, .10), transparent 60%),
        var(--bg);
}
#topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}
.brand { font-weight: 800; letter-spacing: .12em; font-size: 15px; }
.brand span { background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-right { display: flex; align-items: center; gap: 8px; }
.teaser-badge {
    font-size: 10px; font-weight: 800; letter-spacing: .14em;
    color: #0A0D14; background: linear-gradient(90deg, var(--gold), #FFD54F);
    padding: 4px 8px; border-radius: 999px;
}
.icon-btn {
    min-height: 32px; padding: 6px 10px; border-radius: 999px;
    border: 1px solid rgba(232, 236, 245, .25); font-size: 12px; color: var(--text-dim);
}
#stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 12px; overflow: hidden; }

/* ---------- start ---------- */
.start-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.start-crown { font-size: 44px; color: var(--gold); text-shadow: 0 0 24px rgba(255, 193, 7, .5); line-height: 1; }
.start-hero h1 { font-size: 30px; letter-spacing: .1em; }
.tagline { color: var(--text-dim); font-size: 15px; }
.teaser-note {
    font-size: 12px; line-height: 1.5; color: var(--gold);
    border: 1px solid rgba(255, 193, 7, .4); background: rgba(255, 193, 7, .07);
    border-radius: 10px; padding: 8px 12px; max-width: 340px;
}
.start-cards { display: flex; gap: 6px; margin: 2px 0; }
.mini-card {
    width: 34px; height: 48px; border-radius: 6px;
    background: linear-gradient(160deg, #1B2440, #11151F);
    border: 1px solid rgba(232, 236, 245, .25);
    display: flex; align-items: center; justify-content: center;
    font-family: Cinzel, serif; font-weight: 800; font-size: 15px;
}
.mini-card:nth-child(1) { color: var(--spades); transform: rotate(-6deg); }
.mini-card:nth-child(2) { color: var(--spades); transform: rotate(-2deg); }
.mini-card:nth-child(3) { color: var(--hearts); transform: rotate(2deg); }
.mini-card:nth-child(4) { color: var(--diamonds); transform: rotate(5deg); }
.mini-card:nth-child(5) { color: var(--clubs); transform: rotate(8deg); }
.cta {
    min-height: 48px; padding: 12px 28px; border-radius: 12px; font-size: 17px; font-weight: 800;
    letter-spacing: .04em; color: #0A0D14;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    box-shadow: 0 6px 24px rgba(34, 211, 238, .35);
    transition: transform var(--motion-ms) var(--ease-out), box-shadow var(--motion-ms) var(--ease-out);
}
.cta:active { transform: scale(.96); }
.cta.secondary {
    background: transparent; color: var(--text); box-shadow: none;
    border: 1px solid rgba(232, 236, 245, .3); font-size: 15px;
}
.start-meta { font-size: 12px; color: var(--text-dim); min-height: 16px; }
.funnel { font-size: 12px; line-height: 1.5; color: var(--text-dim); max-width: 340px; }
.save-note { font-size: 11px; color: var(--text-dim); opacity: .75; max-width: 340px; line-height: 1.5; }

/* ---------- fight ---------- */
#screen-fight { gap: 8px; }
#monster-panel {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .12);
    border-radius: 14px; padding: 10px 12px;
}
.monster-glyph {
    flex: 0 0 auto; width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; background: var(--panel-2);
    border: 1px solid rgba(232, 236, 245, .18);
}
.monster-glyph.boss { border-color: rgba(255, 107, 107, .6); box-shadow: 0 0 18px rgba(255, 107, 107, .25); }
.monster-info { flex: 1 1 auto; min-width: 0; }
.monster-name { font-size: 16px; font-weight: 800; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.monster-sub { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.hp-track {
    position: relative; height: 16px; margin-top: 6px;
    background: rgba(232, 236, 245, .1); border-radius: 999px; overflow: hidden;
}
.hp-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 400ms ease;
}
#hp-text {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 800; letter-spacing: .06em;
}
.twist-line { font-size: 11px; color: var(--gold); margin-top: 4px; min-height: 13px; }
.coins-box {
    flex: 0 0 auto; display: flex; align-items: center; gap: 5px;
    font-weight: 800; font-size: 16px; background: var(--panel-2);
    border: 1px solid rgba(255, 193, 7, .35); border-radius: 999px; padding: 6px 10px;
}
.coins-box .coin { color: var(--gold); font-size: 13px; }
.coins-box.big { font-size: 18px; padding: 8px 14px; align-self: center; }

#score-strip { display: flex; gap: 6px; }
.score-box {
    flex: 1 1 0; background: var(--surface); border: 1px solid rgba(232, 236, 245, .1);
    border-radius: 10px; padding: 6px 4px; text-align: center; min-width: 0;
}
.score-box label { display: block; font-size: 9px; letter-spacing: .12em; color: var(--text-dim); font-weight: 800; }
.score-box span { font-size: 14px; font-weight: 800; white-space: nowrap; }
.score-box span.pop { animation: score-pop 300ms var(--ease-out); }
@keyframes score-pop { 40% { transform: scale(1.18); } }

#scoring-line { min-height: 22px; font-size: 13px; color: var(--text-dim); text-align: center; line-height: 1.4; }
#scoring-line .sc-contrib { display: inline-block; margin: 0 2px; animation: reveal-in 300ms var(--ease-out); }
#scoring-line .sc-total { color: var(--gold); font-weight: 800; }
@keyframes reveal-in { from { opacity: 0; transform: translateY(6px); } }

#played-row { min-height: calc(var(--card-h) + 8px); display: flex; justify-content: center; align-items: flex-end; gap: 4px; }
#jokers-row { min-height: 34px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.joker-chip {
    display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
    background: var(--panel); border: 1px solid rgba(167, 139, 250, .45); border-radius: 999px;
    padding: 5px 9px; animation: reveal-in 300ms var(--ease-out);
}
.joker-chip .j-glyph { font-size: 13px; }
.joker-chip.fused { border-color: var(--gold); }
.joker-chip .j-mult { color: var(--cyan); }
#hand-row {
    flex: 1 1 auto; min-height: calc(var(--card-h) + 18px);
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 2px;
}
#action-row { display: flex; gap: 10px; }
.action-btn {
    flex: 1 1 0; min-height: 48px; border-radius: 12px; font-size: 16px; font-weight: 800;
    border: 1px solid rgba(232, 236, 245, .3); background: var(--surface);
    transition: transform var(--motion-ms) var(--ease-out), opacity 200ms ease;
}
.action-btn:active { transform: scale(.96); }
.action-btn.primary { background: linear-gradient(90deg, var(--cyan), var(--violet)); color: #0A0D14; border: none; }
.action-btn:disabled { opacity: .4; }
#hint-line { font-size: 11px; color: var(--text-dim); text-align: center; min-height: 14px; }

/* ---------- playing cards ---------- */
.pcard {
    position: relative; width: var(--card-w); height: var(--card-h);
    border-radius: 9px; flex: 0 0 auto;
    background: linear-gradient(165deg, #232C47, #11151F 70%);
    border: 1px solid rgba(232, 236, 245, .28);
    box-shadow: 0 3px 10px rgba(0, 0, 0, .45);
    cursor: pointer; user-select: none; touch-action: manipulation;
    transition: transform var(--motion-ms) var(--ease-out), box-shadow var(--motion-ms) var(--ease-out), opacity 200ms ease;
}
#hand-row .pcard { margin-left: -14px; }
#hand-row .pcard:first-child { margin-left: 0; }
.pcard .pc-corner {
    position: absolute; top: 3px; left: 4px; font-size: 13px; font-weight: 800; line-height: 1.05;
    display: flex; flex-direction: column; align-items: center;
}
.pcard .pc-corner .pc-suit { font-size: 11px; }
.pcard .pc-pip {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: calc(var(--card-w) * .52); line-height: 1;
}
.pcard .pc-corner-br {
    position: absolute; bottom: 3px; right: 4px; font-size: 13px; font-weight: 800;
    transform: rotate(180deg); display: flex; flex-direction: column; align-items: center; line-height: 1.05;
}
.pcard.s-spades { color: var(--spades); }
.pcard.s-hearts { color: var(--hearts); }
.pcard.s-diamonds { color: var(--diamonds); }
.pcard.s-clubs { color: var(--clubs); }
.pcard.selected {
    transform: translateY(-16px);
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px var(--cyan), 0 10px 22px rgba(34, 211, 238, .35);
}
.pcard.crowned {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 193, 7, .45);
}
.pcard.crowned.selected { box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--cyan), 0 10px 22px rgba(255, 193, 7, .4); }
.pcard .pc-crown {
    position: absolute; top: -9px; right: -6px; z-index: 2;
    font-size: 15px; color: var(--gold); text-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}
.pcard .pc-crown-lv {
    position: absolute; top: -7px; left: -4px; z-index: 2;
    font-size: 9px; font-weight: 800; color: #0A0D14; background: var(--gold);
    border-radius: 999px; padding: 1px 5px;
}
.pcard.silenced { opacity: .45; filter: grayscale(.7); }
.pcard .pc-silence {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; text-shadow: 0 1px 4px #000;
}
.pcard.deal-in { animation: deal-in var(--motion-ms) var(--ease-out) backwards; }
@keyframes deal-in { from { opacity: 0; transform: translateY(26px) scale(.85); } }
.pcard.played { cursor: default; }

/* ---------- shop / relic / end screens ---------- */
#screen-shop h2, #screen-relic h2, #screen-gameover h2, #screen-teaserend h2 {
    text-align: center; font-size: 24px; letter-spacing: .08em; margin-top: 6px;
}
.screen-sub { text-align: center; font-size: 13px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }
#shop-jokers { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.shop-item {
    display: flex; align-items: center; gap: 10px; text-align: left;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .14);
    border-radius: 12px; padding: 10px 12px; min-height: 56px; width: 100%;
    transition: transform var(--motion-ms) var(--ease-out), opacity 200ms ease;
}
.shop-item:active { transform: scale(.98); }
.shop-item:disabled { opacity: .45; }
.shop-item.bought { border-color: rgba(61, 255, 160, .6); }
.shop-item .sh-glyph { font-size: 24px; flex: 0 0 auto; width: 34px; text-align: center; }
.shop-item .sh-body { flex: 1 1 auto; min-width: 0; }
.shop-item .sh-name { font-weight: 800; font-size: 14px; }
.shop-item .sh-desc { font-size: 12px; color: var(--text-dim); line-height: 1.4; margin-top: 1px; }
.shop-item .sh-price { font-weight: 800; color: var(--gold); font-size: 14px; white-space: nowrap; }
.shop-item .sh-price .coin { color: var(--gold); }
#shop-upgrade { margin-top: 8px; }
#btn-reroll { margin-top: 10px; }
#btn-climb { margin-top: 10px; width: 100%; }
#screen-shop .ad-slot { margin-top: 12px; }
#relic-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.relic-item {
    display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
    background: var(--surface); border: 1px solid rgba(255, 193, 7, .45);
    border-radius: 12px; padding: 14px; min-height: 64px;
    transition: transform var(--motion-ms) var(--ease-out);
}
.relic-item:active { transform: scale(.98); }
.relic-item .r-glyph { font-size: 30px; }
.relic-item .r-name { font-weight: 800; font-size: 15px; }
.relic-item .r-desc { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin-top: 2px; }
.stats-box {
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .14);
    border-radius: 12px; padding: 14px; margin-top: 14px;
    font-size: 14px; line-height: 1.9; text-align: center;
}
.stats-box .stat-num { color: var(--gold); font-weight: 800; }
#btn-retry, #btn-home, #btn-again { margin-top: 10px; width: 100%; }
#screen-gameover .cta, #screen-teaserend .cta { margin-top: 12px; }
#screen-teaserend .ad-slot { margin-top: 12px; }

/* ---------- overlay / fly / burst ---------- */
#overlay {
    position: fixed; inset: 0; z-index: 40; display: none;
    align-items: flex-end; justify-content: center;
    background: rgba(3, 5, 10, .65);
}
#overlay.open { display: flex; }
#overlay-content {
    width: 100%; max-width: 560px; background: var(--surface);
    border: 1px solid rgba(232, 236, 245, .18); border-bottom: none;
    border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    text-align: center; animation: sheet-up 280ms var(--ease-out);
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
#overlay-content h3 { font-family: Cinzel, serif; font-size: 22px; letter-spacing: .06em; }
#overlay-content p { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin-top: 8px; }
#overlay-content .cta { margin-top: 16px; width: 100%; }
#fly-layer, #burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fly-clone {
    position: absolute; z-index: 61; margin: 0;
    transition: transform var(--motion-ms) var(--ease-out), opacity var(--motion-ms) ease;
    will-change: transform;
}
.dmg-float {
    position: absolute; z-index: 62; font-family: Cinzel, serif; font-weight: 800; font-size: 22px;
    color: var(--accent); text-shadow: 0 2px 8px rgba(0, 0, 0, .8);
    animation: dmg-rise 700ms ease-out forwards; pointer-events: none;
}
@keyframes dmg-rise { from { opacity: 1; transform: translateY(0) scale(1.1); } to { opacity: 0; transform: translateY(-46px) scale(1); } }
.particle {
    position: absolute; width: 7px; height: 7px; border-radius: 50%; pointer-events: none;
    animation: particle-fly 650ms ease-out forwards;
}
@keyframes particle-fly {
    from { opacity: 1; transform: translate(0, 0) scale(1); }
    to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); }
}
.shake { animation: shake 300ms ease-in-out; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); } 80% { transform: translateX(3px); }
}

/* ---------- ad slots ---------- */
.ad-slot {
    border: 1px dashed rgba(232, 236, 245, .25); border-radius: 10px;
    padding: 8px 10px; text-align: center; background: rgba(232, 236, 245, .03);
}
.ad-slot.ad-banner { min-height: 56px; }
.ad-slot.interstitial-ad { min-height: 90px; }
.ad-slot-label { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-dim); font-weight: 800; }
.ad-slot-note { font-size: 11px; color: var(--text-dim); line-height: 1.5; margin-top: 4px; }
.ad-slot-error { border-color: rgba(255, 107, 107, .5); }

/* ---------- calm mode: decoration only, core motion always plays ---------- */
body.calm .particle, body.calm .dmg-float { display: none; }
body.calm .shake { animation: none; }
body.calm .start-crown { text-shadow: none; }
body.calm .mini-card { transform: none !important; }

@media (max-height: 700px) {
    .start-crown { font-size: 34px; }
    .start-hero h1 { font-size: 25px; }
    .start-hero { gap: 7px; }
}
