* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

body {
    /* font-family: var(--font-sans); */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1625;
    color: #e8e4f0;
    min-height: 100vh;
    overflow-x: hidden
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 14px;
    position: relative
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease-out
}

.screen.active {
    display: block
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-6px)
    }

    75% {
        transform: translateX(6px)
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.05)
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(127, 119, 221, 0.4)
    }

    50% {
        box-shadow: 0 0 20px rgba(127, 119, 221, 0.8)
    }
}

@keyframes flashRed {

    0%,
    100% {
        background: var(--bg-card)
    }

    50% {
        background: rgba(226, 75, 74, 0.3)
    }
}

@keyframes flashGreen {

    0%,
    100% {
        background: var(--bg-card)
    }

    50% {
        background: rgba(99, 153, 34, 0.3)
    }
}

@keyframes damageFloat {
    0% {
        opacity: 1;
        transform: translateY(0)
    }

    100% {
        opacity: 0;
        transform: translateY(-40px)
    }
}

:root {
    --bg-dark: #1a1625;
    --bg-card: #2a2438;
    --bg-card-hi: #352d48;
    --bg-elevated: #3d3354;
    --border: #4a3f66;
    --border-hi: #6b5d8a;
    --text: #e8e4f0;
    --text-dim: #a598c0;
    --text-faint: #6b5d8a;
    --purple: #7f77dd;
    --purple-dark: #534ab7;
    --gold: #f5c547;
    --red: #e24b4a;
    --green: #639922;
    --blue: #4a9eff;
    --amber: #ef9f27;
}

h1 {
    font-size: 38px;
    font-weight: 500;
    letter-spacing: 1px
}

h2 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 12px;
    letter-spacing: 0.3px
}

h3 {
    font-size: 16px;
    font-weight: 500
}

.btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px
}

.btn:hover:not(:disabled) {
    background: var(--bg-card-hi);
    border-color: var(--border-hi);
    transform: translateY(-1px)
}

.btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98)
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed
}

.btn-primary {
    background: linear-gradient(135deg, #534ab7, #7f77dd);
    border-color: #7f77dd;
    color: #fff;
    font-weight: 500
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #6558d4, #9b94ea);
    box-shadow: 0 4px 16px rgba(127, 119, 221, 0.4)
}

.btn-danger {
    background: linear-gradient(135deg, #992d2d, #e24b4a);
    border-color: #e24b4a;
    color: #fff
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(226, 75, 74, 0.4)
}

.btn-success {
    background: linear-gradient(135deg, #3b6d11, #639922);
    border-color: #639922;
    color: #fff
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(99, 153, 34, 0.4)
}

.btn-gold {
    background: linear-gradient(135deg, #c9920f, #f5c547);
    border-color: #f5c547;
    color: #2a1a00;
    font-weight: 500
}

/* TITLE */
.title-screen {
    text-align: center;
    padding: 60px 0
}

.title-screen h1 {
    background: linear-gradient(135deg, #f5c547, #e24b4a, #7f77dd);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    animation: slideUp 0.6s ease-out
}

.title-sub {
    color: var(--text-dim);
    margin-bottom: 40px;
    font-size: 15px;
    font-style: italic;
    animation: slideUp 0.8s ease-out
}

.title-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    animation: slideUp 1s ease-out
}

.title-btns .btn {
    width: 200px;
    justify-content: center;
    font-size: 15px;
    padding: 12px
}

.howto {
    margin-top: 32px;
    text-align: left;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.8;
    background: var(--bg-card);
    padding: 18px 22px;
    border-radius: 12px;
    border: 1px solid var(--border)
}

.howto strong {
    color: var(--text);
    display: block;
    margin-top: 10px;
    margin-bottom: 4px
}

.howto strong:first-child {
    margin-top: 0
}

.kw {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin: 0 2px
}

.kw-bleed {
    background: rgba(226, 75, 74, 0.2);
    color: #ff8080
}

.kw-weak {
    background: rgba(239, 159, 39, 0.2);
    color: #f5c547
}

.kw-vuln {
    background: rgba(226, 75, 74, 0.25);
    color: #ff6b6b
}

.kw-burn {
    background: rgba(239, 100, 39, 0.2);
    color: #ff9057
}

/* MAP - BRANCHING */
.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 16px
}

.hp-display {
    display: flex;
    align-items: center;
    gap: 10px
}

.hp-icon {
    color: #e24b4a;
    font-size: 18px
}

.hp-text {
    font-weight: 500;
    font-size: 15px
}

.hp-bar-mini {
    width: 100px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden
}

.hp-bar-mini-fill {
    height: 100%;
    background: linear-gradient(90deg, #e24b4a, #ff8080);
    border-radius: 3px;
    transition: width 0.5s
}

.gold-display {
    color: var(--gold);
    font-weight: 500;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 6px
}

.act-banner {
    text-align: center;
    margin: 12px 0;
    font-size: 13px;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase
}

.act-banner strong {
    color: var(--gold);
    font-weight: 500
}

.relics-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 12px;
    min-height: 28px
}

.relic-mini {
    font-size: 12px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 20px;
    padding: 4px 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: help;
    transition: transform 0.2s
}

.relic-mini:hover {
    transform: translateY(-2px)
}

.map-container {
    background: linear-gradient(180deg, #221c30, #2a2438);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 8px;
    position: relative;
    overflow: hidden
}

.map-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(127, 119, 221, 0.08), transparent 50%), radial-gradient(circle at 70% 80%, rgba(245, 197, 71, 0.05), transparent 50%);
    pointer-events: none
}

.map-svg-wrap {
    position: relative;
    z-index: 1
}

.map-svg {
    width: 100%;
    display: block
}

.node-circle {
    cursor: default;
    transition: all 0.2s
}

.node-circle.available {
    cursor: pointer
}

.node-circle.available .node-bg {
    animation: glow 2s ease-in-out infinite
}

.node-circle.available:hover .node-bg {
    transform: scale(1.15);
    transform-origin: center
}

.node-circle.completed .node-bg {
    opacity: 0.4
}

.node-circle.locked {
    opacity: 0.35
}

.node-current .node-bg {
    stroke: #f5c547;
    stroke-width: 3
}

/* COMBAT */
.combat-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fadeIn 0.5s
}

.combat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px
}

