/* ==========================================================================
   css/style.css - Pure Vanilla CSS (No External CDN / Strict CSP Compliant)
   ========================================================================== */

:root {
    --primary-50: #f0fdfa;
    --primary-100: #ccfbf1;
    --primary-200: #99f6e4;
    --primary-300: #5eead4;
    --primary-400: #2dd4bf;
    --primary-500: #14b8a6;
    --primary-600: #0d9488;
    --primary-700: #0f766e;
    --primary-800: #115e59;
    --primary-900: #134e4a;
    
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --amber-50: #fffbeb;
    --amber-100: #fef3c7;
    --amber-400: #fbbf24;
    --amber-500: #f59e0b;
    --amber-600: #d97706;
    --amber-700: #b45309;

    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-600: #059669;
    --emerald-700: #047857;

    --rose-50: #fff1f2;
    --rose-100: #ffe4e6;
    --rose-600: #e11d48;
    --rose-700: #be123c;
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #e6f4f1 0%, #f4fbf9 50%, #e0f2fe 100%);
    color: var(--slate-800);
    min-height: 100vh;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

/* Container */
.app-container {
    max-width: 1140px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--primary-100);
    border-radius: 1.25rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px -2px rgba(15, 118, 110, 0.05);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 0.85rem;
    background: var(--primary-500);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
    flex-shrink: 0;
}

.brand-icon-box svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--slate-800);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.825rem;
    color: var(--slate-500);
    margin-top: 0.15rem;
}

.header-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.stat-badge svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.stat-time {
    background: rgba(240, 253, 250, 0.9);
    border-color: var(--primary-100);
    color: var(--slate-700);
}
.stat-time svg { fill: var(--primary-600); }
.stat-time span { font-family: monospace; font-weight: 700; font-size: 0.95rem; }

.stat-score {
    background: var(--amber-50);
    border-color: var(--amber-100);
    color: var(--slate-700);
}
.stat-score svg { fill: var(--amber-500); }
.stat-score .score-val { color: var(--amber-700); font-weight: 800; }

.btn-audio {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    color: var(--slate-700);
    border-radius: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-audio:hover {
    background: var(--primary-100);
    border-color: var(--primary-200);
}

.btn-audio.active {
    background: var(--primary-100);
    border-color: var(--primary-300);
    color: var(--primary-800);
}

.btn-audio svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Main Grid Layout */
.app-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 992px) {
    .app-main {
        grid-template-columns: 7fr 5fr;
    }
}

/* Cards & Panels */
.card-panel {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--primary-100);
    border-radius: 1.25rem;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px -2px rgba(15, 118, 110, 0.05);
}

/* Left Section: Board & Controls */
.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    border-radius: 0.75rem;
    font-size: 0.825rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.btn-primary {
    background: var(--primary-600);
    color: white;
    box-shadow: 0 3px 10px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover { background: var(--primary-700); transform: translateY(-1px); }

.btn-success {
    background: var(--emerald-600);
    color: white;
    box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
}
.btn-success:hover { background: var(--emerald-700); transform: translateY(-1px); }

.btn-warning {
    background: var(--amber-500);
    color: white;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.25);
}
.btn-warning:hover { background: var(--amber-600); transform: translateY(-1px); }

.btn-secondary {
    background: var(--slate-100);
    color: var(--slate-600);
    border: 1px solid var(--slate-200);
}
.btn-secondary:hover { background: var(--slate-200); color: var(--slate-800); }

/* Active Clue Bar */
.active-clue-bar {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: 0.85rem;
    font-size: 0.85rem;
    color: var(--primary-900);
    font-weight: 600;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* TTS Grid Container */
.grid-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    padding: 0.5rem;
}

.tts-grid {
    display: grid;
    gap: 3px;
    background: var(--slate-300);
    padding: 8px;
    border-radius: 0.9rem;
    border: 1px solid var(--slate-300);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Individual TTS Cell */
.tts-cell {
    position: relative;
    width: 38px;
    height: 38px;
    aspect-ratio: 1;
    transition: all 0.15s ease;
}

@media (min-width: 640px) {
    .tts-cell {
        width: 44px;
        height: 44px;
    }
}

.tts-cell.blocked {
    background-color: var(--slate-300);
    border-radius: 0.35rem;
}

.tts-cell:not(.blocked) {
    background-color: white;
    border-radius: 0.35rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tts-cell input {
    width: 100%;
    height: 100%;
    text-align: center;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 1.15rem;
    border: 1px solid var(--slate-200);
    border-radius: 0.35rem;
    background: transparent;
    outline: none;
    caret-color: transparent;
    user-select: none;
    transition: all 0.15s ease;
}

.tts-cell .cell-number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--primary-700);
    pointer-events: none;
    z-index: 10;
}

