:root {
    --surface: #fff4f6;
    --surface-bright: #fff4f6;
    --surface-container: #ffe0eb;
    --surface-container-high: #ffd8e7;
    --surface-container-lowest: #ffffff;
    --surface-variant: #ffd0e3;
    
    --primary: #9c3853;
    --primary-container: #ff85a1;
    --primary-dim: #8d2c48;
    
    --secondary-container: #78e3fd;
    --on-secondary-container: #00515f;
    
    --tertiary-container: #f9cc61;
    
    --on-surface: #4a2135;
    --outline-variant: #d79db5;

    --font-family: 'Plus Jakarta Sans', sans-serif;
    
    --radius-full: 9999px;
    --radius-xl: 3rem;
    --radius-md: 1.5rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--surface);
    color: var(--on-surface);
    overflow-x: hidden;
}

/* Typography */
.display-lg {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 1rem;
}

.display-sm {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 2rem;
}

.body-md {
    font-size: 1.125rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    position: sticky;
    top: 1rem;
    margin: 0 1rem;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--radius-full);
    z-index: 100;
    box-shadow: 0 8px 32px rgba(74, 33, 53, 0.05);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-bar input {
    background-color: var(--surface-container-high);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    font-family: var(--font-family);
    font-weight: 600;
    color: var(--on-surface);
    outline: none;
    transition: background-color 0.2s;
}

.search-bar input:focus {
    background-color: var(--primary-container);
    color: var(--primary);
}

.search-bar input::placeholder {
    color: var(--on-surface);
    opacity: 0.6;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--radius-full);
    background-color: var(--surface-container-high);
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.05);
}

/* Layout */
main {
    width: 100%;
}