.combatant {
    background: linear-gradient(180deg, var(--bg-card), var(--bg-card-hi));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: background 0.3s
}

.combatant.hurt {
    animation: flashRed 0.4s ease
}

.combatant.heal {
    animation: flashGreen 0.4s ease
}

.enemy-box {
    border-color: rgba(226, 75, 74, 0.3)
}

.player-box {
    border-color: rgba(127, 119, 221, 0.3)
}

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

.entity-name {
    display: flex;
    align-items: center;
    gap: 10px
}

.entity-sprite {
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 1px solid var(--border)
}

.entity-meta {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.entity-meta h3 {
    margin: 0
}

.hp-bar {
    height: 18px;
    background: var(--bg-elevated);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border)
}

.hp-fill {
    height: 100%;
    border-radius: 9px;
    transition: width 0.4s ease;
    position: relative
}

.hp-fill.player {
    background: linear-gradient(90deg, #3b6d11, #97c459)
}

.hp-fill.enemy {
    background: linear-gradient(90deg, #992d2d, #e24b4a)
}

.hp-text-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    z-index: 2
}

.block-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--blue);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 6px
}

.block-badge svg {
    width: 12px;
    height: 12px
}

.intent {
    font-size: 13px;
    background: rgba(226, 75, 74, 0.15);
    border: 1px solid rgba(226, 75, 74, 0.3);
    border-radius: 8px;
    padding: 6px 10px;
    color: #ff8080;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500
}

.intent svg {
    width: 14px;
    height: 14px
}

.status-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
    min-height: 22px
}

.status-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
    border: 1px solid
}

.sb-bleed {
    background: rgba(226, 75, 74, 0.15);
    color: #ff8080;
    border-color: rgba(226, 75, 74, 0.4)
}

.sb-weak {
    background: rgba(239, 159, 39, 0.15);
    color: #f5c547;
    border-color: rgba(239, 159, 39, 0.4)
}

.sb-vuln {
    background: rgba(226, 75, 74, 0.2);
    color: #ff6b6b;
    border-color: rgba(226, 75, 74, 0.5)
}

.sb-burn {
    background: rgba(239, 100, 39, 0.15);
    color: #ff9057;
    border-color: rgba(239, 100, 39, 0.4)
}

.energy-display {
    display: flex;
    align-items: center;
    gap: 8px
}

.energy-orb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #9b94ea, #534ab7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    font-weight: 500;
    border: 2px solid #7f77dd;
    box-shadow: 0 0 12px rgba(127, 119, 221, 0.5)
}

