:root {
    --primary: #ff9900; /* Amazon Orange */
    --primary-hover: #ffb13d;
    --primary-deep: #e07d00;
    --accent: #7c5cff;     /* Stage spotlight purple */
    --accent-pink: #ff4d8d;
    --background: #0b0d18;
    --bg-2: #131634;
    --card-bg: rgba(24, 27, 49, 0.72);
    --card-border: rgba(255, 255, 255, 0.09);
    --text: #ffffff;
    --text-muted: #b8bed6;
    --success: #1dd97b;
    --danger: #ff5b6e;

    --radius-lg: 28px;
    --radius-md: 16px;
    --radius-sm: 12px;

    --shadow-card: 0 30px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.35);

    --ring: 0 0 0 4px rgba(255, 153, 0, 0.35);

    --font-display: 'Fredoka', 'Outfit', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

html, body {
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--background);
    background-image:
        radial-gradient(1200px 600px at 50% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at 90% 110%, rgba(255, 77, 141, 0.12), transparent 55%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: clamp(20px, 5vw, 56px) clamp(14px, 4vw, 24px);
    position: relative;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Dynamic Animated Background */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(255, 153, 0, 0.16), transparent 58%),
                radial-gradient(circle at 78% 22%, rgba(124, 92, 255, 0.16), transparent 50%),
                radial-gradient(circle at 22% 80%, rgba(255, 77, 141, 0.12), transparent 50%);
    animation: rotate 40s linear infinite;
    z-index: -2;
    pointer-events: none;
}

/* Subtle stage-floor grid */
.grid-overlay {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 10%, transparent 75%);
            mask-image: radial-gradient(circle at 50% 30%, #000 10%, transparent 75%);
    z-index: -1;
    pointer-events: none;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.container {
    width: 100%;
    max-width: 760px;
    z-index: 1;
    animation: containerIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes containerIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
header {
    text-align: center;
    margin-bottom: clamp(24px, 4vw, 36px);
}

.show-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #c8ceea;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 7px 18px;
    border-radius: 999px;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
}

.show-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-pink);
    box-shadow: 0 0 10px var(--accent-pink);
    animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 9vw, 4.25rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    background: linear-gradient(95deg, #ffffff 10%, var(--primary) 55%, var(--accent-pink) 110%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    filter: drop-shadow(0 6px 22px rgba(255, 153, 0, 0.3));
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: clamp(1.05rem, 3vw, 1.3rem);
    font-weight: 300;
}

.stats-board {
    margin-top: 22px;
    display: flex;
    justify-content: center;
    gap: clamp(12px, 3vw, 18px);
    flex-wrap: wrap;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 120px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    padding: 12px 26px;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-soft);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 1.7rem);
    font-weight: 600;
}

/* .stat-sep rule removed — no matching markup in HTML */

#score, #round-number {
    color: var(--primary);
}

.progress-track {
    margin: 18px auto 0;
    width: min(320px, 80%);
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.progress-fill {
    height: 100%;
    width: 10%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--accent-pink));
    box-shadow: 0 0 12px rgba(255, 153, 0, 0.5);
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Glass Card ---------- */
.game-card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: clamp(22px, 5vw, 42px);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(22px);
    border: 1px solid var(--card-border);
    text-align: center;
    overflow: hidden;
    animation: cardIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(22px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* top sheen */
.game-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
}

.card-glow {
    position: absolute;
    top: -40%;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 60%;
    background: radial-gradient(circle, rgba(255, 153, 0, 0.18), transparent 70%);
    filter: blur(30px);
    pointer-events: none;
    z-index: 0;
}

.game-card > *:not(.card-glow) { position: relative; z-index: 1; }

.image-container {
    width: 100%;
    aspect-ratio: 3 / 2;
    max-height: 60vh;
    background: linear-gradient(160deg, #ffffff, #eef0f5);
    border-radius: var(--radius-md);
    margin-bottom: clamp(20px, 4vw, 30px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05), 0 16px 30px rgba(0, 0, 0, 0.35);
}

.price-tag-deco {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% 50% 50% 4px;
    box-shadow: 0 8px 18px rgba(255, 77, 141, 0.45);
    transform: rotate(8deg);
    pointer-events: none;
}

#product-image {
    position: relative;
    z-index: 2;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: clamp(14px, 3vw, 24px);
    background: linear-gradient(160deg, #ffffff, #eef0f5);
    transition: opacity 0.3s, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.image-container:hover #product-image {
    transform: scale(1.04);
}

.product-title {
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 4.5vw, 1.85rem);
    font-weight: 600;
    margin-bottom: clamp(20px, 4vw, 30px);
    line-height: 1.3;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.game-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.currency {
    position: absolute;
    left: 20px;
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: var(--primary);
    font-weight: 700;
    font-family: var(--font-display);
    pointer-events: none;
}

input[type="number"], input[type="text"] {
    width: 100%;
    padding: clamp(16px, 3.5vw, 20px) 20px;
    padding-left: 52px;
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 600;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

input[type="text"] {
    padding-left: 20px;
    font-size: clamp(1.1rem, 4vw, 1.4rem);
}

input::placeholder { color: rgba(255, 255, 255, 0.3); }

input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: var(--ring), 0 0 24px rgba(255, 153, 0, 0.22);
}

/* Hide number spinners */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- Buttons ---------- */
button {
    font-family: var(--font-display);
    font-size: clamp(1.15rem, 4vw, 1.4rem);
    font-weight: 600;
    padding: clamp(15px, 3.2vw, 19px);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.25s ease, filter 0.25s ease;
    letter-spacing: 0.01em;
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85), 0 0 0 7px var(--primary);
}

