/* ==================================================================
   Animal Mahjong 3D — style.css
   Premium casual-game UI. Font: Baloo 2. Mobile-first, safe-area
   aware, GPU-friendly transitions only (opacity/transform).
   ================================================================== */

:root {
    --c-primary: #58B368;
    --c-primary-dark: #3E9450;
    --c-accent: #F7B32B;
    --c-accent-dark: #D69316;
    --c-danger: #E86A5E;
    --c-panel: rgba(255, 255, 255, 0.94);
    --c-ink: #3A3145;
    --c-ink-soft: #7A7287;
    --radius: 22px;
    --shadow: 0 10px 30px rgba(40, 60, 40, 0.25);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Game-style UI: never show browser scrollbars anywhere */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'Baloo 2', 'Comic Sans MS', cursive, sans-serif;
    background: #87CEEB;
    color: var(--c-ink);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

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

/* ==================================================================
   LOADING SCREEN
   ================================================================== */
#loading-screen {
    position: fixed; inset: 0; z-index: 100;
    background: linear-gradient(160deg, #A8E063 0%, #56AB2F 60%, #2E7D32 100%);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.6s ease;
}
#loading-screen.done { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; padding: 24px; }
#loading-cube {
    width: 96px; height: 96px; object-fit: contain;
    animation: pawBounce 1.2s ease-in-out infinite;
    filter: drop-shadow(0 10px 14px rgba(0, 40, 0, 0.3));
}
/* fallback size box even before the image src arrives */
#loading-cube:not([src]) { visibility: hidden; }
.loading-paw { font-size: 64px; animation: pawBounce 1.2s ease-in-out infinite; }
@keyframes pawBounce {
    0%, 100% { transform: translateY(0) rotate(-8deg); }
    50% { transform: translateY(-18px) rotate(8deg); }
}
.loading-title {
    color: #fff; font-size: 34px; font-weight: 800;
    text-shadow: 0 3px 0 rgba(0,0,0,0.18);
    margin: 12px 0 20px;
}
.loading-title span { color: #FFE96B; }
.loading-bar {
    width: min(320px, 70vw); height: 16px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px; overflow: hidden;
    margin: 0 auto;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.15);
}
#loading-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #FFE96B, #F7B32B);
    border-radius: 10px;
    transition: width 0.4s ease;
}
.loading-tip { color: rgba(255,255,255,0.9); margin-top: 14px; font-size: 15px; }

/* ==================================================================
   SCREEN / OVERLAY BASE
   ================================================================== */
#ui-root { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center;
    opacity: 0; transform: translateY(12px) scale(0.99);
    transition: opacity 0.32s ease, transform 0.32s ease;
    pointer-events: none;
}
.screen.visible { opacity: 1; transform: none; pointer-events: auto; }