.energy-orb.empty {
    background: var(--bg-elevated);
    color: var(--text-faint);
    border-color: var(--border);
    box-shadow: none
}

.energy-label {
    font-size: 12px;
    color: var(--text-dim)
}

.hand-info {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
    padding: 0 4px
}

.hand-info span strong {
    color: var(--text);
    font-weight: 500
}

.hand {
    display: flex;
    gap: 8px;
    justify-content: center;
    min-height: 160px;
    padding: 8px 4px;
    flex-wrap: wrap
}

.card {
    width: 108px;
    min-height: 148px;
    background: linear-gradient(180deg, #3d3354, #2a2438);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    font-size: 11px;
    position: relative;
    animation: slideUp 0.3s ease-out
}

.card:hover:not(.unaffordable) {
    transform: translateY(-10px);
    border-color: var(--purple);
    box-shadow: 0 8px 24px rgba(127, 119, 221, 0.4)
}

.card.unaffordable {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5)
}

.card.type-attack {
    border-color: rgba(226, 75, 74, 0.5)
}

.card.type-block {
    border-color: rgba(74, 158, 255, 0.5)
}

.card.type-skill {
    border-color: rgba(99, 153, 34, 0.5)
}

.card.type-power {
    border-color: rgba(239, 159, 39, 0.5)
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start
}

.card-cost {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #9b94ea, #534ab7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    border: 2px solid #fff;
    box-shadow: 0 0 8px rgba(127, 119, 221, 0.5);
    flex-shrink: 0
}

.card-type-badge {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500
}

.card-icon {
    font-size: 20px;
    text-align: center;
    margin: 2px 0
}

.card-name {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2
}

.type-attack .card-name {
    color: #ff8080
}

.type-block .card-name {
    color: #7ab8ff
}

.type-skill .card-name {
    color: #b5d676
}

.type-power .card-name {
    color: #f5c547
}

.card-desc {
    font-size: 10px;
    color: var(--text-dim);
    line-height: 1.4;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center
}

.combat-btns {
    display: flex;
    gap: 8px;
    justify-content: center
}

.log {
    font-size: 12px;
    color: var(--text-dim);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    height: 90px;
    overflow-y: auto;
    line-height: 1.7
}

.log::-webkit-scrollbar {
    width: 6px
}

.log::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px
}

.log-entry {
    animation: fadeIn 0.3s
}

/* DAMAGE FLOAT */
.dmg-float {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 28px;
    font-weight: 500;
    pointer-events: none;
    animation: damageFloat 1s ease-out forwards;
    z-index: 100
}

.dmg-float.dmg {
    color: #ff6b6b;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8)
}

.dmg-float.blk {
    color: #7ab8ff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8)
}

.dmg-float.heal {
    color: #b5d676;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8)
}

/* REWARD */
.reward-cards {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0
}

.reward-card-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.5s ease-out
}

.reward-card-wrap:nth-child(2) {
    animation-delay: 0.1s
}

.reward-card-wrap:nth-child(3) {
    animation-delay: 0.2s
}

.full-card {
    width: 130px;
    min-height: 180px;
    background: linear-gradient(180deg, #3d3354, #2a2438);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px
}

.full-card.type-attack {
    border-color: rgba(226, 75, 74, 0.5)
}

.full-card.type-block {
    border-color: rgba(74, 158, 255, 0.5)
}

.full-card.type-skill {
    border-color: rgba(99, 153, 34, 0.5)
}

.full-card.type-power {
    border-color: rgba(239, 159, 39, 0.5)
}

/* SHOP/REST/EVENT */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px
}

.panel-intro {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 16px;
    font-style: italic
}

.shop-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center
}

.shop-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px
}

.deck-scroll {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    max-height: 380px;
    overflow-y: auto;
    padding: 8px;
    justify-content: center
}

.deck-scroll::-webkit-scrollbar {
    width: 8px
}

.deck-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px
}

.deck-scroll .full-card {
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s
}

.deck-scroll .full-card:hover {
    transform: translateY(-4px);
    border-color: var(--purple)
}

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px
}

.event-choices .btn {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    padding: 14px 16px;
    font-size: 14px
}

.go-victory h1 {
    color: #f5c547 !important;
    -webkit-text-fill-color: #f5c547 !important;
    background: none !important
}

.go-defeat h1 {
    color: #e24b4a !important;
    -webkit-text-fill-color: #e24b4a !important;
    background: none !important
}

/* Toast/notification */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out
}
