@font-face {
    font-family: 'Baloo2';
    src: url('../assets/fonts/Baloo2.ttf') format('truetype');
    font-weight: 400 800;
}

:root {
    --candy-pink: #ff7ab8;
    --candy-blue: #5fd3ff;
    --candy-purple: #a06bff;
    --candy-gold: #ffcf4d;
    --ice-blue: #bfe9ff;
    --ink: #2a1a40;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f1d3a;
    font-family: 'Baloo2', 'Segoe UI', system-ui, sans-serif;
    touch-action: none;
    overscroll-behavior: none;
}

#game-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

.screen.hidden {
    display: none;
}

/* ---------- Shared bits ---------- */

.game-title {
    font-size: clamp(2.2rem, 10vw, 3.4rem);
    font-weight: 800;
    color: var(--candy-gold);
    text-shadow: 0 3px 0 #7a4a00, 0 6px 14px rgba(0,0,0,0.45);
    margin: 0;
    text-align: center;
    letter-spacing: 1px;
}

.game-subtitle {
    text-align: center;
    color: #fff;
    font-size: clamp(0.95rem, 3.6vw, 1.2rem);
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
    margin-top: 6px;
}

.candy-btn {
    font-family: inherit;
    font-weight: 700;
    font-size: 1.3rem;
    color: #fff;
    padding: 18px 40px;
    border-radius: 999px;
    border: 4px solid #fff;
    cursor: pointer;
    box-shadow: 0 6px 0 rgba(0,0,0,0.25), 0 10px 20px rgba(0,0,0,0.35);
    transition: transform 0.08s ease;
    text-shadow: 0 2px 3px rgba(0,0,0,0.4);
}

.candy-btn:active {
    transform: translateY(4px) scale(0.98);
    box-shadow: 0 2px 0 rgba(0,0,0,0.25), 0 4px 10px rgba(0,0,0,0.3);
}

.candy-btn-primary {
    background: linear-gradient(180deg, #8fe0ff, #2f8fd6);
    color: #fff;
}

/* Faceted "ice gem" button. The facets are real polygons (drawn in an inline SVG child,
   see index.html) rather than a CSS gradient trick - flat gradient stripes read as candy
   stripes no matter the color, they don't read as angular cut facets. The clip-path here
   mirrors the SVG's own octagon exactly (same per-axis fractions: 32/340 x, 32/100 y) so
   the button's hit-area/glow matches the drawn silhouette. */
.candy-btn-ice {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #fff;
    clip-path: polygon(9.41% 0, 90.59% 0, 100% 32%, 100% 68%, 90.59% 100%, 9.41% 100%, 0 68%, 0 32%);
    text-shadow: 0 2px 3px rgba(0,10,25,0.6), 0 0 10px rgba(255,255,255,0.7);
    filter: drop-shadow(0 6px 14px rgba(0,15,35,0.4)) drop-shadow(0 0 16px rgba(140,210,255,0.55));
}

.ice-btn-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.ice-btn-label {
    position: relative;
    z-index: 1;
}

.ice-btn-shimmer {
    transform-origin: center;
    animation: ice-shimmer-sweep 3.6s ease-in-out infinite;
}

.ice-sparkle {
    animation: ice-sparkle 2.2s ease-in-out infinite;
}
.ice-sparkle:nth-child(2) { animation-delay: 0.5s; }
.ice-sparkle:nth-child(3) { animation-delay: 1.1s; }
.ice-sparkle:nth-child(4) { animation-delay: 0.3s; }
.ice-sparkle:nth-child(5) { animation-delay: 1.6s; }

@keyframes ice-shimmer-sweep {
    0%   { transform: translateX(-140px); opacity: 0; }
    15%  { opacity: 0.9; }
    50%  { transform: translateX(140px); opacity: 0; }
    100% { transform: translateX(140px); opacity: 0; }
}

@keyframes ice-sparkle {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 1; }
}

