* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100svh;
}

body {
    margin: 0;
    overflow: hidden;
    color: #fff7d8;
    font-family: "Fredoka", Arial, Helvetica, sans-serif;
    background: #16082f;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

canvas {
    position: fixed;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    width: 100dvw;
    height: 100dvh;
    touch-action: none;
}

.topbar {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.back, #muteButton, .title-chip {
    border: 2px solid rgba(255, 226, 122, 0.45);
    border-radius: 10px;
    background: rgba(18, 6, 42, 0.72);
    color: #ffe27a;
    text-decoration: none;
    font-weight: 700;
}

.back, #muteButton {
    padding: 8px 12px;
    font: inherit;
    cursor: pointer;
}

.title-chip {
    padding: 8px 12px;
    font-size: 0.92rem;
}

.hud {
    position: fixed;
    top: calc(62px + env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    pointer-events: none;
}

.count-bubble {
    min-width: 120px;
    padding: 8px 16px 10px;
    border: 4px solid #ffe27a;
    border-radius: 18px;
    background: linear-gradient(#6b32d6, #3b157c);
    text-align: center;
    box-shadow: 0 6px 0 #1a0838;
}

.count-bubble span {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.count-bubble strong {
    font-size: clamp(2.4rem, 8vw, 3.6rem);
    line-height: 0.9;
}

.run-stats {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(12, 4, 28, 0.7);
    font-size: 0.95rem;
    line-height: 1.45;
}

.panel {
    position: fixed;
    inset: 0;
    z-index: 8;
    display: grid;
    place-items: center;
    padding: 72px 16px 24px;
    background: rgba(10, 3, 24, 0.38);
    overflow: auto;
}

.card {
    width: min(520px, 100%);
    padding: 22px 20px 18px;
    border: 4px solid #f0c14a;
    border-radius: 22px;
    background: linear-gradient(#4a1d97, #241056);
    box-shadow: 0 12px 0 #120627;
}

.card.wide { width: min(760px, 100%); }

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.eyebrow {
    margin: 0 0 4px;
    color: #ffd56a;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
}

h1, h2 { margin: 0 0 10px; line-height: 1.05; }
h1 { font-size: clamp(2rem, 7vw, 3rem); }
h2 { font-size: clamp(1.5rem, 5vw, 2.1rem); }

.lead, .how, #failText, #clearText { color: #f7e7c2; }

.how {
    margin: 0 0 16px;
    padding-left: 18px;
}

.plus { color: #7dff9a; }
.mul { color: #ffe36a; }
.minus { color: #ff7a7a; }

button {
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: #2a1050;
    background: linear-gradient(#ffe36a, #f0b429);
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    box-shadow: 0 5px 0 #b07a12;
}

button.ghost {
    color: #ffe9a8;
    background: transparent;
    box-shadow: none;
    border: 2px solid rgba(255, 226, 122, 0.4);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.coin-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    color: #ffe36a;
    white-space: nowrap;
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0;
}

.map-grid button {
    min-height: 54px;
    padding: 6px 4px;
    box-shadow: none;
    border-radius: 10px;
    background: #6d3ad4;
    color: #fff6d6;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.map-grid button span {
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.85;
}
.map-grid button strong { font-size: 1.15rem; }

.map-grid button.boss { background: linear-gradient(#d45a22, #8a1f78); }
.map-grid button.done { background: #2f9d62; color: #fff; }
.map-grid button.locked {
    background: #2a2140;
    color: #8d84a6;
    cursor: not-allowed;
    box-shadow: none;
}

.shop-list { display: grid; gap: 10px; margin: 14px 0; }

.shop-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
}

.shop-item p { margin: 2px 0 0; font-size: 0.86rem; color: #ead9b0; }

@media (max-width: 520px) {
    .map-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .title-chip { display: none; }
    .card { padding: 18px 14px 14px; }
}
