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

:root {
    --background: 0 0% 98%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 221.2 83.2% 53.3%;
    --radius: 0.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: hsl(var(--background));
    min-height: 100vh;
    padding: 0;
    color: hsl(var(--foreground));
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: transparent;
}

header {
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: hsla(var(--card), 0.95);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    letter-spacing: -0.025em;
}

.header-info {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.balance, .cart-info {
    background: hsl(var(--secondary));
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

section {
    margin-bottom: 3rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
    padding: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.product-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-color: hsl(var(--ring));
}

.product-card.flag-item {
    background: linear-gradient(to bottom right, hsl(48, 100%, 97%), hsl(48, 100%, 94%));
    border: 2px solid hsl(48, 96%, 53%);
    position: relative;
    overflow: hidden;
}

.product-card.flag-item::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, hsl(48, 96%, 53%) 0%, hsl(48, 96%, 63%) 100%);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    opacity: 0.3;
}

.product-card.flag-item:hover {
    box-shadow: 0 10px 15px -3px rgba(250, 204, 21, 0.2), 0 4px 6px -2px rgba(250, 204, 21, 0.1);
    border-color: hsl(48, 96%, 53%);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    margin-bottom: 1rem;
}

.product-card.flag-item .product-image {
    background: linear-gradient(135deg, hsl(48, 100%, 90%) 0%, hsl(48, 100%, 85%) 100%);
}

.product-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: hsl(var(--card-foreground));
}

.product-description {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    margin-bottom: 1rem;
    flex: 1;
}

.product-price {
    font-size: 1.5rem;
    color: hsl(var(--primary));
    font-weight: 700;
    margin-bottom: 1rem;
}

.product-card.flag-item .product-price {
    color: hsl(0, 84%, 60%);
    font-size: 1.75rem;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.quantity-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.quantity-selector input {
    width: 70px;
    padding: 0.5rem;
    text-align: center;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: border-color 0.2s;
}

.quantity-selector input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsla(var(--ring), 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
}

.btn-primary:active:not(:disabled) {
    background: hsl(var(--primary) / 0.95);
}

.btn-primary:disabled {
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
}

.btn-secondary:hover {
    background: hsl(var(--secondary) / 0.8);
}

.btn-danger {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.btn-danger:hover {
    background: hsl(var(--destructive) / 0.9);
}

.cart {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) + 2px);
    padding: 1.5rem;
}

.cart-items {
    min-height: 100px;
}

.empty-cart {
    text-align: center;
    color: hsl(var(--muted-foreground));
    padding: 3rem;
    font-size: 0.875rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background: hsl(var(--background));
    transition: border-color 0.2s;
}

.cart-item:hover {
    border-color: hsl(var(--muted-foreground) / 0.3);
}

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

.cart-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: hsl(var(--card-foreground));
}

.cart-item-details {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
}

.cart-total {
    text-align: right;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0;
    padding: 1rem;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

.cart-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

footer {
    background: hsl(var(--card));
    border-top: 1px solid hsl(var(--border));
    text-align: center;
    padding: 2rem 1.5rem;
    margin-top: 4rem;
    color: hsl(var(--muted-foreground));
}

footer p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: hsl(var(--card));
    margin: 10% auto;
    padding: 2rem;
    border-radius: calc(var(--radius) + 4px);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid hsl(var(--border));
    animation: slideUp 0.3s ease;
}

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

.close {
    color: hsl(var(--muted-foreground));
    float: right;
    font-size: 1.75rem;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover {
    color: hsl(var(--foreground));
}

#modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

#modal-body {
    color: hsl(var(--card-foreground));
    line-height: 1.6;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.success-message {
    background: hsl(142, 71%, 45%);
    color: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
    border: 1px solid hsl(142, 71%, 40%);
}

.error-message {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
    border: 1px solid hsl(var(--destructive) / 0.8);
}

.flag-message {
    background: linear-gradient(to bottom right, hsl(48, 100%, 95%), hsl(48, 100%, 88%));
    color: hsl(var(--foreground));
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 600;
    border: 2px solid hsl(48, 96%, 53%);
    box-shadow: 0 4px 6px -1px rgba(250, 204, 21, 0.1);
}

.flag-code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    background: hsl(222.2, 84%, 4.9%);
    color: hsl(142, 71%, 65%);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-top: 0.75rem;
    font-size: 1rem;
    letter-spacing: -0.025em;
    border: 1px solid hsl(222.2, 84%, 8%);
}

/* 반응형 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .header-info {
        font-size: 0.75rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .product-card {
        padding: 1rem;
    }

    .cart-actions {
        flex-direction: column;
    }

    .cart-actions .btn {
        width: 100%;
    }
}