.candy-btn-secondary {
    background: linear-gradient(180deg, #f2fbff, #a9d8f2);
    color: #123a5c;
    font-size: 1.05rem;
    padding: 12px 30px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.candy-btn-danger {
    background: linear-gradient(180deg, #ff8a8a, #d33f3f);
    color: #fff;
    font-size: 1.05rem;
    padding: 12px 30px;
}

.candy-btn-danger.armed {
    background: linear-gradient(180deg, #ffb84d, #d3701f);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.85);
    background: rgba(30, 15, 50, 0.55);
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.coin-pill, .stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(20, 10, 40, 0.55);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 999px;
    padding: 8px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
}

.stat-pill-btn {
    font-family: inherit;
    cursor: pointer;
    position: relative;
}

.shop-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: linear-gradient(180deg, #34c98a, #1f8f60);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
    margin-left: -2px;
}

.coin-icon, .heart-icon, .star-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    background: radial-gradient(circle at 35% 30%, #fff6c8, var(--candy-gold) 60%, #b8860b 100%);
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.3);
}

/* Currency icon is a snowflake (fits the ice/defrost theme) instead of a coin -
   overrides the shared circular coin styling above. */
.coin-icon {
    border-radius: 0;
    box-shadow: none;
    background: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48ZyBpZD0iYXJtIiBzdHJva2U9IiMzZWM2ZjAiIHN0cm9rZS13aWR0aD0iNyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBmaWxsPSJub25lIj48bGluZSB4MT0iNTAiIHkxPSI1MCIgeDI9IjUwIiB5Mj0iOCIvPjxsaW5lIHgxPSI1MCIgeTE9IjIwIiB4Mj0iMzciIHkyPSI5Ii8+PGxpbmUgeDE9IjUwIiB5MT0iMjAiIHgyPSI2MyIgeTI9IjkiLz48bGluZSB4MT0iNTAiIHkxPSIzNSIgeDI9IjM5IiB5Mj0iMjciLz48bGluZSB4MT0iNTAiIHkxPSIzNSIgeDI9IjYxIiB5Mj0iMjciLz48L2c+PHVzZSBocmVmPSIjYXJtIiB0cmFuc2Zvcm09InJvdGF0ZSg2MCA1MCA1MCkiLz48dXNlIGhyZWY9IiNhcm0iIHRyYW5zZm9ybT0icm90YXRlKDEyMCA1MCA1MCkiLz48dXNlIGhyZWY9IiNhcm0iIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA1MCkiLz48dXNlIGhyZWY9IiNhcm0iIHRyYW5zZm9ybT0icm90YXRlKDI0MCA1MCA1MCkiLz48dXNlIGhyZWY9IiNhcm0iIHRyYW5zZm9ybT0icm90YXRlKDMwMCA1MCA1MCkiLz48Y2lyY2xlIGN4PSI1MCIgY3k9IjUwIiByPSI3IiBmaWxsPSIjM2VjNmYwIi8+PC9zdmc+") center/contain no-repeat;
}

.heart-icon {
    background: radial-gradient(circle at 35% 30%, #ffd0d8, #ff4d6d 60%, #a80025 100%);
}

.star-icon {
    background: radial-gradient(circle at 35% 30%, #fff, #5fd3ff 60%, #1b6faa 100%);
}

/* ---------- Splash ---------- */

#splash-overlay {
    justify-content: center;
    background: linear-gradient(180deg, #0a1430, #143058);
}

.splash-title-wrap {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.splash-title-wrap.visible {
    opacity: 1;
}

/* ---------- Main Menu ---------- */

#menu-overlay {
    justify-content: flex-end;
    padding-bottom: 6vh;
    gap: 22px;
}

.menu-title-wrap {
    position: absolute;
    top: 9vh;
    width: 100%;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 2;
}

.menu-hint {
    color: #fff;
    text-shadow: 0 2px 5px rgba(0,0,0,0.6);
    font-size: 0.95rem;
    text-align: center;
    padding: 0 12vw;
    z-index: 2;
}

.menu-settings-btn {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: 14px;
    z-index: 3;
}

/* ---------- Tutorial Prompt ---------- */

#tutorial-prompt-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
    z-index: 10;
}

.tutorial-prompt-text {
    color: #fff;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.tutorial-prompt-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.tutorial-prompt-btn {
    padding: 14px 30px;
    font-size: 1.1rem;
    white-space: nowrap;
}

#shop-tutorial-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
    z-index: 10;
}

#shop-ad-confirm-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
    z-index: 10;
}

/* ---------- How To Play ---------- */

#howtoplay-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
}

.htp-tabs {
    width: 100%;
    display: flex;
    gap: 8px;
}

.htp-tab {
    flex: 1;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 999px;
    padding: 8px 6px;
    cursor: pointer;
}

.htp-tab.active {
    color: #123a5c;
    background: linear-gradient(180deg, #f2fbff, #a9d8f2);
    border-color: rgba(255,255,255,0.6);
}

.htp-candy-icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    vertical-align: middle;
}

.panel {
    box-sizing: border-box;
    width: 88%;
    max-width: 440px;
    min-width: 0;
    max-height: 84vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(14, 28, 58, 0.92);
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 24px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #57515f rgba(0,0,0,0.2);
    /* Clips the custom scrollbar (drawn as a straight rectangle) to the same rounded
       rect as the panel itself - without this it pokes past the rounded corners into
       the background above/below the card. */
    clip-path: inset(0 round 24px);
}

/* Force the scrollbar thumb to always render (not just while scrolling), so players
   notice a panel is scrollable instead of assuming they've seen all of its content. */
.panel::-webkit-scrollbar {
    width: 4px;
}

.panel::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 999px;
}