.overlay {
    background: rgba(30, 40, 30, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    justify-content: center;
}

/* ==================================================================
   BUTTONS — chunky 3D style: extruded base, top bevel, press-down
   ================================================================== */
button {
    font-family: inherit; border: none; cursor: pointer;
    font-weight: 700; color: #fff;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.12s ease;
}

.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
    display: block; width: min(300px, 78vw);
    padding: 13px 22px; margin: 10px auto;
    border-radius: var(--radius);
    font-size: 19px; font-weight: 800; letter-spacing: 0.6px;
    border: 2px solid rgba(255,255,255,0.55);
    text-shadow: 0 2px 0 rgba(0,0,0,0.28), 0 4px 6px rgba(0,0,0,0.18);
}
.btn-primary {
    background: linear-gradient(180deg, #7DD48C 0%, #58B368 45%, var(--c-primary-dark) 100%);
    box-shadow: 0 7px 0 #2C6B38, 0 12px 22px rgba(20, 60, 25, 0.4),
                inset 0 2px 0 rgba(255,255,255,0.45);
}
.btn-primary:active { transform: translateY(5px); box-shadow: 0 2px 0 #2C6B38, inset 0 2px 0 rgba(255,255,255,0.45); }
.btn-secondary {
    background: linear-gradient(180deg, #77BCF0 0%, #5AA9E6 45%, #3E7BB5 100%);
    box-shadow: 0 7px 0 #2A5A8A, 0 12px 22px rgba(15, 45, 80, 0.4),
                inset 0 2px 0 rgba(255,255,255,0.45);
}
.btn-secondary:active { transform: translateY(5px); box-shadow: 0 2px 0 #2A5A8A, inset 0 2px 0 rgba(255,255,255,0.45); }
.btn-purple {
    display: block; width: min(300px, 78vw);
    padding: 13px 22px; margin: 8px auto;
    border-radius: var(--radius);
    font-size: 19px; font-weight: 800; letter-spacing: 0.6px;
    border: 2px solid rgba(255,255,255,0.55);
    text-shadow: 0 2px 0 rgba(0,0,0,0.28), 0 4px 6px rgba(0,0,0,0.18);
    background: linear-gradient(180deg, #A985E8 0%, #8B5FD6 45%, #6A3FB0 100%);
    box-shadow: 0 7px 0 #4E2B8A, 0 12px 22px rgba(40, 15, 80, 0.4),
                inset 0 2px 0 rgba(255,255,255,0.45);
}
.btn-purple:active { transform: translateY(5px); box-shadow: 0 2px 0 #4E2B8A, inset 0 2px 0 rgba(255,255,255,0.45); }

/* Play button: big PLAY + small LEVEL N below (reference style) */
.btn-play { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 11px 22px; }
.bp-main { font-size: 24px; letter-spacing: 3px; pointer-events: none; }
.bp-sub { font-size: 13px; letter-spacing: 2px; opacity: 0.92; pointer-events: none; }
.btn-danger {
    background: linear-gradient(180deg, #F49A8E 0%, #E86A5E 50%, #C74A3E 100%);
    box-shadow: 0 7px 0 #93362D, 0 12px 22px rgba(90, 25, 18, 0.4),
                inset 0 2px 0 rgba(255,255,255,0.4);
    margin-top: 26px;
}
.btn-danger:active { transform: translateY(5px); box-shadow: 0 2px 0 #93362D; }
.btn-ghost {
    background: transparent; color: var(--c-ink-soft);
    box-shadow: none; border: none; font-size: 16px; padding: 8px;
    text-shadow: none;
}
.btn-play { font-size: 21px; }

.btn-back {
    width: 56px; height: 56px; border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #FFEDB0 0%, #FFD873 30%, #F5A623 70%, #E8940F 100%);
    color: #A85E10; font-size: 24px; flex: 0 0 auto;
    border: 3px solid #FFDF8A;
    box-shadow: 0 6px 0 #C77E0A, 0 10px 18px rgba(150, 90, 0, 0.35),
                inset 0 3px 6px rgba(255,255,255,0.55), inset 0 -4px 6px rgba(180,100,0,0.3);
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}
.btn-back:active { transform: translateY(4px); box-shadow: 0 2px 0 #C77E0A, inset 0 3px 6px rgba(255,255,255,0.55); }

/* Golden round arcade button (matches the round gold reference set) */
.btn-round {
    width: 62px; height: 62px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 35% 28%, #FFEDB0 0%, #FFD873 30%, #F5A623 70%, #E8940F 100%);
    color: #A85E10; font-size: 24px; font-weight: 800;
    border: 3px solid #FFDF8A;
    box-shadow: 0 7px 0 #C77E0A, 0 12px 20px rgba(150, 90, 0, 0.38),
                inset 0 3px 6px rgba(255,255,255,0.55), inset 0 -4px 6px rgba(180,100,0,0.3);
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
    flex: 0 0 auto;
}
.btn-round:active { transform: translateY(5px); box-shadow: 0 2px 0 #C77E0A, inset 0 3px 6px rgba(255,255,255,0.55); }

.btn-small {
    flex: 1; padding: 9px 6px; border-radius: 16px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F1EAE0 100%);
    color: var(--c-ink);
    font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 1px;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 5px 0 #C9BFAF, 0 9px 16px rgba(60, 50, 30, 0.22);
}
.btn-small:active { transform: translateY(4px); box-shadow: 0 1px 0 #C9BFAF; }
.btn-small label { font-size: 12px; font-weight: 800; color: var(--c-ink-soft); pointer-events: none; letter-spacing: 0.3px; }

.btn-buy {
    padding: 10px 16px; border-radius: 14px; font-size: 15px;
    background: linear-gradient(180deg, #FFDD75 0%, #FFCE55 45%, var(--c-accent-dark) 100%);
    border: 2px solid rgba(255,255,255,0.55);
    box-shadow: 0 4px 0 #A8720E, 0 7px 12px rgba(120, 80, 0, 0.3);
    text-shadow: 0 1px 0 rgba(0,0,0,0.2);
    white-space: nowrap; flex: 0 0 auto;
}
.btn-buy:active { transform: translateY(3px); box-shadow: 0 1px 0 #A8720E; }
.btn-buy.active {
    background: #B8E0BE; color: #2E6B38; cursor: default;
    border-color: rgba(255,255,255,0.7);
    box-shadow: 0 4px 0 #8AB392; text-shadow: none;
}

/* ==================================================================
   MAIN MENU
   ================================================================== */
.menu-screen {
    justify-content: center;
    padding: calc(12px + var(--safe-top)) 20px calc(12px + var(--safe-bottom));
    overflow: hidden; gap: 14px;
}
.menu-header { perspective: 700px; display: flex; flex-direction: column; align-items: center; }

/* circular settings button — fixed top right */
.btn-circle {
    position: absolute;
    top: calc(16px + var(--safe-top)); right: 18px;
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #FFFFFF 0%, #EDE6DA 100%);
    font-size: 26px;
    border: 3px solid rgba(255,255,255,0.95);
    box-shadow: 0 6px 0 #C2B8A6, 0 10px 20px rgba(60, 50, 30, 0.3),
                inset 0 2px 4px rgba(255,255,255,0.8);
    z-index: 5;
}
.btn-circle:active { transform: translateY(4px); box-shadow: 0 2px 0 #C2B8A6; }

/* logo row: ONE big cube left + stacked title right */
.logo-row {
    display: flex; align-items: center; justify-content: center;
    gap: 20px;
}
.logo-row .menu-cube { width: 96px; height: 96px; flex: 0 0 auto; }
.menu-cube img { width: 100%; height: 100%; display: block; object-fit: contain; }
.title-stack { align-items: flex-start; }

/* ---- menu logo cube: single pre-composed 2.5D image ---- */
.menu-cube {
    animation: cubeFloat 3.2s ease-in-out infinite;
    filter: drop-shadow(0 10px 14px rgba(30, 60, 30, 0.3));
}
@keyframes cubeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-9px); }
}

/* ---- stacked 3D arcade title: left-aligned beside the cube ---- */
.title-stack { display: flex; flex-direction: column; gap: 0; line-height: 1.04; }
.title-line {
    font-weight: 800; letter-spacing: 2px; text-align: center;
}
.title-white {
    font-size: clamp(34px, 8.5vw, 52px); color: #FFFDF6;
    text-shadow:
        0 1px 0 #E8E0D2, 0 2px 0 #CBc2B0, 0 3px 0 #A89E8A,
        0 4px 0 #7A7260, 0 5px 0 #5C5648,
        0 10px 18px rgba(0,0,0,0.35);
}
.title-gold {
    font-size: clamp(30px, 7.6vw, 46px); color: #FFC933;
    text-shadow:
        0 1px 0 #F0AF1D, 0 2px 0 #D89A10, 0 3px 0 #B87F08,
        0 4px 0 #966604, 0 5px 0 #7A5202,
        0 10px 18px rgba(0,0,0,0.35);
}
.title-green {
    font-size: clamp(26px, 6.4vw, 38px); color: #7ED957;
    display: flex; align-items: center; gap: 8px;
    text-shadow:
        0 1px 0 #5FBE3C, 0 2px 0 #46A028, 0 3px 0 #338318,
        0 4px 0 #26680F, 0 10px 16px rgba(0,0,0,0.35);
}
.title-leaf { font-size: 0.65em; filter: drop-shadow(0 3px 3px rgba(0,0,0,0.25)); }
.leaf-l { transform: scaleX(-1); }

/* ---- ribbon banner subtitle ---- */
.ribbon {
    position: relative; margin: 16px auto 0;
    background: linear-gradient(180deg, #66B54E 0%, #4E9A3D 55%, #3E7D31 100%);
    border-radius: 8px;
    padding: 7px 26px;
    box-shadow: 0 4px 0 #2C6322, 0 8px 14px rgba(20, 60, 20, 0.35),
                inset 0 2px 0 rgba(255,255,255,0.3);
    width: fit-content;
}
.ribbon::before, .ribbon::after {
    content: ''; position: absolute; top: 5px; width: 18px; height: 82%;
    background: #34702A; z-index: -1;
}
.ribbon::before { left: -12px; transform: skewY(18deg); border-radius: 4px 0 0 4px; }
.ribbon::after { right: -12px; transform: skewY(-18deg); border-radius: 0 4px 4px 0; }
.ribbon-text {
    color: #FFFDF2; font-weight: 800; font-size: clamp(11px, 2.8vw, 14px);
    letter-spacing: 2px; text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.menu-coins {
    margin: 0 auto; padding: 9px 24px;
    background: linear-gradient(180deg, #FFFFFF, #F1EAE0);
    border-radius: 30px;
    font-weight: 800; font-size: 16px;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 5px 0 #C9BFAF, 0 9px 18px rgba(60, 50, 30, 0.25);
}
.menu-buttons { width: min(340px, 88vw); display: flex; flex-direction: column; gap: 6px; }
.menu-row { display: flex; gap: 14px; margin: 10px auto 0; width: 100%; }

/* Short screens: shrink menu chrome so everything stays visible */
@media (max-height: 700px) {
    .logo-row .menu-cube { width: 78px; height: 78px; }
    .logo-row .mc-front { transform: translateZ(39px); }
    .logo-row .mc-side { transform: rotateY(90deg) translateZ(39px); }
    .logo-row .mc-top  { transform: rotateX(90deg) translateZ(39px); }
    .title-white { font-size: clamp(26px, 6.4vw, 38px); }
    .title-gold { font-size: clamp(23px, 5.8vw, 34px); }
    .title-green { font-size: clamp(20px, 5vw, 28px); }
    .menu-screen { gap: 9px; }
    .btn-primary, .btn-secondary { padding: 11px 20px; font-size: 17px; margin: 5px auto; }
    .bp-main { font-size: 20px; }
    .btn-small { font-size: 18px; padding: 7px 4px; }
    .btn-small label { font-size: 11px; }
    .menu-coins { font-size: 14px; padding: 6px 18px; }
    .btn-circle { width: 50px; height: 50px; font-size: 22px; }
}

/* ==================================================================
   PANELS (level select, shop, etc.)
   ================================================================== */
.panel-screen {
    background: linear-gradient(160deg, rgba(168,224,99,0.96), rgba(86,171,47,0.96));
    padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
}
.panel-header {
    display: flex; align-items: center; gap: 14px;
    width: min(560px, 94vw); padding: 6px 2px 12px;
}
.panel-header h2 {
    color: #fff; font-size: 26px; font-weight: 800;
    text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}
.panel-scroll {
    width: min(560px, 94vw); flex: 1;
    overflow-y: auto; padding: 4px 2px 30px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* ===== SELECT LEVEL screen: big title, centered 5×4 grid, side arrows ===== */
.level-screen {
    justify-content: center; gap: 6px;
    padding: calc(14px + var(--safe-top)) 14px calc(18px + var(--safe-bottom));
}
.select-title {
    color: #fff; font-size: clamp(30px, 7vw, 46px); font-weight: 800;
    letter-spacing: 4px; text-align: center; margin-bottom: 8px;
    text-shadow:
        0 1px 0 #DDF3E0, 0 2px 0 #B9E3C1, 0 3px 0 #7FC290,
        0 4px 0 #4F9A63, 0 5px 0 var(--c-primary-dark),
        0 6px 0 #2C6B38, 0 12px 24px rgba(0,0,0,0.4);
}
.level-mid {
    display: flex; align-items: center; gap: 14px;
    width: min(640px, 96vw); justify-content: center;
}
.level-mid .level-grid { flex: 1; max-width: 460px; }
.level-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 12px; align-content: center;
}
.btn-back-wide {
    width: min(240px, 60vw); font-size: 22px; letter-spacing: 3px;
    margin-top: 14px;
}
.level-cell {
    aspect-ratio: 1; border-radius: 18px;
    background: linear-gradient(180deg, #FFF6E8, #F3E3C8);
    color: #7A4E17;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 6px 0 #C9A567, 0 10px 18px rgba(60, 40, 10, 0.28);
    border: 2px solid rgba(255,255,255,0.7);
    font-weight: 800;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.level-cell:active { transform: translateY(4px); box-shadow: 0 2px 0 #C9A567; }
.level-cell.current {
    background: linear-gradient(180deg, #FFD98A, #F7B32B);
    color: #6B4400;
    box-shadow: 0 6px 0 #B57F12, 0 10px 20px rgba(120, 80, 0, 0.35);
    animation: currentPulse 1.6s ease-in-out infinite;
}
@keyframes currentPulse { 50% { transform: scale(1.06); } }
.level-cell .lv-num { font-size: 20px; }
.level-cell .lv-stars { font-size: 12px; color: #C77800; letter-spacing: 1px; }
.level-cell.locked {
    background: rgba(70, 60, 90, 0.35); box-shadow: none;
    border-color: rgba(255,255,255,0.15); cursor: default;
}
.level-cell .lv-lock { font-size: 20px; opacity: 0.75; }

/* page navigation — golden round arrows beside the grid */
.page-nav {
    display: flex; align-items: center; justify-content: center;
    gap: 22px; padding: 16px 0 6px;
}
.btn-page {
    width: 64px; height: 64px; border-radius: 50%; font-size: 24px;
    background: radial-gradient(circle at 35% 28%, #FFEDB0 0%, #FFD873 30%, #F5A623 70%, #E8940F 100%);
    color: #A85E10;
    border: 3px solid #FFDF8A;
    box-shadow: 0 7px 0 #C77E0A, 0 12px 20px rgba(150, 90, 0, 0.38),
                inset 0 3px 6px rgba(255,255,255,0.55), inset 0 -4px 6px rgba(180,100,0,0.3);
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}
.btn-page:active { transform: translateY(5px); box-shadow: 0 2px 0 #C77E0A, inset 0 3px 6px rgba(255,255,255,0.55); }
.btn-page.disabled {
    filter: grayscale(0.9) brightness(0.75); pointer-events: none;
}
.page-label {
    color: #fff; font-weight: 800; font-size: 21px;
    text-shadow: 0 2px 0 rgba(0,0,0,0.25), 0 4px 8px rgba(0,0,0,0.2);
    min-width: 70px; text-align: center; letter-spacing: 1px;
}

/* scroll-arrow navigation for tall panels */
.scroll-wrap {
    position: relative; width: min(560px, 94vw); flex: 1;
    display: flex; overflow: hidden;
}
.scroll-wrap .panel-scroll { width: 100%; }
.scroll-arrows {
    position: absolute; right: 4px; bottom: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.btn-scroll {
    width: 54px; height: 54px; border-radius: 50%; font-size: 18px;
    background: radial-gradient(circle at 35% 28%, #FFEDB0 0%, #FFD873 30%, #F5A623 70%, #E8940F 100%);
    color: #A85E10;
    border: 3px solid #FFDF8A;
    box-shadow: 0 6px 0 #C77E0A, 0 10px 16px rgba(150, 90, 0, 0.35),
                inset 0 3px 6px rgba(255,255,255,0.55), inset 0 -4px 6px rgba(180,100,0,0.3);
    opacity: 0.96;
}
.btn-scroll:active { transform: translateY(3px); box-shadow: 0 2px 0 #C77E0A; }

/* ==================================================================
   HUD
   ================================================================== */
.hud-screen { justify-content: space-between; pointer-events: none; }
.hud-screen.visible { pointer-events: none; }
.hud-top {
    width: 100%; display: flex; justify-content: space-between; align-items: flex-start;
    padding: calc(10px + var(--safe-top)) 12px 0;
}
.hud-stat {
    background: var(--c-panel); border-radius: 30px;
    padding: 8px 16px; font-weight: 800; font-size: 16px;
    box-shadow: var(--shadow); pointer-events: auto;
}
.hud-stat.small { font-size: 13px; color: var(--c-ink-soft); }
.hud-stat.small b { color: var(--c-ink); }
.hud-center { text-align: center; }
.hud-level {
    background: linear-gradient(180deg, #7DD48C 0%, #58B368 45%, var(--c-primary-dark) 100%);
    color: #fff; border-radius: 30px; padding: 9px 28px;
    font-weight: 800; font-size: 18px; letter-spacing: 1px;
    border: 2px solid rgba(255,255,255,0.6);
    box-shadow: 0 5px 0 #2C6B38, 0 10px 18px rgba(20, 60, 25, 0.35),
                inset 0 2px 0 rgba(255,255,255,0.45);
    text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.hud-timer {
    margin-top: 6px; font-weight: 800; font-size: 15px;
    color: #fff; text-shadow: 0 2px 3px rgba(0,0,0,0.35);
}
.hud-timer.danger { color: #FF8A80; animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* ---- left stat pills: icon badge + white pill (premium style) ---- */
.hud-score-col {
    position: absolute; top: calc(74px + var(--safe-top));
    left: 14px; display: flex; flex-direction: column; gap: 10px;
}
.stat-pill {
    display: flex; align-items: center;
    background: linear-gradient(180deg, #FFFFFF, #F3EDE3);
    border-radius: 30px;
    padding: 4px 16px 4px 4px;
    border: 2px solid rgba(255,255,255,0.95);
    box-shadow: 0 5px 0 #C9BFAF, 0 9px 16px rgba(60, 50, 30, 0.25);
    min-width: 128px;
}
.sp-icon {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; margin-right: 9px; flex: 0 0 auto;
    box-shadow: inset 0 -3px 5px rgba(0,0,0,0.18), inset 0 2px 3px rgba(255,255,255,0.45),
                0 2px 5px rgba(0,0,0,0.2);
}
.sp-purple { background: linear-gradient(180deg, #A985E8, #7B4FC8); }
.sp-blue   { background: linear-gradient(180deg, #6FB7F0, #3E7BB5); }
.sp-gold   { background: linear-gradient(180deg, #FFD873, #E8940F); }
.sp-amber  { background: linear-gradient(180deg, #FFCB52, #D9820B); }
.sp-green  { background: linear-gradient(180deg, #7DD48C, #3E9450); }
.sp-body { display: flex; flex-direction: column; line-height: 1.1; }
.sp-body label { font-size: 10px; font-weight: 800; letter-spacing: 1.4px; color: var(--c-ink-soft); }
.sp-body b { font-size: 17px; font-weight: 800; color: var(--c-ink); }

.hud-bottom {
    width: 100%; display: flex; justify-content: center; gap: 8px;
    padding: 0 10px calc(12px + var(--safe-bottom));
    flex-wrap: wrap;
}
.hud-btn {
    position: relative;
    min-width: 62px; padding: 9px 10px; border-radius: 18px;
    background: linear-gradient(180deg, #FFFFFF 0%, #F1EAE0 100%);
    color: var(--c-ink);
    font-size: 20px; display: flex; flex-direction: column; align-items: center;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 6px 0 #C9BFAF, 0 10px 18px rgba(60, 50, 30, 0.25);
    pointer-events: auto;
}
.hud-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #C9BFAF; }
.hud-btn label { font-size: 11px; font-weight: 700; color: var(--c-ink-soft); pointer-events: none; }
.hud-btn .pcount {
    position: absolute; top: -6px; right: -4px;
    background: var(--c-accent); color: #fff;
    min-width: 22px; height: 22px; border-radius: 12px;
    font-size: 12px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

/* ==================================================================
   DIALOGS
   ================================================================== */
.dialog-card {
    background: var(--c-panel); border-radius: 28px;
    width: min(400px, 90vw); max-height: 86vh; overflow-y: auto;
    padding: 26px 22px; text-align: center;
    box-shadow: 0 24px 60px rgba(0, 30, 10, 0.35);
    animation: cardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
}
@keyframes cardIn {
    from { transform: translateY(50px) scale(0.9); opacity: 0; }
    to { transform: none; opacity: 1; }
}
.dialog-card h2 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.dialog-sub { color: var(--c-ink-soft); margin-bottom: 14px; }
.dialog-row { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.dialog-row .btn-primary, .dialog-row .btn-secondary { width: auto; flex: 1; margin: 0; }

/* victory */
.star-row { font-size: 46px; margin: 6px 0 10px; }
.vstar { display: inline-block; color: #D8D3CC; margin: 0 4px; transform: scale(0); animation: starPop 0.5s cubic-bezier(0.34, 1.8, 0.64, 1) forwards; }
.vstar.earned { color: var(--c-accent); text-shadow: 0 3px 8px rgba(247, 179, 43, 0.5); }
@keyframes starPop { to { transform: scale(1) rotate(0); } }
.result-lines { margin-bottom: 12px; color: var(--c-ink-soft); font-size: 16px; }
.result-lines b { color: var(--c-ink); }

/* card reveal */
.animal-card-reveal {
    background: linear-gradient(160deg, #FFF8E6, #FFEFC2);
    border: 3px solid var(--c-accent);
    border-radius: 22px; padding: 14px; margin: 10px 0 14px;
    animation: cardIn 0.6s 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.ac-badge {
    display: inline-block; background: var(--c-accent); color: #fff;
    font-size: 11px; font-weight: 800; letter-spacing: 1.5px;
    padding: 3px 12px; border-radius: 10px; margin-bottom: 8px;
}
.ac-emoji {
    width: 84px; height: 84px; margin: 0 auto 8px;
    border-radius: 22px; font-size: 48px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 -6px 12px rgba(0,0,0,0.12), 0 6px 14px rgba(0,0,0,0.15);
}
.ac-emoji.big { width: 100px; height: 100px; font-size: 60px; }
.ac-name { font-size: 20px; font-weight: 800; }
.ac-fact { font-size: 14px; color: var(--c-ink-soft); margin: 6px 0 8px; }
.ac-meta { display: flex; justify-content: center; gap: 14px; font-size: 13px; font-weight: 700; color: var(--c-ink); }

/* ==================================================================
   ACHIEVEMENTS / STATS / COLLECTION / SHOP / SETTINGS
   ================================================================== */
.ach-row {
    display: flex; align-items: center; gap: 14px;
    background: rgba(255,255,255,0.55); border-radius: 18px;
    padding: 12px 16px; margin-bottom: 10px;
}
.ach-row.unlocked { background: var(--c-panel); }
.ach-icon { font-size: 30px; filter: grayscale(1) opacity(0.5); }
.ach-row.unlocked .ach-icon { filter: none; }
.ach-info { flex: 1; display: flex; flex-direction: column; }
.ach-info span { font-size: 13px; color: var(--c-ink-soft); }
.ach-state { font-weight: 800; color: var(--c-primary-dark); white-space: nowrap; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat-cell {
    background: var(--c-panel); border-radius: 18px; padding: 16px 10px;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.stat-cell b { font-size: 22px; }
.stat-cell span { font-size: 12px; color: var(--c-ink-soft); text-align: center; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.collect-card {
    background: var(--c-panel); border-radius: 18px; padding: 12px 6px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 14px; cursor: pointer;
    transition: transform 0.15s ease;
}
.collect-card:active { transform: scale(0.95); }
.collect-card.locked { background: rgba(255,255,255,0.4); cursor: default; }
.cc-emoji {
    width: 56px; height: 56px; border-radius: 16px; font-size: 32px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.12);
}
.cc-emoji.locked { background: #CFCAC4; color: #948E86; font-weight: 800; }

.shop-coins {
    background: var(--c-panel); border-radius: 18px;
    padding: 12px 18px; margin-bottom: 6px; font-size: 16px; text-align: center;
}
.shop-section { color: #fff; font-weight: 800; margin: 16px 4px 8px; text-shadow: 0 2px 0 rgba(0,0,0,0.12); }
.shop-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--c-panel); border-radius: 18px;
    padding: 12px 14px; margin-bottom: 8px;
}
.shop-icon { font-size: 28px; }
.shop-info { flex: 1; display: flex; flex-direction: column; }
.shop-info span { font-size: 12px; color: var(--c-ink-soft); }
.shop-info em { font-size: 11px; font-style: normal; color: var(--c-primary-dark); font-weight: 700; }

.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--c-panel); border-radius: 18px;
    padding: 13px 16px; margin-bottom: 8px; font-weight: 700;
}
.toggle {
    width: 74px; padding: 8px 0; border-radius: 14px;
    background: #C9C4BE; color: #fff; font-size: 14px;
}
.toggle.on { background: linear-gradient(180deg, #6BC77B, var(--c-primary-dark)); }
.choice-group { display: flex; gap: 6px; }
.choice {
    padding: 8px 12px; border-radius: 12px; font-size: 13px;
    background: #C9C4BE; color: #fff; text-transform: capitalize;
}
.choice.on { background: linear-gradient(180deg, #6BC77B, var(--c-primary-dark)); }

.center-text { text-align: center; }
.credits-block {
    background: var(--c-panel); border-radius: 22px; padding: 22px;
    margin-bottom: 14px; line-height: 1.6;
}
.credits-block h3 { margin-bottom: 8px; }
.credits-block .tiny { font-size: 12px; color: var(--c-ink-soft); margin-top: 10px; }

/* ==================================================================
   FX LAYER (score pops, combo, flash, toast)
   ================================================================== */
#fx-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }

.score-pop {
    position: absolute; transform: translate(-50%, -50%);
    font-size: 26px; font-weight: 800; color: #FFE96B;
    text-shadow: 0 2px 0 #B8860B, 0 4px 10px rgba(0,0,0,0.4);
    animation: scoreFloat 1.1s ease-out forwards;
}
.score-pop.big { font-size: 34px; color: #FF9BE0; text-shadow: 0 2px 0 #B33E8E, 0 4px 10px rgba(0,0,0,0.4); }
@keyframes scoreFloat {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    30% { transform: translate(-50%, -60%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(0.9); }
}

.combo-banner {
    position: absolute; left: 50%; top: 30%;
    transform: translate(-50%, -50%);
    font-size: 40px; font-weight: 800; color: #fff;
    text-shadow: 0 3px 0 #C4501F, 0 8px 20px rgba(0,0,0,0.4);
    animation: comboIn 1.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.combo-banner span { color: #FFE96B; font-size: 52px; }
@keyframes comboIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(3deg); }
    35% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(0.9); }
}

.screen-flash {
    position: absolute; inset: 0; opacity: 0;
    transition: opacity 0.15s ease;
}
.screen-flash.on { opacity: 1; transition: opacity 0.45s ease; }

.toast {
    position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom));
    transform: translateX(-50%) translateY(20px);
    background: var(--c-ink); color: #fff;
    padding: 12px 22px; border-radius: 30px;
    font-weight: 700; font-size: 15px; z-index: 60;
    opacity: 0; transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 26px rgba(0,0,0,0.35);
    max-width: 86vw; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* small screens */
@media (max-height: 620px) {
    .star-row { font-size: 36px; }
    .select-title { font-size: 26px; margin-bottom: 4px; }
    .level-grid { gap: 8px; }
    .btn-page { width: 52px; height: 52px; font-size: 20px; }
}
