/* NEON VEIL web prototype (v0) — studio look (#060A13, cyan→violet
   gradient, gold only for currency/rewards), portrait 360px primary,
   tap-first. 100dvh layout: hub and battle fit one screen where feasible. */
: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;
    --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, h3, .brand, .cta, .action-btn, .hub-tab, .proto-name, .battle-title, .draw-name { 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; }
.gold-text { color: var(--gold); font-weight: 800; }

#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, .16), transparent 60%),
        radial-gradient(120% 60% at 50% 110%, rgba(34, 211, 238, .12), 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; }
.currency-box {
    display: flex; align-items: center; gap: 5px;
    font-weight: 800; font-size: 15px; background: var(--panel-2);
    border: 1px solid rgba(255, 193, 7, .35); border-radius: 999px; padding: 6px 10px;
}
.currency-box .coin { color: var(--gold); font-size: 12px; }
.currency-box.shards { border-color: rgba(167, 139, 250, .45); }
.currency-box .shard { color: var(--violet); font-size: 12px; }
.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 / protagonist select ---------- */
.start-hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; overflow-y: auto; }
.start-glyph { font-size: 34px; color: var(--cyan); text-shadow: 0 0 24px rgba(34, 211, 238, .5); line-height: 1; }
.start-hero h1 { font-size: 30px; letter-spacing: .12em; }
.tagline { color: var(--text-dim); font-size: 15px; max-width: 340px; }
.proto-choices { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.proto-card {
    flex: 1 1 0; min-width: 0; text-align: center;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .14);
    border-radius: 14px; padding: 10px; min-height: 48px;
    transition: transform var(--motion-ms) var(--ease-out), border-color 200ms ease, box-shadow 200ms ease;
}
.proto-card:active { transform: scale(.97); }
.proto-card.selected {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px var(--cyan), 0 0 22px rgba(34, 211, 238, .35);
}
.proto-img {
    width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top;
    border-radius: 10px; display: block;
}
.proto-name { font-size: 19px; font-weight: 800; letter-spacing: .08em; margin-top: 8px; }
.proto-flavor { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin-top: 4px; min-height: 34px; }
.proto-stats { font-size: 11px; color: var(--cyan); font-weight: 700; margin-top: 6px; }
.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:disabled { opacity: .45; }
.cta.secondary {
    background: transparent; color: var(--text); box-shadow: none;
    border: 1px solid rgba(232, 236, 245, .3); font-size: 15px;
}
.save-note { font-size: 11px; color: var(--text-dim); opacity: .75; max-width: 340px; line-height: 1.5; }

/* ---------- hub ---------- */
#hub-tabs { display: flex; gap: 8px; margin-top: 4px; }
.hub-tab {
    flex: 1 1 0; min-height: 48px; border-radius: 12px; font-size: 16px; font-weight: 800;
    letter-spacing: .06em; background: var(--surface);
    border: 1px solid rgba(232, 236, 245, .14); color: var(--text-dim);
}
.hub-tab.active {
    color: #0A0D14; background: linear-gradient(90deg, var(--cyan), var(--violet));
    border: none;
}
.hub-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-top: 10px; }
#screen-hub h2 { text-align: center; font-size: 22px; letter-spacing: .08em; }
.screen-sub { text-align: center; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.active-strip { display: flex; gap: 8px; }
.active-slot {
    flex: 1 1 0; min-width: 0; border-radius: 12px; overflow: hidden;
    background: var(--surface); border: 1px dashed rgba(232, 236, 245, .25);
    min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 11px; color: var(--text-dim); text-align: center;
}
.active-slot.filled { border-style: solid; border-color: rgba(34, 211, 238, .5); }
.slot-img { width: 100%; height: 76px; object-fit: cover; object-position: top; display: block; }
.slot-label { font-size: 11px; font-weight: 800; padding: 4px 2px; color: var(--text); }
#roster-list { display: flex; flex-direction: column; gap: 8px; }
.roster-row {
    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: 8px 10px; min-height: 64px;
}
.roster-row.locked { opacity: .55; }
.roster-img { width: 44px; height: 58px; object-fit: cover; object-position: top; border-radius: 8px; flex: 0 0 auto; }
.roster-body { flex: 1 1 auto; min-width: 0; }
.roster-name { font-weight: 800; font-size: 15px; }
.roster-sub { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin-top: 2px; }
.rarity-badge {
    font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 999px; vertical-align: middle;
}
.rarity-badge.r-hero { color: #0A0D14; background: linear-gradient(90deg, var(--gold), #FFD54F); }
.rarity-badge.r-rare { color: #0A0D14; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.rarity-badge.r-epic { color: #fff; background: linear-gradient(90deg, #B57BFF, #FF5C7A); }
.rarity-badge.r-common { color: var(--text-dim); border: 1px solid rgba(232, 236, 245, .35); }
.equip-btn {
    flex: 0 0 auto; min-height: 44px; min-width: 76px; padding: 8px 12px; border-radius: 10px;
    font-size: 13px; font-weight: 800; background: var(--panel);
    border: 1px solid rgba(34, 211, 238, .5); color: var(--cyan);
}
.equip-btn:disabled { opacity: .45; border-color: rgba(232, 236, 245, .2); color: var(--text-dim); }
#btn-battle { width: 100%; margin-top: 4px; }

/* ---------- draw ---------- */
.draw-balance {
    text-align: center; font-weight: 800; font-size: 17px;
    background: var(--panel-2); border: 1px solid rgba(255, 193, 7, .35);
    border-radius: 999px; padding: 8px 14px; align-self: center;
}
.draw-balance .coin { color: var(--gold); }
.draw-balance .shard { color: var(--violet); }
#btn-roll { width: 100%; }
.draw-result { display: flex; justify-content: center; min-height: 0; }
.draw-card {
    width: 100%; max-width: 300px; text-align: center;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .2);
    border-radius: 14px; padding: 12px;
}
.draw-card.r-rare { border-color: rgba(34, 211, 238, .6); box-shadow: 0 0 22px rgba(34, 211, 238, .25); }
.draw-card.r-epic { border-color: rgba(181, 123, 255, .7); box-shadow: 0 0 26px rgba(181, 123, 255, .35); }
.draw-img { width: 100%; max-height: 220px; object-fit: cover; object-position: top; border-radius: 10px; display: block; }
.draw-glyph { font-size: 52px; line-height: 1.2; }
.draw-name { font-size: 20px; font-weight: 800; letter-spacing: .08em; margin-top: 8px; }
.draw-rarity { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); margin-top: 2px; }
.draw-note { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-top: 6px; }
.inv-title { text-align: center; font-size: 15px; letter-spacing: .1em; margin-top: 6px; }
#inventory-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text-dim); text-align: center; }
.inv-row {
    display: flex; align-items: center; gap: 10px; text-align: left;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .12);
    border-radius: 12px; padding: 8px 10px; min-height: 52px;
}
.inv-glyph { font-size: 22px; flex: 0 0 auto; width: 30px; text-align: center; }
.inv-body { flex: 1 1 auto; min-width: 0; }
.inv-name { font-weight: 800; font-size: 14px; color: var(--text); }
.inv-sub { font-size: 12px; color: var(--text-dim); line-height: 1.4; margin-top: 1px; }

