@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* =========================
   CSS Variables for Themes
   ========================= */

:root {
    /* Default Edgy Neon Theme */
    --bg-primary: radial-gradient(1200px 600px at 10% 10%, rgba(140, 34, 255, 0.12), transparent 10%),
                  radial-gradient(900px 500px at 90% 90%, rgba(29, 233, 182, 0.08), transparent 10%),
                  linear-gradient(180deg, #0f1724 0%, #071124 100%);
    --bg-secondary: rgba(255, 255, 255, 0.04);
    --card-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.06);
    --text-primary: #E6F0FF;
    --text-secondary: #9fb4d6;
    --accent: #7C4DFF; /* neon purple */
    --accent-2: #00F5A0; /* neon green */
    --accent-hover: #9a6bff;
    --neon: rgba(124, 77, 255, 0.14);
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 10px 30px rgba(2, 6, 23, 0.6);
    --modal-bg: rgba(2, 6, 23, 0.7);
    --toast-bg: rgba(0, 0, 0, 0.6);
    --correct-bg: rgba(124, 209, 172, 0.08);
    --correct-border: rgba(0, 245, 160, 0.9);
    --wrong-color: #ff4d6d;
}

[data-theme="dark"] {
    --bg-primary: linear-gradient(180deg,#04050a 0%, #071124 100%);
    --bg-secondary: rgba(255,255,255,0.02);
    --text-primary: #e6eefc;
    --text-secondary: #93a8c9;
    --accent: #7C4DFF;
    --accent-hover: #8f6bff;
    --border: rgba(255,255,255,0.04);
    --shadow: 0 18px 60px rgba(2,6,23,0.75);
    --modal-bg: rgba(0,0,0,0.7);
    --toast-bg: rgba(255,255,255,0.06);
    --toast-text: #e6eefc;
    --correct-bg: rgba(124,209,172,0.08);
    --correct-border: rgba(0,245,160,0.9);
    --wrong-color: #ff6b81;
}

[data-theme="light"] {
    --bg-primary: linear-gradient(180deg,#f7fbff 0%, #eaf4ff 100%);
    --bg-secondary: #ffffff;
    --text-primary: #0b1220;
    --text-secondary: #5b6f88;
    --accent: #1167b1;
    --accent-hover: #0d5aa2;
    --border: rgba(10,20,34,0.06);
    --shadow: 0 10px 30px rgba(16,24,40,0.06);
    --modal-bg: rgba(0,0,0,0.18);
    --toast-bg: rgba(0,0,0,0.06);
    --correct-bg: rgba(46,125,50,0.06);
    --correct-border: rgba(46,125,50,0.8);
    --wrong-color: #d32f2f;
}

/* Additional theme presets */
[data-theme="cyberpunk"]{
    --bg-primary: radial-gradient(800px 400px at 10% 10%, rgba(255,0,128,0.06), transparent 10%),
                  radial-gradient(700px 350px at 90% 90%, rgba(0,240,255,0.05), transparent 10%),
                  linear-gradient(180deg,#041022 0%, #071124 100%);
    --bg-secondary: rgba(255,255,255,0.02);
    --text-primary: #e8f6ff;
    --text-secondary: #9bd6ff;
    --accent: #ff00c3;
    --accent-2: #00fff0;
    --border: rgba(255,255,255,0.03);
    --shadow: 0 20px 60px rgba(2,6,23,0.8);
}

[data-theme="retro"]{
    --bg-primary: linear-gradient(180deg,#2b1b58 0%, #22183f 100%);
    --bg-secondary: rgba(255,255,255,0.02);
    --text-primary: #fff0d9;
    --text-secondary: #d8c6a0;
    --accent: #ff9f1c;
    --accent-2: #ff3b3b;
    --border: rgba(255,255,255,0.03);
    --shadow: 0 16px 48px rgba(10,6,20,0.7);
}

[data-theme="pastel"]{
    --bg-primary: linear-gradient(180deg,#fff7fb 0%, #f7fff9 100%);
    --bg-secondary: #ffffff;
    --text-primary: #1a2430;
    --text-secondary: #6b7686;
    --accent: #ff7ab6;
    --accent-2: #7ad1ff;
    --border: rgba(10,20,34,0.04);
    --shadow: 0 8px 24px rgba(16,24,40,0.06);
}

/* Footer styles added for the persistent tip */
.site-footer{
    position:fixed;
    left:0; right:0; bottom:12px;
    display:flex; justify-content:center; pointer-events:none; z-index:10000;
}
.footer-note{
    background: rgba(2,6,23,0.45);
    color: var(--text-secondary);
    padding:8px 12px;
    border-radius:10px;
    font-size:13px;
    pointer-events:auto;
    border:1px solid rgba(255,255,255,0.03);
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins',sans-serif;
}

body{
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.4s ease, color 0.3s ease;
    overflow: hidden;
}

/* theme crossfade helper */
.theme-transition * {
    transition: background-color .28s ease, color .28s ease, border-color .28s ease, box-shadow .28s ease !important;
}

/* Background Animation */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(124,77,255,0.18), rgba(0,245,160,0.12));
    filter: blur(14px) saturate(1.2);
    mix-blend-mode: screen;
    animation: floaty 14s linear infinite;
}

.circle:nth-child(1) { width: 20px; height: 20px; left: 10%; animation-delay: 0s; }
.circle:nth-child(2) { width: 30px; height: 30px; left: 20%; animation-delay: 1s; }
.circle:nth-child(3) { width: 15px; height: 15px; left: 30%; animation-delay: 2s; }
.circle:nth-child(4) { width: 25px; height: 25px; left: 40%; animation-delay: 3s; }
.circle:nth-child(5) { width: 18px; height: 18px; left: 50%; animation-delay: 4s; }
.circle:nth-child(6) { width: 22px; height: 22px; left: 60%; animation-delay: 5s; }
.circle:nth-child(7) { width: 28px; height: 28px; left: 70%; animation-delay: 6s; }
.circle:nth-child(8) { width: 16px; height: 16px; left: 80%; animation-delay: 7s; }
.circle:nth-child(9) { width: 24px; height: 24px; left: 90%; animation-delay: 8s; }
.circle:nth-child(10) { width: 20px; height: 20px; left: 95%; animation-delay: 9s; }

@keyframes fall {
    0% { transform: translateY(-10vh) scale(0.8); opacity: 0; }
    10% { opacity: 0.9; }
    50% { transform: translateY(30vh) scale(1.05); }
    100% { transform: translateY(120vh) scale(1.2); opacity: 0; }
}

@keyframes floaty {
    0% { transform: translateY(-10vh) translateX(0) scale(0.9); opacity: 0; }
    25% { transform: translateY(5vh) translateX(10px) scale(1); opacity: 1; }
    50% { transform: translateY(-4vh) translateX(-10px) scale(1.05); }
    75% { transform: translateY(8vh) translateX(6px) scale(1); }
    100% { transform: translateY(120vh) translateX(0) scale(1.15); opacity: 0; }
}

.wrapper{
    width: 460px;
    max-width: calc(100% - 48px);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    overflow: visible;
    -webkit-backdrop-filter: blur(10px) saturate(1.05);
    backdrop-filter: blur(10px) saturate(1.05);
    border: 1px solid var(--glass-border);
    position: relative;
    padding: 18px 20px 28px;
    display:flex;
    flex-direction:column;
    align-items:center;
}

.wrapper h1{
    font-size: 22px;
    text-align: center;
    font-weight: 700;
    margin: 4px 0 12px;
    padding: 6px 0 12px;
    color: var(--text-primary);
    letter-spacing: 0.6px;
    text-shadow: 0 6px 18px rgba(124,77,255,0.06);
}

/* Digital Clock */
.digital-clock {
    position: absolute;
    top: 12px;
    left: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.03);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.wrapper .content{
    margin: 8px 12px 6px;
    width:100%;
    max-width:420px;
    display:flex;
    flex-direction:column;
    align-items:center;
}

.content .word{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 72px;
    align-items: center;
    gap: 8px;
}

/* Decorative shapes inside card */
.decor{ position:absolute; inset:auto; right:18px; top:72px; pointer-events:none; z-index:0 }
.decor .shape{ display:block; position:absolute; border-radius:8px; filter: blur(6px); opacity:0.85 }
.decor .s1{ width:86px;height:86px; right:-18px; top:-28px; background: linear-gradient(135deg, rgba(124,77,255,0.22), rgba(0,245,160,0.12)); transform: rotate(18deg); }
.decor .s2{ width:52px;height:52px; right:6px; top:36px; background: linear-gradient(135deg, rgba(124,77,255,0.14), rgba(0,245,160,0.08)); border-radius:12px; }
.decor .s3{ width:120px;height:12px; right:-12px; top:110px; background: linear-gradient(90deg, rgba(124,77,255,0.12), rgba(0,245,160,0.06)); border-radius:6px; transform: rotate(-10deg) }

@media (max-width:520px){ .decor{ display:none } }

.word input{
    height: 56px;
    width: 52px;
    margin: 4px;
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.04);
    background: rgba(255,255,255,0.03);
    text-align: center;
    border-radius: 12px;
    text-transform: uppercase;
    pointer-events: none;
    font-size: 20px;
    font-weight: 700;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: inset 0 -6px 18px rgba(2,6,23,0.35);
}

/* input press micro-interaction */
.word input:active{ transform: translateY(2px) scale(0.995) }
.word input.revealed{ box-shadow: 0 10px 30px rgba(124,77,255,0.06); transform: translateY(-6px) }

.type-input{
    /* keep this input visually hidden but focusable for keyboard users */
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.word input:first-child{
    margin-left: 0;
}

.content .info{
    margin: 20px 0;
}

.info p{
    font-size: 16px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* Settings */
.settings {
    margin: 14px 0;
    text-align: center;
}
.settings label {
    margin-right: 10px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Dropdown styling for all select elements to follow theme */
select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 30px 6px 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    position: relative;
}

select::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-primary);
    pointer-events: none;
}

select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.2);
}