/* =========================================
   Japanese Full Screen Hero
========================================= */
.japanese-hero {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fcfcfc;
    background-image: 
        linear-gradient(#e5e5e5 1px, transparent 1px),
        linear-gradient(90deg, #e5e5e5 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    overflow: hidden;
    margin-bottom: 4rem;
}

.full-screen-gasha {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    transform: scale(1.1); /* 讓機台更大更有魄力 */
}

/* 滾動提示 */
.scroll-hint {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #666;
    font-weight: 700;
    font-size: 0.9rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* =========================================
   Japanese Gashapon Machine
========================================= */
.japanese-machine {
    width: 320px;
    height: 600px;
    position: relative;
    filter: drop-shadow(0 30px 50px rgba(0, 0, 0, 0.25));
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 頂部看板 */
.machine-signboard {
    width: 90%;
    background: #ffffff;
    border: 4px solid #e60012; /* 經典紅 */
    border-radius: 10px 10px 0 0;
    padding: 10px;
    text-align: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1), 0 5px 15px rgba(0,0,0,0.2);
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.machine-signboard h2 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 900;
    color: #005eb8; /* 萬代藍 */
    font-size: 1.8rem;
    margin: 0;
    letter-spacing: 2px;
}

.price-tag {
    background: #e60012;
    color: white;
    font-weight: 900;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 1.2rem;
    margin-top: 5px;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* 透明壓克力櫥窗 */
.acrylic-glass {
    width: 100%;
    height: 280px;
    background: rgba(255, 255, 255, 0.4);
    border: 6px solid #e2e8f0;
    border-bottom: none;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(2px);
    z-index: 2;
    box-shadow: inset 0 0 30px rgba(255,255,255,0.8), inset 0 10px 20px rgba(0,0,0,0.05);
}

.acrylic-glass::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-20deg);
    animation: glass-shine 6s infinite;
}

@keyframes glass-shine {
    0% { left: -50%; }
    20%, 100% { left: 150%; }
}

.capsules-glass {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Capsule styling */
.capsule {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    position: absolute;
    box-shadow: inset -5px -5px 15px rgba(0,0,0,0.4), 0 5px 10px rgba(0,0,0,0.4), inset 5px 5px 10px rgba(255,255,255,0.8);
    border: 1px solid rgba(0,0,0,0.1);
}

/* 半白半色的真實扭蛋設計 (含中間接縫) */
.c-pink { background: linear-gradient(to bottom, #ffffff 48%, #cccccc 49%, #888888 50%, #ff6b8b 51%, #c92a54 100%); }
.c-yellow { background: linear-gradient(to bottom, #ffffff 48%, #cccccc 49%, #888888 50%, #ffde59 51%, #d4a017 100%); }
.c-cyan { background: linear-gradient(to bottom, #ffffff 48%, #cccccc 49%, #888888 50%, #4ddbff 51%, #008cb4 100%); }

/* 自然滾動特效 */
.mixing .capsule {
    animation: tumble 0.6s ease-in-out infinite alternate;
}

.mixing .capsule:nth-child(even) {
    animation-delay: 0.1s;
    animation-duration: 0.5s;
    animation-name: tumble-alt;
}

.mixing .capsule:nth-child(3n) {
    animation-delay: 0.2s;
    animation-duration: 0.7s;
}

@keyframes tumble {
    0% { transform: translateY(0) rotate(0deg) translateX(0); }
    100% { transform: translateY(-30px) rotate(80deg) translateX(10px); }
}

@keyframes tumble-alt {
    0% { transform: translateY(0) rotate(0deg) translateX(0); }
    100% { transform: translateY(-20px) rotate(-60deg) translateX(-15px); }
}

/* 機台主機與操作區 */
.metal-base {
    width: 100%;
    height: 220px;
    background: linear-gradient(180deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 2px solid #ccc;
    border-radius: 0 0 15px 15px;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.1), 0 10px 20px rgba(0,0,0,0.2);
}

/* 投幣區 */
.coin-panel {
    position: absolute;
    top: 20px;
    left: 30px;
    width: 50px;
    height: 100px;
    background: #d1d5db;
    border: 2px solid #9ca3af;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

.coin-slot {
    width: 6px;
    height: 30px;
    background: #111;
    border-radius: 3px;
    border: 1px solid #4b5563;
}

.coin-return {
    width: 30px;
    height: 20px;
    background: #111;
    border-radius: 4px;
    margin-top: 20px;
    border: 2px solid #4b5563;
}

/* 轉鈕區 */
.dial-container {
    position: absolute;
    top: 30px;
    right: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dial {
    width: 80px;
    height: 80px;
    background: linear-gradient(145deg, #e60012, #b3000e);
    border-radius: 50%;
    border: 4px solid #fff;
    box-shadow: 0 8px 15px rgba(0,0,0,0.4), inset 0 4px 10px rgba(255,255,255,0.4);
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, filter 0.2s;
}

.dial:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.dial:active {
    transform: scale(0.95);
}

.dial::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 40px;
    background: #fff;
    border-radius: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.dial.spin {
    animation: spin-knob 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

.dial-label {
    margin-top: 10px;
    font-weight: 900;
    color: #444;
    font-size: 0.9rem;
    text-shadow: 0 1px 1px #fff;
}

/* 取物口 */
.dispenser {
    width: 120px;
    height: 80px;
    background-color: #111;
    border-radius: 10px;
    position: absolute;
    bottom: 20px;
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.8), 0 2px 5px rgba(255,255,255,0.5);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
    border: 4px solid #d1d5db;
}

.flap {
    width: 100%;
    height: 90%;
    background: rgba(255,255,255,0.2);
    position: absolute;
    top: 0;
    transform-origin: top;
    transition: transform 0.3s;
    border-bottom: 2px solid rgba(255,255,255,0.5);
    z-index: 10;
}

.dispenser:has(.dropped) .flap {
    transform: rotateX(60deg); /* 扭蛋掉落時推開擋板 */
}

#dropped-capsule {
    position: relative;
    bottom: -60px;
    z-index: 5;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#dropped-capsule.dropped {
    bottom: 5px;
}

/* Buttons */
.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-container));
    color: var(--surface-container-lowest);
    border: none;
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 800;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(156, 56, 83, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: var(--font-family);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(156, 56, 83, 0.4);
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 5px 10px rgba(156, 56, 83, 0.2);
}

/* Animations */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-2deg); }
    50% { transform: translateX(5px) rotate(2deg); }
    75% { transform: translateX(-5px) rotate(-2deg); }
    100% { transform: translateX(0); }
}

.shaking {
    animation: shake 0.5s ease-in-out;
}

@keyframes mix-capsules {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(10px, -10px) rotate(45deg); }
    50% { transform: translate(-10px, 10px) rotate(90deg); }
    75% { transform: translate(-10px, -10px) rotate(135deg); }
    100% { transform: translate(0, 0) rotate(180deg); }
}

.mixing .capsule {
    animation: mix-capsules 0.5s ease-in-out infinite alternate;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.product-card {
    background-color: var(--surface-container-lowest);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(74, 33, 53, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.8) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(74, 33, 53, 0.1);
}

.product-image-container {
    width: 100%;
    aspect-ratio: 1;
    background-color: var(--surface-variant);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.product-price {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.chip {
    align-self: flex-start;
    background-color: var(--secondary-container);
    color: var(--on-secondary-container);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsive */
@media (max-width: 768px) {
    .hero {
        flex-direction: column;
        padding: 2rem;
    }
    
    .display-lg {
        font-size: 2.5rem;
    }
}

/* Cart Badge */
.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--primary);
    color: var(--surface-container-lowest);
    font-size: 0.75rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(156, 56, 83, 0.3);
}

.cart-badge.hidden {
    display: none;
}

/* Cart Overlay */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(74, 33, 53, 0.4);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    opacity: 1;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.cart-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Cart Sidebar */
.cart-sidebar {
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    box-shadow: -10px 0 30px rgba(74, 33, 53, 0.1);
}

.cart-overlay.hidden .cart-sidebar {
    transform: translateX(100%);
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    border-bottom: 2px solid var(--surface-container);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: var(--surface-container-lowest);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 5px 15px rgba(74, 33, 53, 0.05);
}

.cart-item-emoji {
    font-size: 2.5rem;
    background-color: var(--surface-variant);
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: var(--primary);
    font-weight: 600;
}

.cart-footer {
    padding: 2rem;
    background-color: var(--surface-container-highest);
    border-top: 2px solid var(--surface-container);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.checkout-btn {
    width: 100%;
    padding: 1.25rem;
}

.add-to-cart-btn {
    width: 100%;
    background-color: var(--surface-container-high);
    color: var(--primary);
    border: none;
    padding: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
    font-family: var(--font-family);
}

.add-to-cart-btn:hover {
    background-color: var(--primary-container);
    color: var(--on-primary-container);
}

/* =========================================
   Reward Popup Modal
========================================= */
.reward-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.reward-popup-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex !important; /* Keep it flex for structure, opacity handles hide */
}

.reward-popup-content {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 2rem;
    padding: 3rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transform: scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reward-popup-overlay.hidden .reward-popup-content {
    transform: scale(0.8);
}

.reward-emoji {
    font-size: 6rem;
    margin: 1rem 0;
    animation: bounce 2s infinite;
}

.reward-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--on-surface);
    margin-bottom: 0.5rem;
}

.reward-tags {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}