.panel::-webkit-scrollbar-thumb {
    background: #57515f;
    border-radius: 999px;
}

.panel-title {
    color: var(--candy-blue);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    margin: 0;
}

.htp-sections {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.htp-section {
    min-width: 0;
}

.htp-section h3 {
    margin: 0 0 4px;
    color: var(--candy-gold);
    font-size: 1rem;
}

.htp-section p {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.9;
    white-space: pre-line;
    overflow-wrap: break-word;
}

/* ---------- Settings ---------- */

#settings-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
}

.settings-rows {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    color: #fff;
    font-size: 1rem;
}

.toggle-switch {
    flex: none;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.4);
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
}

.toggle-switch.on {
    background: linear-gradient(180deg, #34c98a, #1f8f60);
}

.toggle-switch.on::after {
    transform: translateX(24px);
}

/* ---------- Shop ---------- */

#shop-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
}

.shop-panel {
    max-width: 460px;
}

.shop-coin-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--candy-gold);
    font-size: 1.4rem;
    font-weight: 800;
    margin-top: -6px;
}

.shop-ad-plus {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(180deg, #34c98a, #1f8f60);
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0,0,0,0.25);
}

.shop-ad-plus:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}

.shop-tool-tabs {
    width: 100%;
    display: flex;
    gap: 10px;
}

.shop-tool-tab {
    flex: 1;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 16px;
    padding: 10px 6px;
    cursor: pointer;
}

.shop-tool-tab img {
    width: 108px;
    height: 108px;
    object-fit: contain;
}

.shop-tool-tab span {
    font-weight: 700;
    font-size: 0.8rem;
}