select option {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 8px;
}

/* make dropdown visually match active theme */
#theme {
    padding: 8px 30px 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    color: var(--text-primary);
}

/* Responsive: stack settings and buttons for small screens */
@media (max-width: 520px){
    .wrapper{ width:96%; padding:16px }
    .wrapper .content{ margin:8px 8px 14px }
    .settings{ display:flex; flex-wrap:wrap; gap:8px; justify-content:center }
    .theme-presets{ order:3; width:100%; justify-content:center }
    .buttons{ width:100%; gap:8px; display:flex; flex-direction:column }
    .content .buttons .reset, .content .buttons .showhint{ width:100% }
    .stats{ width:100%; justify-content:space-between }
}

/* sound toggle button */
.sound-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    margin-left:8px;
    padding:6px 10px;
    border-radius:8px;
    border:1px solid rgba(255,255,255,0.04);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    color:var(--text-primary);
    cursor:pointer;
    transition: transform .12s ease, box-shadow .12s ease;
}
.sound-toggle[aria-pressed="true"]{ box-shadow: 0 8px 22px rgba(124,77,255,0.14); transform: translateY(-3px) }

/* Theme preset thumbnails */
.theme-presets{ display:flex; gap:8px; align-items:center; margin-left:10px; margin-top:8px }
.preset-btn{ width:34px; height:34px; border-radius:8px; padding:6px; border:1px solid rgba(255,255,255,0.03); background:transparent; cursor:pointer }
.preset-btn[aria-pressed="true"]{ box-shadow: 0 10px 26px rgba(0,0,0,0.18); transform: translateY(-4px); }
.swatch{ display:block; width:100%; height:100%; border-radius:6px; box-shadow: inset 0 -6px 10px rgba(0,0,0,0.08) }
.sw-default{ background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)) }
.sw-dark{ background: linear-gradient(90deg,#071124,#0b1230) }
.sw-light{ background: linear-gradient(90deg,#f7fbff,#eaf4ff) }
.sw-cyberpunk{ background: linear-gradient(90deg,#ff00c3,#00fff0) }
.sw-retro{ background: linear-gradient(90deg,#ff9f1c,#ff3b3b) }
.sw-pastel{ background: linear-gradient(90deg,#ff7ab6,#7ad1ff) }

/* Buttons */
.buttons{
    display: flex;
    justify-content: space-between;
}

.content .buttons .reset, .content .buttons .showhint{
    width: 48%;
    border: none;
    cursor: pointer;
    color: #0b1020;
    outline: none;
    padding: 12px 0;
    font-size: 15px;
    background: linear-gradient(90deg,var(--accent), var(--accent-2));
    border-radius: 12px;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 6px 20px rgba(124,77,255,0.12), 0 2px 6px rgba(0,245,160,0.06) inset;
    font-weight: 700;
}

.content .buttons .reset:hover, .content .buttons .showhint:hover{
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 18px 40px rgba(124,77,255,0.14), 0 6px 14px rgba(0,245,160,0.08);
}

@media screen and (max-width: 450px) {
    
    .wrapper{
        width: 100%;
    }

    .wrapper h1{
        font-size: 20px;
        padding: 16px 20px;
    }

    .wrapper .content{
        margin: 25px 20px 30px;
    }

    .word input{
        height: 46px;
        width: 45px;
        margin: 3px;
        font-size: 19px;
    }

    .content .info p{
        font-size: 15px;
    }

    .content .buttons .reset{
        padding: 9px 0;
        font-size: 15px;
    }

}

/* Stats */
.stats{
    display:flex;
    justify-content:space-between;
    margin-top:12px;
}
.stats p{font-size:14px;color:var(--text-secondary);font-weight:600}

/* Modal overlay */
.modal{
    position:fixed;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    background:var(--modal-bg);
    z-index:9999;
    transition: opacity 0.2s ease;
}
.modal.hidden{display:none}
.modal-content{
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
    padding:20px 24px;
    border-radius:14px;
    width:360px;
    max-width: calc(100% - 40px);
    text-align:center;
    box-shadow: 0 30px 80px rgba(2,6,23,0.7);
    color: var(--text-primary);
    border: 1px solid rgba(124,77,255,0.08);
}
.modal-content{ transform: translateY(18px) scale(.98); opacity:0; transition: transform .28s cubic-bezier(.2,.9,.3,1), opacity .2s ease }
.modal:not(.hidden) .modal-content{ transform: translateY(0) scale(1); opacity:1 }
.modal-title{font-size:22px;margin-bottom:8px;color:var(--text-primary);font-weight:800}
.modal-body{margin-bottom:18px;color:var(--text-secondary);font-size:15px}
.modal-actions .modal-play{
    background: linear-gradient(90deg,var(--accent), var(--accent-2));
    color:#061026;
    border:none;
    padding:10px 18px;
    border-radius:12px;
    cursor:pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-weight:700;
}
.modal-actions .modal-play:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 26px 60px rgba(124,77,255,0.14), 0 8px 18px rgba(0,245,160,0.06);
}

/* Visual feedback classes */

/* correct letter flash */
.word input.correct {
    animation: correctFlash 700ms ease;
    box-shadow: 0 0 6px var(--correct-border);
    border-color: var(--correct-border);
    background: var(--correct-bg);
}
@keyframes correctFlash {
    0% { transform: translateY(-4px); }
    50% { transform: translateY(0); }
    100% { transform: translateY(-1px); }
}

/* wrong guess animation on the .wrong paragraph */
.wrong.wrong-anim {
    animation: wrongShake 600ms;
    color: var(--wrong-color);
    font-weight: 600;
}
@keyframes wrongShake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* Already guessed highlight (applied to guess span) */
.already {
    animation: alreadyFlash 600ms;
}
@keyframes alreadyFlash {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.65; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 36px;
    background: linear-gradient(90deg, rgba(124,77,255,0.12), rgba(0,245,160,0.08));
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, bottom .28s ease, transform .18s ease;
}
.toast.show {
    opacity: 1;
    pointer-events: auto;
    bottom: 48px;
}
[data-theme="dark"] .toast {
    color: var(--toast-text);
}

/* Responsive Design - Mobile First */

/* Large mobiles and small tablets (up to 768px) */
@media (max-width: 768px) {
    body { padding: 16px; }
    .wrapper { width: 100%; max-width: 480px; padding: 16px 18px 24px; }
    .wrapper h1 { font-size: 20px; margin-bottom: 8px; }
    .digital-clock { top: 8px; left: 12px; font-size: 12px; padding: 4px 8px; }
    .content .word { gap: 6px; min-height: 60px; }
    .word input { height: 48px; width: 46px; font-size: 18px; margin: 3px; }
    .settings { margin: 12px 0; }
    .settings select { font-size: 14px; padding: 8px 12px; }
    .theme-presets { gap: 6px; margin-top: 6px; }
    .preset-btn { width: 32px; height: 32px; }
    .buttons { gap: 12px; }
    .content .buttons .reset, .content .buttons .showhint { padding: 14px 0; font-size: 16px; min-height: 48px; }
    .info p { font-size: 15px; margin-bottom: 8px; }
    .stats p { font-size: 13px; }
    .modal-content { width: 90%; padding: 18px 20px; }
    .modal-title { font-size: 20px; }
    .modal-body { font-size: 14px; }
    .modal-actions .modal-play { padding: 12px 20px; font-size: 16px; min-height: 44px; }
    .toast { bottom: 20px; padding: 12px 16px; font-size: 15px; }
    .site-footer { bottom: 8px; }
    .footer-note { font-size: 12px; padding: 6px 10px; }
}

/* Medium mobiles (up to 600px) */
@media (max-width: 600px) {
    .wrapper { padding: 14px 16px 20px; }
    .wrapper h1 { font-size: 18px; }
    .content .word { gap: 4px; }
    .word input { height: 44px; width: 42px; font-size: 16px; }
    .settings { flex-direction: column; align-items: center; gap: 10px; }
    .settings label { margin-right: 0; margin-bottom: 4px; }
    .theme-presets { justify-content: center; margin-top: 8px; }
    .buttons { flex-direction: column; gap: 8px; }
    .content .buttons .reset, .content .buttons .showhint { width: 100%; padding: 16px 0; font-size: 16px; }
    .info { margin: 16px 0; }
    .info p { font-size: 14px; }
    .stats { flex-direction: column; gap: 4px; align-items: center; }
    .modal-content { padding: 16px 18px; }
    .toast { font-size: 14px; }
}

/* Small mobiles (up to 520px) */
@media (max-width: 520px) {
    .decor { display: none; }
    .wrapper { width: 96%; padding: 16px 12px 20px; }
    .wrapper .content { margin: 8px 8px 14px; }
    .settings { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
    .theme-presets { order: 3; width: 100%; justify-content: center; }
    .buttons { width: 100%; gap: 8px; display: flex; flex-direction: column; }
    .content .buttons .reset, .content .buttons .showhint { width: 100%; padding: 14px 0; font-size: 15px; }
    .stats { width: 100%; justify-content: space-between; flex-direction: row; }
    .word input { height: 50px; width: 44px; font-size: 18px; }
    .content .buttons .reset, .content .buttons .showhint { padding: 10px 0; font-size: 14px; }
}

/* Extra small mobiles (up to 450px) */
@media (max-width: 450px) {
    body { padding: 12px; }
    .wrapper { width: 100%; padding: 12px 10px 16px; }
    .wrapper h1 { font-size: 16px; padding: 8px 0 10px; }
    .wrapper .content { margin: 6px 6px 10px; }
    .content .word { gap: 3px; min-height: 50px; }
    .word input { height: 40px; width: 38px; margin: 2px; font-size: 15px; }
    .content .info { margin: 14px 0; }
    .info p { font-size: 13px; margin-bottom: 6px; }
    .settings select { font-size: 13px; padding: 6px 8px; }
    .content .buttons .reset, .content .buttons .showhint { padding: 12px 0; font-size: 14px; }
    .modal-content { width: 95%; padding: 14px 16px; }
    .modal-title { font-size: 18px; }
    .modal-body { font-size: 13px; }
    .modal-actions .modal-play { padding: 10px 16px; font-size: 15px; }
    .toast { padding: 10px 12px; font-size: 13px; }
    .site-footer { bottom: 6px; }
    .footer-note { font-size: 11px; padding: 5px 8px; }
}