/* ---------- battle ---------- */
#screen-battle { gap: 8px; }
.battle-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.battle-title { font-size: 17px; font-weight: 800; letter-spacing: .06em; }
.battle-sub { font-size: 11px; color: var(--text-dim); line-height: 1.4; margin-top: 2px; }
#battle-hint { text-align: right; max-width: 55%; }
#enemy-row { display: flex; gap: 8px; }
.enemy-card {
    flex: 1 1 0; min-width: 0; min-height: 48px;
    background: var(--surface); border: 1px solid rgba(255, 107, 107, .4);
    border-radius: 12px; padding: 8px 6px; text-align: center;
    transition: transform var(--motion-ms) var(--ease-out), box-shadow 200ms ease;
}
.enemy-card:active { transform: scale(.97); }
.enemy-card.dead { opacity: .35; border-color: rgba(232, 236, 245, .15); }
.enemy-glyph { font-size: 24px; line-height: 1; }
.enemy-name { font-size: 12px; font-weight: 800; letter-spacing: .04em; margin-top: 4px; }
.hp-track {
    position: relative; height: 14px; margin-top: 6px;
    background: rgba(232, 236, 245, .1); border-radius: 999px; overflow: hidden;
}
.hp-fill { height: 100%; border-radius: 999px; transition: width 400ms ease; }
.hp-fill.enemy-hp { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.hp-fill.party-hp { background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.hp-text { font-size: 10px; font-weight: 800; color: var(--text-dim); margin-top: 3px; }
#party-row { display: flex; gap: 8px; flex: 1 1 auto; min-height: 0; }
.party-card {
    flex: 1 1 0; min-width: 0; min-height: 48px;
    background: var(--surface); border: 1px solid rgba(232, 236, 245, .14);
    border-radius: 12px; padding: 8px 6px; text-align: center; overflow: hidden;
    transition: transform var(--motion-ms) var(--ease-out), box-shadow 200ms ease, opacity 200ms ease;
}
.party-card:active { transform: scale(.97); }
.party-card.selected {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px var(--cyan), 0 0 18px rgba(34, 211, 238, .35);
}
.party-card.acted { opacity: .55; }
.party-card.dead { opacity: .35; }
.party-card.deal-in { animation: deal-in var(--motion-ms) var(--ease-out) backwards; }
@keyframes deal-in { from { opacity: 0; transform: translateY(26px) scale(.85); } }
.party-img { width: 100%; height: 110px; object-fit: cover; object-position: top; border-radius: 8px; display: block; }
.party-name { font-size: 12px; font-weight: 800; letter-spacing: .04em; margin-top: 5px; }
#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; }
.battle-log {
    flex: 0 0 auto; min-height: 84px; max-height: 110px; overflow: hidden;
    background: var(--panel-2); border: 1px solid rgba(232, 236, 245, .1);
    border-radius: 12px; padding: 8px 10px; font-size: 12px; line-height: 1.55; color: var(--text-dim);
}
.log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- result ---------- */
#screen-result h2 { text-align: center; font-size: 24px; letter-spacing: .08em; margin-top: 6px; }
.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-return { margin-top: 12px; width: 100%; }
#screen-result .ad-slot { margin-top: 12px; }

/* ---------- fly / burst / reveal ---------- */
#fly-layer, #burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.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;
}
.dmg-float.good { color: #3DFFA0; }
@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, 30px), var(--dy, -30px)) scale(.3); }
}
.reveal-in { animation: reveal-in 340ms var(--ease-out) backwards; }
@keyframes reveal-in { from { opacity: 0; transform: translateY(10px) scale(.94); } }
.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); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes score-pop { 40% { transform: scale(1.18); } }

/* ---------- 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-glyph { text-shadow: none; }

@media (max-height: 700px) {
    .start-glyph { font-size: 26px; }
    .start-hero h1 { font-size: 25px; }
    .start-hero { gap: 7px; }
    .party-img { height: 84px; }
}
