@font-face {
    font-family: 'Gimlet Sans';
    src: url('fonts/GimletSansMicro-Regular.woff2') format('woff2'),
         url('fonts/GimletSansMicro-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Megazoid';
    src: url('fonts/Megazoid-Regular.woff2') format('woff2'),
         url('fonts/Megazoid-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

button, input, select, textarea {
    font-family: inherit;
}

body {
    font-family: 'Gimlet Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.container {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1rem;
}

header h1 {
    font-family: 'Megazoid', sans-serif;
    color: #333;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.stat {
    font-size: 1.1rem;
    color: #555;
}

.stat-label {
    font-weight: 600;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin: 0 auto;
    max-width: 600px;
}

/* Card */
.card {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.25s ease;
    transform-style: preserve-3d;
}

.card.flipped .card-inner,
.card.matched .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back {
    background: linear-gradient(135deg, var(--card-back-1, #a8c0ff) 0%, var(--card-back-2, #3f2b96) 100%);
    border: 2px solid color-mix(in srgb, var(--card-back-2, #5a4fcf) 80%, black);
}

.card-front {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    transform: rotateY(180deg);
    font-size: clamp(2.2rem, 7vw, 3.5rem);
}

.card.matched .card-front {
    background: #d4edda;
    border-color: #28a745;
}

.card:hover:not(.flipped):not(.matched) .card-back {
    background: linear-gradient(135deg, color-mix(in srgb, var(--card-back-1, #a8c0ff) 80%, white) 0%, color-mix(in srgb, var(--card-back-2, #3f2b96) 80%, white) 100%);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 1rem;
}

.btn {
    background: linear-gradient(135deg, var(--card-back-1, #667eea) 0%, var(--card-back-2, #764ba2) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.share-btn {
    background: linear-gradient(135deg, var(--card-back-1, #667eea) 0%, var(--card-back-2, #764ba2) 100%);
    margin-top: 1rem;
    font-size: 1rem;
}

.instructions {
    margin-top: 1rem;
    color: #666;
    font-size: 0.9rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden {
    display: none;
}

.modal.hidden {
    display: none;
}

.modal-content {
    position: relative;
    background: white;
    padding: 2rem;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    color: #28a745;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Shareable Result Section */
.shareable-section {
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.shareable-section h3 {
    color: #495057;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

.shareable-box {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shareable-text {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #495057;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: all;
    cursor: text;
}

.btn-secondary {
    background: #6c757d;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.btn-secondary:hover {
    background: #5a6268;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.btn-secondary:disabled {
    background: #28a745;
    cursor: not-allowed;
}

/* Theme Guess */
.theme-guess-section {
    margin: 1.5rem 0;
    text-align: center;
}

.theme-guess-section p {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.theme-input-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

#theme-input {
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    outline: none;
    width: 200px;
    transition: border-color 0.2s;
}

#theme-input:focus {
    border-color: #667eea;
}

.btn-small {
    background: linear-gradient(135deg, var(--card-back-1, #667eea) 0%, var(--card-back-2, #764ba2) 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.theme-result {
    margin: 1rem 0;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.theme-result.correct {
    background: #d4edda;
    color: #155724;
}

.theme-result.incorrect {
    background: #f8d7da;
    color: #721c24;
}

/* Streak Section */
.streak-section {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: #fff8e1;
    border-radius: 8px;
}

.streak-info {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.streak-item {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

/* Results grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    max-width: 160px;
    margin: 1rem auto;
}

.result-cell {
    aspect-ratio: 1;
    border-radius: 4px;
}

.result-green {
    background: #28a745;
}

.result-yellow {
    background: #ffc107;
}

.result-red {
    background: #dc3545;
}

/* Countdown */
.countdown {
    margin: 1rem 0;
    font-size: 0.95rem;
    color: #555;
}

.countdown span {
    font-weight: 700;
    color: #333;
}

/* Ko-fi button */
.kofi-wrapper {
    margin: 0.75rem 0;
    display: flex;
    justify-content: center;
}

/* Responsive */
@media (max-width: 650px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 450px) {
    .grid {
        gap: 2px;
    }
}
