/* noto-color-emoji-regular - emoji */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Noto Color Emoji';
    font-style: normal;
    font-weight: 400;
    src: url('./assets/fonts/NotoColorEmoji.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* fredoka-300 - latin */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 300;
    src: url('./assets/fonts/fredoka-v17-latin-300.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* fredoka-regular - latin */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 400;
    src: url('./assets/fonts/fredoka-v17-latin-regular.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* fredoka-500 - latin */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 500;
    src: url('./assets/fonts/fredoka-v17-latin-500.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* fredoka-600 - latin */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 600;
    src: url('./assets/fonts/fredoka-v17-latin-600.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* fredoka-700 - latin */
@font-face {
    font-display: swap;
    /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 700;
    src: url('./assets/fonts/fredoka-v17-latin-700.woff2') format('woff2');
    /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}


/* ==================== THEME VARIABLES ==================== */
:root {
    /* Light Theme */
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-sub: #64748b;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --success: #10b981;
    --danger: #ef4444;
    --gold: #f59e0b;
    --overlay: rgba(0, 0, 0, 0.5);
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
    --btn-icon-bg: #e2e8f0;
    --btn-icon-hover: #cbd5e1;
    --tag-text: #ffffff;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --perfect-stroke: #ffffff;
}

body.dark-mode {
    /* Dark Theme */
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --primary: #a78bfa;
    --primary-hover: #8b5cf6;
    --input-bg: #334155;
    --input-border: #475569;
    --btn-icon-bg: #334155;
    --btn-icon-hover: #475569;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --perfect-stroke: #0f172a;
}

/* ==================== BASE LAYOUT ==================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    font-weight: 400;
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0;
}

.container {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    text-align: center;
    width: 90%;
    max-width: 450px;
    position: relative;
    min-height: 520px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.container.spaced {
    justify-content: space-between;
}

h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
}

/* ==================== LOGO ==================== */
.logo-container {
    width: 100%;
    display: flex;
    justify-content: center;
    user-select: none;
}

.logo-container svg {
    width: 300px;
    height: auto;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    margin: 0 auto;
}

body.dark-mode .logo-text {
    fill: var(--text-main);
}

/* ==================== HEADER ==================== */
.header-row {
    display: flex;
    flex-direction: row;
    min-width: auto;
    z-index: 10;
    gap: 10px;
}

.header-row.spaced {
    width: 100%;
    justify-content: space-between;
    min-width: max-content;
}

.header-left {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: var(--btn-icon-bg);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-sub);
    transition: background 0.2s, transform 0.1s;
    border: none;
    font-size: 1.1rem;
    font-family: 'Fredoka', sans-serif;
}

.icon-btn:hover {
    background: var(--btn-icon-hover);
}

.icon-btn:active {
    transform: scale(0.95);
}

.score-badge {
    background: var(--btn-icon-bg);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-sub);
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.score-badge.highscore {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* ==================== EMOJI DISPLAY ==================== */
.emoji-display {
    font-size: 7rem;
    margin: 2rem 0 0 0;
    line-height: 1;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

html.non-apple .emoji-display {
    font-family: 'Noto Color Emoji', sans-serif;
}

html.non-apple svg {
    font-family: 'Noto Color Emoji', sans-serif;
}

/* ==================== WORD TAGS ==================== */
.found-words-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    min-height: 2.5rem;
    margin-bottom: 1rem;
    width: 100%;
}

.word-tag {
    background-color: var(--primary);
    color: var(--tag-text);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    animation: popIn 0.3s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
}

.word-tag.exact {
    background-color: #4f46e5;
    border: 2px solid #c7d2fe;
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== INPUT & BUTTONS ==================== */
.input-area {
    width: 100%;
    transition: opacity 0.3s;
}

input[type="text"] {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    border-radius: 14px;
    font-size: 1.1rem;
    outline: none;
    text-align: center;
    font-family: 'Fredoka', sans-serif;
    font-weight: 500;
    transition: border-color 0.2s, background-color 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

button.submit-btn,
button.restart-btn {
    margin-top: 1rem;
    width: 100%;
    padding: 14px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: 'Fredoka', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

button.share-btn {
    margin-top: calc(1rem + 10px);
    width: 100%;
    padding: 14px;
    background-color: var(--btn-icon-bg);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: 'Fredoka', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

button.submit-btn:hover,
button.restart-btn:hover,
button.share-btn:hover {
    background-color: var(--primary-hover);
}

button.submit-btn:active,
button.restart-btn:active {
    transform: scale(0.98);
}

.key-hint {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-block;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ==================== ANIMATIONS ==================== */
.score-pulse {
    animation: scorePulse 0.5s ease-out;
    background-color: var(--gold) !important;
    color: white !important;
    transform: scale(1.1);
}

@keyframes scorePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.floating-perfect {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gold);
    pointer-events: none;
    opacity: 0;
    z-index: 20;
    white-space: nowrap;
    -webkit-text-stroke: 1.5px var(--perfect-stroke);
    paint-order: stroke fill;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25));
    user-select: none;
}

.animate-perfect {
    animation: floatUp 1.5s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -20px) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -60px) scale(1);
    }
}

/* ==================== SUCCESS MESSAGE ==================== */
.success-message {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.full-name-reveal {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 10px 0;
    text-transform: capitalize;
}

/* ==================== MODAL ==================== */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    max-width: 400px;
    width: 85%;
    text-align: left;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-card ul {
    padding-left: 20px;
    line-height: 1.6;
    color: var(--text-sub);
    font-size: 1rem;
}

.modal-card code {
    background: var(--btn-icon-bg);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Fredoka', sans-serif;
    color: var(--primary);
    font-weight: 600;
}

.close-modal-btn {
    background: var(--text-main);
    color: var(--bg-color);
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    float: right;
    margin-top: 1rem;
    font-weight: 600;
    font-family: 'Fredoka', sans-serif;
    transition: transform 0.1s;
}

.close-modal-btn:active {
    transform: scale(0.95);
}

/* ==================== GAME OVER ==================== */
h1.game-over-title {
    color: var(--danger);
    margin: 0 0 10px 0;
    font-weight: 700;
}

.solution-reveal {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 10px 0;
    color: var(--text-main);
    text-transform: capitalize;
}

.stats-grid {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 20px;
    background: var(--btn-icon-bg);
    padding: 15px;
    border-radius: 16px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-sub);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.restart-btn {
    background-color: var(--text-main);
    color: var(--bg-color);
    margin-top: 20px;
}

/* ==================== LOADER ==================== */
.loader {
    border: 5px solid var(--btn-icon-bg);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    color: var(--danger);
    margin-top: 1rem;
    font-size: 0.95rem;
}

/* ==================== MOBILE RESPONSIVE ==================== */

/* Tablet (landscape phones and small tablets) */
@media (max-width: 768px) {
    .container {
        padding: 1.75rem;
        min-height: 450px;
        width: 92%;
    }

    .logo-container svg {
        width: 260px;
    }

    .emoji-display {
        font-size: 6rem;
        margin: 1.6rem 0 0 0;
        min-height: 100px;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
        font-size: 1.15rem;
    }

    .score-badge {
        padding: 9px 18px;
        font-size: 1rem;
    }

    input[type="text"] {
        padding: 15px;
        font-size: 1.05rem;
    }

    button.submit-btn,
    button.restart-btn {
        padding: 15px;
        font-size: 1.05rem;
    }

    .word-tag {
        padding: 7px 13px;
        font-size: 0.95rem;
    }

    .modal-card {
        width: 90%;
        max-height: 85vh;
    }
}

/* Mobile (portrait phones) */
@media (max-width: 480px) {
    .container {
        padding: 1.25rem;
        width: 95%;
        border-radius: 20px;
    }

    .emoji-display {
        font-size: 5rem;
        margin: 1.15rem 0 0 0;
        min-height: 85px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
        /* Increased touch target size for accessibility */
    }

    .score-badge {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    button.submit-btn,
    button.restart-btn {
        padding: 16px;
        font-size: 1.05rem;
        min-height: 52px;
        /* Ensure comfortable touch target */
    }

    input[type="text"] {
        padding: 16px;
        font-size: 16px;
        /* Prevents iOS auto-zoom */
        min-height: 52px;
    }

    .key-hint {
        display: none;
    }

    .logo-container svg {
        width: 220px;
    }

    .content-wrapper {
        padding: 1rem 0;
        gap: 0.75rem;
    }

    .word-tag {
        padding: 8px 14px;
        font-size: 0.9rem;
        gap: 5px;
    }

    .found-words-container {
        gap: 5px;
        min-height: 2rem;
        margin-bottom: 0.75rem;
    }

    .full-name-reveal,
    .solution-reveal {
        font-size: 1.4rem;
    }

    .stats-grid {
        flex-direction: row;
        gap: 1rem;
        padding: 12px;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .modal-card {
        padding: 1.5rem;
        width: 92%;
        max-height: 90vh;
        border-radius: 16px;
    }

    .modal-card h2 {
        font-size: 1.4rem;
    }

    .modal-card ul {
        font-size: 0.95rem;
        padding-left: 18px;
    }

    .close-modal-btn {
        padding: 12px 24px;
        font-size: 1rem;
        min-height: 48px;
        /* Accessible touch target */
    }

    .floating-perfect {
        font-size: 2rem;
    }

    h1.game-over-title {
        font-size: 2rem;
    }
}

/* Small mobile (very narrow screens) */
@media (max-width: 360px) {
    .container {
        padding: 1rem;
    }

    .emoji-display {
        font-size: 4.5rem;
        margin: 0.8rem 0 0 0;
    }

    .logo-container svg {
        width: 200px;
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .score-badge {
        padding: 8px 14px;
        font-size: 0.9rem;
    }

    .word-tag {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .full-name-reveal,
    .solution-reveal {
        font-size: 1.25rem;
    }

    .modal-card {
        padding: 1.25rem;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    .container {
        padding: 1.5rem;
        min-height: 450px;
    }

    .emoji-display {
        font-size: 4.5rem;
        margin: 0.6rem 0 0 0;
        min-height: 70px;
    }

    .logo-container svg {
        width: 200px;
    }

    .content-wrapper {
        padding: 0.5rem 0;
        gap: 0.5rem;
    }

    .found-words-container {
        margin-bottom: 0.5rem;
        min-height: 1.75rem;
    }

    .modal-card {
        max-height: 95vh;
    }
}

/* ==================== FOOTER ==================== */
footer {
    text-align: center;
    padding: 2rem 1rem 1rem 1rem;
    color: var(--text-sub);
    font-size: 0.9rem;
    width: 100%;
    margin-top: auto;
}

footer p {
    margin: 0.5rem 0;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
    padding: 0.25rem 0.5rem;
    /* Increase touch target */
}

footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

@media (max-width: 480px) {
    footer {
        padding: 1.5rem 1rem 1rem 1rem;
        font-size: 0.85rem;
    }

    footer a {
        padding: 0.5rem;
        /* Larger touch targets on mobile */
        display: inline-block;
    }
}