/* Active & Focused States */
.tts-cell.active-word input {
    background-color: #ccfbf1 !important;
    border-color: var(--primary-300);
}

.tts-cell.focused input {
    background-color: var(--primary-400) !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(45, 212, 191, 0.7);
    border-color: var(--primary-500);
    transform: scale(1.03);
}

.tts-cell.correct input {
    background-color: #dcfce7 !important;
    color: #15803d !important;
    border-color: #86efac;
}

.tts-cell.incorrect input {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5;
    animation: shake 0.35s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

/* Tips Footer */
.board-tips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 0.75rem;
    color: var(--slate-400);
    padding-top: 0.6rem;
    border-top: 1px solid var(--slate-100);
    gap: 0.5rem;
}

/* Right Column: Clues & Leaderboard */
.side-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--slate-100);
    padding-bottom: 0.75rem;
    margin-bottom: 0.85rem;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--slate-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title svg {
    width: 18px;
    height: 18px;
    fill: var(--primary-500);
}

.badge-tag {
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--emerald-100);
    color: var(--emerald-700);
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
}

/* Clues Container */
.clues-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.clue-group-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.725rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--primary-100);
    color: var(--primary-800);
    padding: 0.3rem 0.65rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.clue-group-badge svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.clue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.clue-item {
    padding: 0.5rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.825rem;
    color: var(--slate-600);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.clue-item:hover {
    background: var(--primary-50);
    border-color: var(--primary-100);
    color: var(--primary-900);
}

.clue-number {
    font-weight: 800;
    color: var(--primary-700);
    width: 18px;
    flex-shrink: 0;
}

/* Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    border-radius: 0.75rem;
    background: var(--slate-50);
    border: 1px solid var(--slate-100);
    transition: all 0.15s ease;
    font-size: 0.825rem;
}

.leaderboard-item:hover {
    background: var(--primary-50);
    border-color: var(--primary-100);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.rank-badge {
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    font-weight: 800;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--slate-200);
    color: var(--slate-600);
    flex-shrink: 0;
}

.rank-1 { background: var(--amber-400); color: white; box-shadow: 0 2px 6px rgba(251, 191, 36, 0.4); }
.rank-2 { background: var(--slate-300); color: var(--slate-700); }
.rank-3 { background: var(--amber-600); color: white; }

.player-name {
    font-weight: 700;
    color: var(--slate-700);
}

.player-date {
    font-size: 0.65rem;
    color: var(--slate-400);
}

.player-score-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}

.time-spent {
    color: var(--slate-400);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.time-spent svg { width: 12px; height: 12px; fill: currentColor; }

.pts-badge {
    font-weight: 800;
    color: var(--primary-700);
    background: rgba(204, 251, 241, 0.6);
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
}

.empty-leaderboard {
    font-size: 0.775rem;
    color: var(--slate-400);
    text-align: center;
    padding: 1rem;
    background: rgba(248, 250, 252, 0.7);
    border-radius: 0.75rem;
    border: 1px dashed var(--slate-200);
}

.btn-reset-leaderboard {
    background: transparent;
    border: none;
    font-size: 0.725rem;
    color: var(--slate-400);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: color 0.15s ease;
}

.btn-reset-leaderboard svg { width: 12px; height: 12px; fill: currentColor; }
.btn-reset-leaderboard:hover { color: var(--rose-600); }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--primary-100);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.crown-circle {
    width: 64px;
    height: 64px;
    border-radius: 9999px;
    background: var(--amber-100);
    color: var(--amber-500);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.crown-circle svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

.modal-title {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--slate-800);
}

.modal-subtitle {
    font-size: 0.825rem;
    color: var(--slate-500);
    margin-top: 0.25rem;
}

.modal-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: var(--primary-50);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--primary-100);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--slate-400);
    text-transform: uppercase;
    font-weight: 700;
    display: block;
}

.stat-huge-score {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-700);
}

.stat-huge-time {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--slate-700);
}

.form-group {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-600);
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: 0.75rem;
    border: 1px solid var(--slate-200);
    outline: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--slate-700);
    font-family: inherit;
    transition: all 0.15s ease;
}

.form-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.25);
}

.btn-full {
    width: 100%;
    padding: 0.85rem;
    justify-content: center;
    font-size: 0.9rem;
}

/* Footer */
.app-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--slate-400);
    padding: 1rem 0;
}

.app-footer a {
    color: var(--primary-600);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.15s ease;
}

.app-footer a:hover {
    color: var(--primary-800);
    text-decoration: underline;
}

/* Animations */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--slate-100);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-200);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-400);
}
