/* 10 Vaarthaigal - Post-Modern Minimalist Editorial Stylesheet (Pomo & 18words Inspired) */

@import url('https://fonts.googleapis.com/css2?family=Libre+Caslon+Text:ital,wght@0,400;0,700;1,400&family=Noto+Sans+Tamil:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-solid: #f6f4ed; /* Warm organic linen paper */
    --card-bg: #ffffff; /* Clean white card */
    --border-color: #2c3d48; /* Solid slate charcoal outline */
    --border-light: #e2dbcd; /* Light grid divider */
    
    /* Design Tokens from pomo.gt.ms */
    --text: #2c3d48;
    --text-muted: #6a8494;
    --accent: #5a8fae; /* Pomo Slate Blue */
    --accent-gold: #c4a060; /* Pomo Sand/Gold */
    --accent-gold-active: #b8873a;
    
    /* Semantic soft pastels */
    --color-correct: #8ea382; /* Warm Sage Green */
    --color-correct-light: #f3f6f1;
    --color-incorrect: #c27a75; /* Warm Terracotta */
    --color-incorrect-light: #faf3f2;
    --color-locked: #d8c89b; /* Warm Gold */
    --color-locked-light: #fdfbf7;

    --font-serif: 'Libre Caslon Text', 'Big Caslon', Georgia, serif;
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-tamil: 'Noto Sans Tamil', 'Latha', sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-solid);
    color: var(--text);
    font-family: var(--font-stack);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
}

/* Vignette for paper edge shading */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 60%, rgba(44, 61, 72, 0.05) 100%);
}

#confettiCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
}

/* VIEWPORT CONTAINER */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
    background: transparent;
}

/* MINIMALIST HEADER */
.game-header {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
}

.header-left, .header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-title {
    font-family: var(--font-serif);
    font-size: clamp(20px, 5.5vw, 26px);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

/* Clean Flat Header Buttons */
.icon-btn, .lang-btn {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.icon-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
}

.lang-btn {
    min-width: 52px;
    height: 44px;
    padding: 0 10px;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 16px;
}

.icon-btn:hover, .lang-btn:hover {
    background: var(--bg-solid);
    transform: translateY(-1px);
}

.icon-btn:active, .lang-btn:active {
    transform: translateY(1px);
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    overflow: hidden;
}

.screen {
    display: none;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 16px;
    animation: popIn 0.2s ease-out;
}

/* POST-MODERN EDITORIAL CARD */
.glass-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 4px 4px 0px 0px rgba(44, 61, 72, 0.08);
    position: relative;
}

/* WELCOME SCREEN */
.welcome-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.welcome-heading {
    font-family: var(--font-serif);
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.welcome-desc {
    font-family: var(--font-tamil);
    font-size: 18px;
    color: var(--text-muted);
    line-height: 1.6;
}

.puzzle-info-badge {
    padding: 6px 16px;
    border-radius: 18px;
    background: #faf8f5;
    border: 1px solid var(--border-light);
}

.puzzle-info-badge h3 {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-gold-active);
}

.welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

/* FLAT SOLID BUTTONS */
.primary-btn, .secondary-btn, .outline-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s ease;
    font-family: var(--font-stack);
}

.primary-btn {
    background-color: var(--border-color);
    border: none;
    color: #ffffff;
}

.primary-btn:hover {
    background-color: #3b5261;
    transform: translateY(-1px);
}

.primary-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    color: var(--text);
}

.secondary-btn:hover {
    background-color: var(--bg-solid);
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(1px);
}

.outline-btn {
    background-color: transparent;
    border: 1.5px solid var(--text-muted);
    color: var(--text-muted);
}

.outline-btn:hover {
    border-color: var(--text);
    color: var(--text);
    background-color: var(--bg-solid);
    transform: translateY(-1px);
}

.outline-btn:active {
    transform: translateY(1px);
}

/* TIMER & PROGRESS BAR */
.timer-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.timer-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    color: var(--text-muted);
}

.timer-label span {
    font-family: var(--font-tamil);
    font-weight: 600;
}

#timerText {
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--text);
    font-size: 18px;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #eae6db;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 100%;
    background-color: var(--accent);
    border-radius: 3px;
    transition: width 1s linear, background-color 0.3s ease;
}

.progress-bar-fill.warning {
    background-color: var(--accent-gold);
}

.progress-bar-fill.danger {
    background-color: var(--color-incorrect);
}

/* GAME PLAY CARD */
.game-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: flex-start;
}

.word-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 700;
}