input:focus-visible {
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    color: #1a1200;
    box-shadow: 0 12px 24px -6px rgba(255, 153, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    position: relative;
    overflow: hidden;
}

.primary-btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}

.primary-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow: 0 18px 32px -8px rgba(255, 153, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.primary-btn:hover::after { left: 130%; }

.primary-btn:active {
    transform: translateY(0) scale(0.98);
}

.primary-btn:disabled {
    filter: grayscale(0.4) brightness(0.8);
    cursor: default;
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    margin-top: 22px;
    width: 100%;
    border: 1px solid var(--card-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.secondary-btn:active { transform: translateY(0) scale(0.98); }

/* ---------- Feedback ---------- */
.feedback {
    margin-top: clamp(22px, 4vw, 30px);
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    animation: feedbackIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.hidden {
    display: none !important;
}

#feedback-message {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5.5vw, 2rem);
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.actual-price {
    font-size: clamp(1.15rem, 4vw, 1.4rem);
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes feedbackIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.7); }
    60% { transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

.success-text {
    color: var(--success);
    text-shadow: 0 0 24px rgba(29, 217, 123, 0.45);
}
.danger-text {
    color: var(--danger);
    text-shadow: 0 0 24px rgba(255, 91, 110, 0.4);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), shake 0.45s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ---------- Game Over / Leaderboard ---------- */
.trophy {
    font-size: clamp(3rem, 12vw, 4.5rem);
    line-height: 1;
    margin-bottom: 6px;
    animation: bob 2.6s ease-in-out infinite;
    filter: drop-shadow(0 10px 18px rgba(255, 153, 0, 0.4));
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-8px) rotate(3deg); }
}

#game-over-area h2 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 7vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.final-score-box {
    margin: clamp(22px, 4vw, 30px) 0;
    padding: 22px;
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 153, 0, 0.12), rgba(255, 77, 141, 0.06));
    border: 1px solid rgba(255, 153, 0, 0.25);
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 5vw, 1.8rem);
    font-weight: 600;
    color: var(--primary);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.final-score-box span { color: #fff; }

.leaderboard-entry {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px;
}

.leaderboard {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: 4px;
}

.leaderboard h3 {
    font-family: var(--font-display);
    margin-bottom: 14px;
    color: var(--primary);
    text-align: center;
    font-size: clamp(1.3rem, 4.5vw, 1.5rem);
    font-weight: 600;
}

#leaderboard-list {
    list-style: none;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: clamp(1rem, 3.5vw, 1.15rem);
    border-radius: 8px;
    transition: background 0.2s ease;
}

#leaderboard-list li:hover {
    background: rgba(255, 255, 255, 0.04);
}

#leaderboard-list li span:last-child {
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

#leaderboard-list li:nth-child(1) span:first-child { color: var(--primary); font-weight: 700; }

#leaderboard-list li:last-child {
    border-bottom: none;
}

/* ---------- Footer ---------- */
.site-footer {
    text-align: center;
    margin-top: 28px;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

/* ---------- Loading spinner (hidden by default; JS shows/hides) ---------- */
.loading-spinner {
    position: absolute;
    width: 46px;
    height: 46px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    z-index: 1;
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Confetti celebration ---------- */
.confetti-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 50;
}

.confetti-piece {
    position: absolute;
    top: -16px;
    width: 10px;
    height: 14px;
    opacity: 0;
    border-radius: 2px;
    animation: confettiFall var(--dur, 2.4s) cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translate3d(0, -10vh, 0) rotate(0deg); }
    100% { opacity: 0; transform: translate3d(var(--drift, 0), 105vh, 0) rotate(720deg); }
}

/* ---------- Leaderboard rank medals ---------- */
#leaderboard-list li:nth-child(2) span:first-child { color: #c8ccd8; font-weight: 700; }
#leaderboard-list li:nth-child(3) span:first-child { color: #c8935a; font-weight: 700; }

/* ---------- Feedback panel polish ---------- */
#feedback {
    border-radius: var(--radius-sm);
}

/* ---------- Accessibility helpers ---------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Responsive tuning ---------- */
@media (max-width: 480px) {
    .stats-board { gap: 10px; }
    .stat-box { min-width: 0; flex: 1 1 120px; padding: 10px 14px; }
    .stat-label { font-size: 0.68rem; }
    .currency { left: 16px; }
    input[type="number"] { padding-left: 44px; }
    .primary-btn, .secondary-btn { font-size: 1.05rem; padding: 14px; }
    .product-title { font-size: clamp(1.15rem, 5.5vw, 1.5rem); }
}

@media (max-width: 360px) {
    h1 { font-size: 2.2rem; }
    .stats-board { flex-direction: column; align-items: center; }
    .stat-box { width: 80%; }
}

@media (min-width: 768px) {
    .game-controls { flex-direction: row; align-items: stretch; }
    .game-controls .input-group { flex: 1; }
    .game-controls #guess-btn { flex: 0 0 auto; min-width: 140px; }
    .leaderboard-entry { flex-direction: row; }
    .leaderboard-entry #player-name { flex: 1; }
    .leaderboard-entry #save-score-btn { flex: 0 0 auto; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .background-animation { animation: none; }
    .confetti-piece { display: none; }
    .image-container:hover #product-image { transform: none; }
}
