/* ===========================================
   スーパーマーケット - SPEC準拠版
   =========================================== */
/* Mobile Responsive Fixes */
@media (max-width: 480px) {
    .game-header {
        padding: 60px 10px 10px;
    }
    .level-badge {
        font-size: 0.9rem;
        padding: 5px 10px;
    }
    .home-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 10px;
        left: 10px;
    }
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Zen Maru Gothic', sans-serif;
    touch-action: pan-y;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.home-btn {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    z-index: 9999;
}

#game-container {
    max-width: 500px;
    height: 100%;
    margin: 0 auto;
    position: relative;
}

.phase {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.phase.hidden {
    display: none;
}

/* ========== Shopping Phase ========== */
.shopping-header {
    background: white;
    padding: 60px 20px 15px;
    border-radius: 0 0 25px 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.memo-icon {
    font-size: 1.5rem;
}

.header-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.target-list {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.target-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: #F5F5F5;
    border-radius: 12px;
    transition: all 0.3s;
    position: relative;
}

.target-item.found {
    background: #C8E6C9;
}

.target-item.found::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4CAF50;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.target-icon {
    font-size: 2rem;
}

.target-name {
    font-size: 0.7rem;
    color: #666;
}

/* Shelf */
.shelf-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Important for flex shrinking */
}

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.product {
    background: white;
    border-radius: 15px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s;
}

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

.product.collected {
    opacity: 0.3;
    pointer-events: none;
}

.product.wrong {
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes wrongShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.product-icon {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.product-name {
    font-size: 0.7rem;
    color: #666;
    text-align: center;
}

/* Cart Bar */
.cart-bar {
    background: white;
    padding: 12px 20px;
    border-radius: 25px 25px 0 0;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.cart-info {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

.cart-icon {
    font-size: 1.8rem;
}

.cart-count {
    font-size: 1.5rem;
    color: #4CAF50;
}

.cart-slash {
    color: #999;
}

.cart-items {
    display: flex;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
}

.cart-item {
    font-size: 1.8rem;
    animation: cartPop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes cartPop {
    0% {
        transform: scale(0) translateY(20px);
    }

    100% {
        transform: scale(1) translateY(0);
    }
}

/* ========== Register Phase ========== */
#register-phase {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #ECEFF1 0%, #CFD8DC 100%);
}

.register-scene {
    text-align: center;
    padding: 20px;
}

.register-scene h2 {
    font-size: 1.4rem;
    color: #333;
    margin-bottom: 10px;
}

.register-instruction {
    color: #666;
    margin-bottom: 25px;
}

.scanner-area {
    width: 200px;
    height: 150px;
    background: #263238;
    border-radius: 15px;
    margin: 0 auto 20px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.scanner-beam {
    position: absolute;
    width: 90%;
    height: 3px;
    background: #F44336;
    box-shadow: 0 0 10px #F44336;
    animation: scanBeam 1.5s ease-in-out infinite;
}

@keyframes scanBeam {

    0%,
    100% {
        top: 20%;
    }

    50% {
        top: 80%;
    }
}

.scan-target {
    font-size: 4rem;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 1;
}

.scan-target:active {
    transform: scale(0.9);
}

.scan-target.scanned {
    animation: scanFlash 0.5s ease-out;
}

@keyframes scanFlash {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.2);
        filter: brightness(2);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.scanned-items {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
    min-height: 50px;
}

.scanned-item {
    font-size: 2.5rem;
    animation: scannedPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scannedPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

.scan-progress {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

/* ========== Complete Phase ========== */
#complete-phase {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
}

.complete-scene {
    text-align: center;
    padding: 20px;
}

.receipt {
    background: white;
    padding: 25px;
    border-radius: 5px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    max-width: 280px;
    margin: 0 auto 25px;
    position: relative;
}

.receipt::before,
.receipt::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 10px;
    background:
        linear-gradient(135deg, white 25%, transparent 25%),
        linear-gradient(-135deg, white 25%, transparent 25%);
    background-size: 10px 10px;
}

.receipt::before {
    top: -10px;
    transform: rotate(180deg);
}

.receipt::after {
    bottom: -10px;
}

.receipt-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #ddd;
}

.receipt-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.receipt-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.receipt-item-icon {
    font-size: 1.5rem;
}

.receipt-item-name {
    flex: 1;
    text-align: left;
    color: #333;
}

.receipt-total {
    font-weight: bold;
    color: #4CAF50;
    padding-top: 10px;
    border-top: 2px dashed #ddd;
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #43A047 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
}