.word-index {
    font-family: var(--font-tamil);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.word-length {
    font-family: var(--font-tamil);
    font-size: 14px;
    color: var(--text-muted);
}

/* PROGRESS DOTS (18words Inspired Soft Rounded Tiles) */
.progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 4px;
}

.progress-dot {
    width: clamp(20px, 6.5vw, 28px);
    height: clamp(20px, 6.5vw, 28px);
    border-radius: 6px;
    background: #eae6db;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.progress-dot.active {
    background: #ffffff;
    border: 1.5px solid var(--text);
    transform: scale(1.15);
}

.progress-dot.correct {
    background: var(--color-correct);
}

.progress-dot.incorrect {
    background: var(--color-incorrect);
}

.progress-dot.pop {
    animation: pgPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pgPop {
    50% { transform: scale(1.25); }
}

/* INPUT LETTER SLOTS */
.letter-slots-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 60px;
    align-items: center;
    padding: 6px 0;
    transition: var(--transition-normal);
}

.letter-slot {
    flex: 1 1 0;
    max-width: 54px;
    aspect-ratio: 1 / 1;
    border: 1.5px solid #d5cebc;
    border-radius: 6px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tamil);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    padding: 0 4px;
}

.letter-slot.filled {
    border-color: var(--text);
    background: #fdfcf7;
    animation: zoomIn 0.12s ease-out;
}

.letter-slot.locked {
    border-color: var(--accent-gold);
    color: var(--accent-gold-active);
    background: #fdfbf7;
    cursor: default;
}

/* Correct Guess Display States */
.letter-slots-container.correct .letter-slot {
    border-color: var(--color-correct) !important;
    background: var(--color-correct-light) !important;
    color: var(--color-correct) !important;
}

.letter-slots-container.incorrect .letter-slot {
    border-color: var(--color-incorrect) !important;
    background: var(--color-incorrect-light) !important;
    color: var(--color-incorrect) !important;
}

/* LETTER TILES KEYBOARD POOL */
.letter-pool-container {
    width: 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.letter-tile {
    min-width: 52px;
    height: 54px;
    background: #ffffff;
    border: 1.5px solid #d5cebc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-tamil);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2.5px 0 0 #d5cebc;
    transition: all 0.1s ease;
    padding: 0 4px;
}

.letter-tile:hover {
    border-color: var(--text);
    box-shadow: 0 2px 0 0 var(--text);
    background: #fdfcf7;
}

.letter-tile:active {
    transform: translateY(2px);
    box-shadow: none;
}

.letter-tile.disabled {
    opacity: 0.2;
    background: #fbfaf7;
    border-color: #eae6db;
    box-shadow: none;
    transform: translateY(2px);
    cursor: default;
    pointer-events: none;
}

/* GAME ACTION BUTTONS */
.game-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

#btnReset, #btnHint {
    flex: 1;
    max-width: 170px;
    padding: 13px 20px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

#btnReset {
    background: #ffffff;
    border: 1.5px solid var(--text-muted);
    color: var(--text-muted);
}

#btnReset:hover {
    border-color: var(--text);
    color: var(--text);
    background: var(--bg-solid);
}

#btnHint {
    background: #fdfbf7;
    border: 1.5px solid var(--accent-gold);
    color: var(--accent-gold-active);
}

#btnHint:hover:not(:disabled) {
    background: var(--accent-gold);
    color: #ffffff;
    border-color: var(--accent-gold);
}

#btnHint:disabled {
    opacity: 0.3;
    border-color: #eae6db;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 61, 72, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease-out forwards;
}

.modal-content {
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    box-shadow: 6px 6px 0px 0px rgba(44, 61, 72, 0.15);
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-content::-webkit-scrollbar {
    width: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #e2dbcd;
    border-radius: 2px;
}

.close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition-fast);
}

.close-btn:hover {
    color: var(--text);
    background: var(--bg-solid);
}

.section-title {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 700;
    margin: 20px 0 10px 0;
    color: var(--text);
    border-left: 3px solid var(--accent-gold);
    padding-left: 8px;
}

/* HOW TO PLAY MODAL */
.help-intro {
    font-size: 17px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.help-step {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
    align-items: flex-start;
}

.help-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-solid);
    border: 1.5px solid var(--text-muted);
    color: var(--text-muted);
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-step p {
    font-size: 16.5px;
    color: var(--text-muted);
    line-height: 1.6;
}

