:root {
    --bg: #99ccff;
    --fg: #0b1b3a;
    --card: rgba(255, 255, 255, 0.55);
    --accent: #3366ff;
    --accent-2: #1e3a8a;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shop-item-width: 100px;
    --page-pad: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000066;
        --fg: #e9f0ff;
        --card: rgba(255, 255, 255, 0.06);
        --accent: #5b7cff;
        --accent-2: #9bb3ff;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    }
}

html,
body {
    background: var(--bg);
}

html {
    min-height: 100%;
    margin: 0;
    font-family: Inter, sans-serif;
    color: var(--fg);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: var(--page-pad);
    overflow-x: hidden;
    box-sizing: border-box;
}

#center {
    width: min(100%, 760px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#main-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    max-width: 100%;
}

#main-btn img {
    display: block;
    width: min(100vw - (var(--page-pad) * 2), 40rem);
    height: auto;
    max-height: 58vh;
    object-fit: contain;
    pointer-events: none;
    background-color: transparent;
}

#main-btn:focus,
#main-btn:active {
    outline: none;
    box-shadow: none;
    border: none;
}

#penguin-img {
    transition: transform 250ms ease;
    transform-origin: 50% 60%;
}

#penguin-img.pulse {
    animation: penguinClick 420ms ease-out;
}

@keyframes penguinClick {
    0% {
        transform: scale(1);
    }
    35% {
        transform: scale(0.92);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

#status {
    min-height: 1.5em;
    text-align: center;
    font-size: clamp(14px, 3.2vw, 16px);
}

#shop {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(5, minmax(72px, var(--shop-item-width)));
    gap: 10px;
    width: 100%;
    justify-content: center;
    justify-items: center;
}

.shop-item {
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.25);
    color: white;
    border-radius: 14px;
    padding: 10px 8px;
    user-select: none;
    width: 100%;
    max-width: var(--shop-item-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    aspect-ratio: 1 / 1;
    min-height: 92px;
    touch-action: manipulation;
}

.shop-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    min-width: var(--shop-item-width);
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.15s ease,
        transform 0.15s ease,
        visibility 0.15s ease;
    z-index: 10;
}

.shop-item:hover .shop-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.shop-item:active {
    transform: translateY(0px) scale(0.98);
}

.shop-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.shop-icon {
    font-size: 28px;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
}

.shop-name {
    margin-top: 6px;
    font-size: 13px;
    opacity: 0.95;
}

.shop-price {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

.shop-owned {
    margin-top: 3px;
    font-size: 12px;
    opacity: 0.75;
}

#shop-msg {
    margin-top: 10px;
    min-height: 1.2em;
    font-size: 14px;
    opacity: 0.9;
    text-align: center;
}

#owned-panel {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(320px, calc(100vw - 24px));
    pointer-events: none;
}

.blurred {
    backdrop-filter: blur(10px);
}

.owned-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--card);
    color: var(--fg);
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.2;
    pointer-events: auto;
}

.owned-item .owned-emoji {
    font-size: 18px;
    flex: 0 0 auto;
}

.owned-item .owned-count {
    font-weight: 700;
    min-width: 2.2em;
}

.owned-item .owned-desc {
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#console {
    position: fixed;
    top: 200px;
    right: 12px;
    z-index: 1000;
    width: min(360px, calc(100vw - 24px));
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

#console-output {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

#console-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.22);
    color: var(--fg);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    font: inherit;
}

@media (max-width: 700px) {
    :root {
        --shop-item-width: 84px;
        --page-pad: 12px;
    }

    #shop {
        grid-template-columns: repeat(3, minmax(72px, 1fr));
        gap: 8px;
    }

    #main-btn img {
        max-height: 50vh;
    }
}

@media (max-width: 480px) {
    :root {
        --shop-item-width: 78px;
        --page-pad: 10px;
    }

    #center {
        gap: 10px;
    }

    #shop {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .shop-item {
        min-height: 88px;
        padding: 8px 6px;
    }

    .shop-icon {
        font-size: 24px;
    }

    .shop-name {
        font-size: 12px;
    }

    .shop-price,
    .shop-owned {
        font-size: 11px;
    }

    #status,
    #shop-msg {
        font-size: 13px;
    }

    .shop-tooltip {
        display: none;
    }
}

@media (max-width: 360px) {
    #shop {
        grid-template-columns: 1fr 1fr;
    }

    #main-btn img {
        max-height: 42vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
