*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Kanit', system-ui, sans-serif;
    line-height: 1.6;
    color: #fff;
    background: linear-gradient(135deg, #8e44ad, #f39c12);
}

a {
    color: #7ff6ff;
}

.navbar {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 24px;
    background: rgba(0, 0, 0, 0.75);
}

.navbar a {
    color: #fff;
    text-decoration: none;
    opacity: 0.85;
}

.navbar a:hover {
    opacity: 1;
    text-decoration: underline;
}

.card {
    width: min(820px, 100% - 32px);
    padding: clamp(20px, 4vw, 32px);
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.7);
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

h1 {
    margin: 0 0 4px;
    font-size: clamp(1.4rem, 4.5vw, 1.9rem);
    font-weight: 600;
    line-height: 1.35;
}

.subtitle {
    margin: 0 0 20px;
    opacity: 0.75;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.btn {
    flex: 1 1 220px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 18px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: 3px solid #7ff6ff;
    outline-offset: 2px;
}

.btn-primary {
    background: #3b82f6;
}

.btn-secondary {
    background: #22a55a;
}

.btn-download {
    background: #f5c518;
    color: #1d1d1d;
}

.image-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    min-height: 120px;
    margin: 24px 0 8px;
}

.image-grid img {
    width: calc(33.333% - 8px);
    max-width: 220px;
    height: auto;
    aspect-ratio: 1;
    padding: 8px;
    border: 2px solid #fff;
    border-radius: 16px;
    background: linear-gradient(45deg, #f39c12, #8e44ad);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    animation: pop 320ms ease-out both;
}

.placeholder {
    align-self: center;
    margin: 0;
    opacity: 0.6;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
}

.result {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.result img {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 0 auto 16px;
    border-radius: 12px;
}

.hint {
    margin: 12px 0 0;
    font-size: 0.85rem;
    opacity: 0.65;
}

.credits {
    width: min(820px, 100% - 32px);
    margin: 24px 0 48px;
    padding: 16px 20px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 0.92rem;
}

.credits p {
    margin: 0 0 6px;
}

.credits .notice {
    text-decoration: underline;
    opacity: 0.85;
}

@media (max-width: 520px) {
    .image-grid img {
        width: calc(50% - 6px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-grid img {
        animation: none;
    }
}