.example-box {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.example-box h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.example-letters {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.example-letters .letter-tile {
    pointer-events: none;
    transform: scale(0.9);
}

.example-box p {
    font-size: 15px;
    color: var(--text-muted);
}

/* STATISTICS MODAL */
.stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0;
}

.stat-card {
    flex: 1;
    background: #faf8f5;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 12px 6px;
    text-align: center;
}

.stat-num {
    font-family: var(--font-serif);
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-lbl {
    font-family: var(--font-tamil);
    font-size: 14px;
    color: var(--text-muted);
}

/* PAST PUZZLES ARCHIVE */
.archive-container {
    width: 100%;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #faf8f5;
    padding: 6px;
    margin-bottom: 16px;
}

.archive-container::-webkit-scrollbar {
    width: 4px;
}

.archive-container::-webkit-scrollbar-thumb {
    background: #e2dbcd;
    border-radius: 2px;
}

.archive-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.archive-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #eae6db;
}

.archive-day-label {
    font-family: var(--font-tamil);
    font-weight: 600;
    color: var(--text);
}

.archive-score-badge {
    padding: 3px 8px;
    border-radius: 10px;
    font-family: var(--font-serif);
    font-size: 11px;
    font-weight: 700;
}

.archive-score-badge.won {
    background: var(--color-correct-light);
    color: var(--color-correct);
    border: 1px solid rgba(142, 163, 130, 0.3);
}

.archive-score-badge.failed {
    background: var(--color-incorrect-light);
    color: var(--color-incorrect);
    border: 1px solid rgba(194, 122, 117, 0.3);
}

.archive-score-badge.unplayed {
    background: #fcfcfc;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.archive-score-badge.unplayed:hover {
    background: var(--text-muted);
    color: #ffffff;
}

/* RESULTS SCREEN MODAL */
.result-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    margin-bottom: 8px;
}

.result-emoji {
    font-size: 40px;
    text-align: center;
    margin-bottom: 12px;
    animation: bounce 2s infinite ease;
}

.result-score-box {
    text-align: center;
    margin-bottom: 16px;
}

.result-score-box h3 {
    font-family: var(--font-tamil);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 10px;
}

.result-mini-grid {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.result-mini-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: #eae6db;
}

.result-mini-dot.correct {
    background: var(--color-correct);
}

.result-mini-dot.incorrect {
    background: var(--color-incorrect);
}

/* COUNTDOWN TIMER CONTAINER */
.countdown-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    border-radius: 6px;
    background: #faf8f5;
    border: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.countdown-container span {
    font-family: var(--font-tamil);
    font-size: 11px;
    color: var(--text-muted);
}

.countdown-timer {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* ANSWERS REVIEW SECTION */
.answers-container-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: left;
    width: 100%;
}

.answers-scroll-box {
    width: 100%;
    max-height: 110px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    background-color: #faf8f5;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.answers-scroll-box::-webkit-scrollbar {
    width: 4px;
}

.answers-scroll-box::-webkit-scrollbar-thumb {
    background: #e2dbcd;
    border-radius: 2px;
}

.answer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    padding: 6px 8px;
    background-color: #ffffff;
    border-radius: 4px;
    border: 1px solid #eae6db;
}

.answer-word-text {
    font-family: var(--font-tamil);
    font-weight: 600;
    color: var(--text);
}

.answer-status-icon {
    font-size: 12px;
}

/* ANIMATIONS & KEYFRAMES */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

@keyframes zoomIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes popIn {
    0% { transform: scale(0.98); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes slideUp {
    0% { transform: translateY(12px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* RESPONSIVE DESIGN */
@media (max-width: 400px) {
    .app-container {
        padding: 0;
    }
    
    .game-header {
        height: 60px;
        padding: 0 12px;
    }
    
    .header-title {
        font-size: clamp(17px, 4.8vw, 20px);
    }
    
    .main-content {
        padding: 12px;
    }
    
    .glass-card {
        padding: 20px 16px;
        border-radius: 8px;
    }
    
    .letter-slots-container {
        gap: 6px;
    }
    
    .letter-slot {
        max-width: 48px;
        padding: 0 2px;
        font-size: 20px;
    }
    
    .letter-tile {
        height: 48px;
        min-width: 46px;
        font-size: 20px;
    }
    
    .primary-btn, .secondary-btn, .outline-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* FOOTER LINK */
.game-footer {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 12px;
}

.game-footer a {
    font-family: var(--font-serif);
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1.5px solid transparent;
    transition: all 0.2s ease;
}

.game-footer a:hover {
    color: var(--text);
    border-bottom-color: var(--text);
}