.shop-tool-tab.active {
    color: #5a3a10;
    background: linear-gradient(180deg, #ffe6b3, #e8b96a);
    border-color: rgba(255,255,255,0.6);
}

.shop-section-label {
    align-self: flex-start;
    color: var(--candy-blue);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.shop-rows {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shop-row {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 16px;
    padding: 12px 14px;
}

.shop-row-info {
    min-width: 0;
    flex: 1;
}

.shop-row-title {
    color: #fff;
    font-weight: 700;
    font-size: 0.98rem;
}

.shop-row-desc {
    color: rgba(255,255,255,0.75);
    font-size: 0.8rem;
    line-height: 1.35;
    margin: 3px 0 7px;
}

.shop-dots {
    display: flex;
    gap: 5px;
}

.shop-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
}

.shop-dot.filled {
    background: var(--candy-blue);
    border-color: var(--candy-blue);
}

.shop-buy-btn {
    flex: none;
    padding: 10px 16px;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.shop-buy-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.shop-btn-coin {
    width: 15px;
    height: 15px;
}

#btn-privacy {
    text-decoration: none;
    text-align: center;
}

#wheel-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
}

/* Main menu side buttons: Free Spins (left) and Shop (right). */
.menu-side-btn {
    position: absolute;
    top: 36vh;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
}

.menu-side-left { left: 14px; }
.menu-side-right { right: 14px; }

.menu-side-btn:active { transform: scale(0.94); }

.menu-side-label {
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    background: rgba(20, 10, 40, 0.55);
    border-radius: 999px;
    padding: 1px 10px;
}

.mini-wheel {
    position: relative;
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: conic-gradient(from -22.5deg,
        #5fd3ff 0 45deg, #ff7ab8 45deg 90deg, #a06bff 90deg 135deg, #ffcf4d 135deg 180deg,
        #5fd3ff 180deg 225deg, #ff7ab8 225deg 270deg, #a06bff 270deg 315deg, #ffcf4d 315deg 360deg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.45);
}

.mini-wheel-hub {
    position: absolute;
    inset: 50%;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #fff;
}

.mini-wheel-pointer {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 12px solid #fff;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.menu-side-btn.ready .mini-wheel {
    animation: mini-wheel-turn 6s linear infinite;
}

@keyframes mini-wheel-turn {
    to { transform: rotate(360deg); }
}

.menu-side-dot {
    position: absolute;
    top: 0;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff4757;
    border: 2px solid #fff;
    display: none;
}

.menu-side-btn.ready .menu-side-dot { display: block; }

.menu-cart {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: radial-gradient(circle at 35% 30%, #fff6c8, var(--candy-gold) 55%, #d99a0b 100%);
    color: var(--ink);
    box-shadow: 0 4px 10px rgba(0,0,0,0.45);
    animation: cart-bob 2.4s ease-in-out infinite;
}

.menu-cart svg {
    width: 34px;
    height: 34px;
}

@keyframes cart-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
    .menu-side-btn.ready .mini-wheel, .menu-cart { animation: none; }
}

.wheel-wrap {
    position: relative;
    width: min(280px, 70vw);
    aspect-ratio: 1;
}

.wheel-canvas {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35));
}

.wheel-pointer {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 26px solid #fff;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
    z-index: 1;
}

.wheel-result {
    min-height: 1.4em;
    color: var(--candy-gold);
    font-weight: 700;
    font-size: 1.05rem;
    text-align: center;
}

#btn-wheel-ad.hidden {
    display: none;
}

#btn-wheel-spin:disabled {
    opacity: 0.6;
    font-size: 1rem;
    cursor: default;
}

.shop-skins {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.shop-skin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 16px;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.shop-skin.equipped {
    border-color: var(--candy-gold);
    background: rgba(255, 207, 77, 0.12);
}

.shop-skin:disabled {
    opacity: 0.45;
    cursor: default;
}

.shop-skin-swatch {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
}

.shop-skin-name {
    font-weight: 700;
    font-size: 0.85rem;
}

.shop-skin-state {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.8);
}

.shop-skin.equipped .shop-skin-state {
    color: var(--candy-gold);
}

.shop-hint-row {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 16px;
    padding: 12px 14px;
}

.shop-hint-info {
    min-width: 0;
    flex: 1;
}

.shop-hint-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
}

.shop-hint-count .stat-icon {
    width: 17px;
    height: 17px;
}

.shop-hint-timer {
    color: var(--candy-blue);
    font-size: 0.78rem;
    font-weight: 700;
    margin: 2px 0 5px;
}

.shop-hint-desc {
    color: rgba(255,255,255,0.75);
    font-size: 0.78rem;
    line-height: 1.35;
}

/* ---------- Level Map ---------- */

#levelmap-overlay {
    justify-content: flex-start;
}

.map-shop-hint {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, 0);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 5;
    animation: mapShopHintBounce 1.2s ease-in-out infinite;
}

.map-shop-hint.hidden {
    display: none;
}

.map-shop-hint-arrow {
    font-size: 1.4rem;
    color: var(--candy-gold);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1;
    margin-bottom: 2px;
}

.map-shop-hint-text {
    background: rgba(20,10,40,0.9);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 12px;
    padding: 6px 10px;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

@keyframes mapShopHintBounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -4px); }
}

.levelmap-topbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: max(14px, env(safe-area-inset-top)) 14px 10px;
    gap: 8px;
    z-index: 3;
}

.levelmap-scroll {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.levelmap-path {
    position: relative;
    width: 100%;
    padding: 40px 0 60px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}

.level-node {
    position: relative;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin: 14px 0;
    border: 4px solid #fff;
    box-shadow: 0 6px 0 rgba(0,0,0,0.3), 0 10px 18px rgba(0,0,0,0.35);
    cursor: pointer;
}

.level-node.cleared {
    background: radial-gradient(circle at 35% 30%, #d6fff0, #34c98a 65%, #157a52);
}

.level-node.current {
    background: radial-gradient(circle at 35% 30%, #fff6c8, var(--candy-gold) 65%, #b8860b);
    animation: node-pulse 1.4s ease-in-out infinite;
}

.level-node.locked {
    background: radial-gradient(circle at 35% 30%, #cfcfe6, #7d7da0 65%, #4a4a63);
    opacity: 0.7;
    cursor: default;
}

.level-node.star-locked {
    background: radial-gradient(circle at 35% 30%, #dff4ff, #4aa8d8 65%, #1b5a80);
    opacity: 0.85;
    cursor: default;
    flex-direction: column;
    gap: 2px;
}

.star-lock-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.star-lock-req {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.72rem;
    font-weight: 700;
}

.star-lock-req .star-icon {
    width: 11px;
    height: 11px;
}

.level-node .star-row {
    position: absolute;
    bottom: -10px;
    display: flex;
    gap: 2px;
}

.level-node .star-row .star-icon {
    width: 14px;
    height: 14px;
}

@keyframes node-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ---------- Loading ---------- */

#loading-overlay {
    justify-content: center;
    gap: 22px;
    background: radial-gradient(circle at 50% 30%, #2a1852, #100a20);
}

.loading-text {
    color: #fff;
    font-size: 1.3rem;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.loading-bar-track {
    width: 60vw;
    height: 18px;
    background: rgba(0,0,0,0.45);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 999px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--candy-gold), #fff2b0);
    transition: width 0.25s ease;
}

/* ---------- Gameplay ---------- */

#gameplay-overlay {
    justify-content: flex-start;
    background: transparent;
    /* Lets taps/clicks fall through to the canvas underneath for chip/melt;
       only the back button re-enables itself below. */
    pointer-events: none;
}

.gameplay-topbar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 14px 0;
    z-index: 3;
    transition: opacity 0.35s ease;
}

.gameplay-topbar.reveal-hide,
.gameplay-rule.reveal-hide,
.tool-bar.reveal-hide,
.gameplay-back-btn.reveal-hide {
    opacity: 0;
    pointer-events: none;
}

.tool-bar {
    transition: opacity 0.35s ease;
}

/* Tightens the topbar's 4 pills (progress/timer/coins/hint) on narrow phones. */
/* Compact top bar. Raised from 380px to 430px so ordinary phones (a 412px-wide Android,
   say) get it too: the row carries five items now that the close button is laid out in
   flow instead of floating over the hint pill, and at full size that left the flexible
   progress track squeezed down to ~77px. */
@media (max-width: 430px) {
    .gameplay-topbar { gap: 6px; padding-left: 8px; padding-right: 8px; }
    .gameplay-topbar .timer-pill,
    .gameplay-topbar .coin-pill,
    .gameplay-topbar .gameplay-hint-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
        gap: 4px;
    }
}

.progress-track {
    position: relative;
    flex: 1;
    height: 28px;
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff5f6d, #34c98a);
    transition: width 0.2s ease;
}

.progress-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.timer-pill {
    flex: none;
    background: rgba(20, 10, 40, 0.55);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 999px;
    padding: 8px 14px;
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.timer-pill.tier-3 { color: #7dffc0; border-color: rgba(125,255,192,0.7); }
.timer-pill.tier-2 { color: #ffe066; border-color: rgba(255,224,102,0.7); }
.timer-pill.tier-1 { color: #ff8a7a; border-color: rgba(255,138,122,0.7); }

.combo-label {
    position: absolute;
    top: 34%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.6);
    color: var(--candy-gold);
    font-size: 2.2rem;
    font-weight: 800;
    text-shadow: 0 3px 0 #7a4a00, 0 6px 14px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.combo-label.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Persistent "Combo: 1.5x" readout, driven by ComboMeter.js - distinct from the big
   flashy .combo-label "Nx!" popup above (that one stays pickaxe-streak-only). Sits just
   above the tool-bar so it's readable no matter which tool is being used to build it. */
.combo-meter-text {
    position: absolute;
    left: 50%;
    bottom: calc(160px + env(safe-area-inset-bottom)); /* just above the tool bar */
    transform: translateX(-50%) scale(0.85);
    background: rgba(20, 10, 40, 0.6);
    border: 2px solid rgba(255,207,77,0.7);
    border-radius: 999px;
    padding: 6px 16px;
    color: var(--candy-gold);
    font-weight: 800;
    font-size: 0.95rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.combo-meter-text.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.combo-meter-text.reveal-hide {
    opacity: 0;
}

.tutorial-callout {
    position: absolute;
    left: 50%;
    bottom: 150px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 4;
    pointer-events: none;
    transition: bottom 0.3s ease, opacity 0.3s ease;
}

.tutorial-callout.hidden {
    display: none;
}

.tutorial-callout.step-hold {
    bottom: 208px;
}

.tutorial-callout.step-select {
    bottom: 290px;
}

.tool-point {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    margin-left: -0.6em;
    font-size: 2.4rem;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    animation: tutorial-point 1s ease-in-out infinite;
    pointer-events: none;
}

.tool-btn.point .tool-point {
    display: block;
}

.tutorial-callout.no-hand .tutorial-hand {
    display: none;
}

.tutorial-callout.advanceable {
    pointer-events: auto;
    cursor: pointer;
}

.tutorial-hand {
    font-size: 2.4rem;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
    animation: tutorial-point 1s ease-in-out infinite;
}

.tutorial-text {
    background: rgba(20, 10, 40, 0.75);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 14px;
    padding: 8px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 0.92rem;
    text-align: center;
    white-space: pre-line;
    max-width: min(84vw, 340px);
}

@keyframes tutorial-point {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

.gameplay-hint-btn {
    position: relative;
    pointer-events: auto;
    cursor: pointer;
    font-family: inherit;
    flex: none;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.gameplay-hint-btn:active {
    transform: scale(0.94);
}

.gameplay-hint-btn.empty {
    opacity: 0.45;
}

/* Sits in the top bar's flex row like every other HUD chip. It used to be absolutely
   positioned at right:14px while the row's last item (the hint pill) was also flush right,
   so the X was drawn on top of the red candy count. Laying it out in the row means the
   row's own gap keeps them apart, at any screen width, with no magic numbers. */
.gameplay-back-btn {
    flex: none;
    pointer-events: auto;
    z-index: 3;
}

.tool-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(50px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 24px;
    z-index: 3;
}

.tool-btn {
    position: relative;
    width: 96px;
    height: 96px;
    padding: 12px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.6);
    background: rgba(20,10,40,0.55);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

.tool-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform: scale(1.5); /* art has wide transparent margins - let it spill past the padding */
    pointer-events: none;
}

.tool-btn.selected {
    border-color: #34c98a;
    box-shadow: 0 0 0 3px rgba(52,201,138,0.5), 0 6px 14px rgba(0,0,0,0.35);
    transform: translateY(-21px);
}

/* ---------- Hairdryer Overheat (see HairdryerOverheat.js) ---------- */

/* Progress ring for both the heating-up meter and the cooldown drain, driven by the
   --heat custom property (0..1) GameplayScreen sets each frame. Amber while heating,
   icy blue while locked out during cooldown; hidden the rest of the time. */
.tool-btn::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(var(--heat-ring-color, #ffcf4d) calc(var(--heat, 0) * 360deg), transparent 0);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tool-btn.heating::after {
    opacity: 1;
}

.tool-btn.locked::after {
    opacity: 1;
    --heat-ring-color: #5fd3ff;
}

.tool-btn.overheating {
    border-color: #ff5a3d;
    animation: overheat-pulse 0.5s ease-in-out infinite;
}

.tool-btn.locked {
    opacity: 0.55;
}

/* Not reached yet in the tool progression (see TOOL_UNLOCK_LEVEL in data/levels.js). */
.tool-btn.tool-locked,
.shop-tool-tab.tool-locked {
    display: none;
}

@keyframes overheat-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(255,90,61,0.6), 0 6px 14px rgba(0,0,0,0.35); }
    50% { box-shadow: 0 0 0 7px rgba(255,90,61,0.3), 0 6px 14px rgba(0,0,0,0.35); }
}

/* ---------- Level Clear ---------- */

#levelclear-overlay {
    justify-content: center;
    background: rgba(0,0,0,0.6);
    /* Purely visual - "tap to continue" is read from the canvas's pointer input. */
    pointer-events: none;
}

.levelclear-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transform: scale(0.6);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(.2,1.4,.4,1), opacity 0.3s ease;
}

.levelclear-panel.visible {
    transform: scale(1);
    opacity: 1;
}

.levelclear-title {
    color: var(--candy-gold);
    font-size: 2.4rem;
    text-shadow: 0 3px 0 #7a4a00, 0 6px 14px rgba(0,0,0,0.5);
    margin: 0;
}

.levelclear-stars {
    display: flex;
    gap: 10px;
    margin: 2px 0 4px;
}

.lc-star {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #4a4a63, #33334a 65%, #22222f);
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.4);
    transform: scale(0.5);
    opacity: 0.5;
    transition: transform 0.4s cubic-bezier(.2,1.6,.4,1), opacity 0.25s ease, background 0.25s ease;
}

.lc-star.filled {
    background: radial-gradient(circle at 35% 30%, #fff, #5fd3ff 60%, #1b6faa 100%);
    transform: scale(1);
    opacity: 1;
}

.levelclear-stats {
    color: #fff;
    text-align: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.levelclear-stats.visible {
    opacity: 1;
}

.lc-line {
    font-size: 1rem;
    margin: 2px 0;
}

.lc-coins {
    color: var(--candy-gold);
    font-size: 1.8rem;
    font-weight: 800;
    text-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

.levelclear-actions {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.lc-btn-next {
    padding: 14px 30px;
    font-size: 1.1rem;
}

.lc-btn-map {
    padding: 10px 22px;
    font-size: 0.95rem;
}

/* ---------- Main menu: Daily Thing / My Things ---------- */

.menu-row {
    display: flex;
    gap: 10px;
}

.menu-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 148px;
    padding: 10px 12px;
    border-radius: 22px;
    line-height: 1.2;
}

.menu-tile-sub {
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.8;
}

.menu-tile:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ---------- My Things (collection) ---------- */

#collection-overlay {
    justify-content: center;
    background: rgba(10, 8, 20, 0.85);
}

.collection-count {
    color: #fff;
    font-weight: 700;
    opacity: 0.9;
}

.collection-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.collection-tile {
    font-family: inherit;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    color: #fff;
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.35);
    border-radius: 14px;
    cursor: pointer;
}

.collection-tile.frozen {
    cursor: default;
    opacity: 0.75;
}

.collection-tile img,
.collection-frost {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 10px;
}

.collection-tile img {
    object-fit: cover;
    background: #fff;
}

.collection-frost {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: rgba(255,255,255,0.85);
    background: linear-gradient(160deg, #dff4ff, #7fbfe6 60%, #3f86bf);
}

.collection-name {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

.collection-stars {
    display: flex;
    gap: 2px;
    min-height: 11px;
}

.collection-stars .star-icon {
    width: 11px;
    height: 11px;
}

/* ---------- Gameplay: level rule, reveal name, floating labels ---------- */

.gameplay-rule {
    margin-top: 8px;
    max-width: 92vw;
    padding: 4px 14px;
    background: rgba(20, 10, 40, 0.6);
    border: 2px solid rgba(95,211,255,0.7);
    border-radius: 999px;
    color: #dff4ff;
    font-weight: 700;
    font-size: 0.8rem;
    text-align: center;
    z-index: 3;
    transition: opacity 0.35s ease;
}

.gameplay-rule.hidden {
    display: none;
}

.gameplay-reveal-name {
    /* Sits where the top bar was - that fades out for the reveal, and the photo card
       below it is white, which white text can't sit on. */
    position: absolute;
    top: max(26px, env(safe-area-inset-top));
    left: 5%;
    width: 90%;
    color: #fff;
    font-size: 1.9rem;
    font-weight: 800;
    text-align: center;
    text-shadow: 0 3px 0 #1b4a70, 0 6px 14px rgba(0,0,0,0.5);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 4;
}

.gameplay-reveal-name.show {
    opacity: 1;
    transform: scale(1);
}

#gameplay-floats {
    position: absolute;
    inset: 0;
    z-index: 5;
}

.gameplay-float {
    position: absolute;
    font-weight: 800;
    font-size: 1.3rem;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    animation: float-up 0.9s ease-out forwards;
}

.gameplay-float.bonus {
    color: var(--candy-gold);
}

.gameplay-float.penalty {
    color: #ff5a3d;
    font-size: 1.7rem;
    text-shadow: 0 2px 0 #fff, 0 3px 8px rgba(0,0,0,0.6);
}

@keyframes float-up {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
    20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -220%) scale(1); }
}

.lc-name {
    padding: 0 20px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

/* ---------- How to Play: Stats tab ---------- */

.htp-stats {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
}

.htp-stats th {
    color: var(--candy-gold);
    padding: 4px 2px;
}

.htp-stats td {
    padding: 4px 2px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

/* Shown above the last node once every level is cleared (LevelMapScreen._buildNodes). */
.levelmap-more {
    margin: 10px 0 24px;
    padding: 10px 22px;
    background: rgba(20, 10, 40, 0.6);
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 999px;
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    text-decoration: none;
}

/* "x" in a panel's top-right corner (see main.js). Sticky so it stays reachable while the
   panel scrolls; the negative margins keep it from pushing the title down. */
.panel-close {
    position: sticky;
    top: 0;
    align-self: flex-end;
    flex: none;
    width: 36px;
    height: 36px;
    margin: -10px -6px -42px 0;
    z-index: 2;
}

/* ---------- Gameplay: object health (cracks) and Level Lost ---------- */

.gameplay-health {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(20, 10, 40, 0.55);
    border-radius: 999px;
    z-index: 3;
    transition: opacity 0.35s ease;
}

.gameplay-health.hidden,
.gameplay-health.reveal-hide {
    display: none;
}

.health-gem {
    width: 26px;
    height: 26px;
    display: block;
}

.health-gem .gem-body { fill: #8fe3ff; stroke: #1b6faa; stroke-width: 1.4; stroke-linejoin: round; }
.health-gem .gem-shine { fill: rgba(255, 255, 255, 0.5); }
.health-gem .gem-crack { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }

.health-gem.broken .gem-body { fill: #4d5568; stroke: #2a2f3c; }
.health-gem.broken .gem-shine { fill: rgba(255, 255, 255, 0.12); }
.health-gem.broken .gem-crack { opacity: 1; }
.health-gem.just-broken { animation: gem-break 0.45s ease-out; }

@keyframes gem-break {
    0% { transform: scale(1); }
    25% { transform: scale(1.45) rotate(-12deg); }
    50% { transform: scale(0.9) rotate(9deg); }
    100% { transform: scale(1) rotate(0); }
}

#levellost-overlay {
    justify-content: center;
    background: rgba(40, 0, 10, 0.62);
    pointer-events: none;
}

.levellost-title {
    color: #ff7a6b;
    text-shadow: 0 3px 0 #6a1010, 0 6px 14px rgba(0,0,0,0.5);
}

.levellost-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.levellost-actions .candy-btn-primary {
    padding: 14px 30px;
    font-size: 1.1rem;
}

#ll-msg {
    color: #fff;
    min-height: 1.3em;
    text-align: center;
    padding: 0 20px;
}

.levellost-actions .candy-btn:disabled { opacity: 0.6; }

#btn-privacy-options.hidden {
    display: none;
}
