/* style.css — Complete responsive styles for Wordtexto */

/* ─── Reset & Variables ─────────────────────────────────────────── */

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

/* Default: dark mode */
:root {
    --bg: #0F0D1A;
    --bg-card: #1A1833;
    --text: #E8E5F5;
    --text-muted: #9B97B0;
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --accent: #2DD4BF;
    --border: #2D2A45;
    --input-bg: #13112A;
    --error: #F87171;
    --success: #34D399;
    --rank-found: #2DD4BF;
    --rank-hot: #34D399;
    --rank-warm: #FBBF24;
    --rank-cool: #FB923C;
    --rank-cold: #F87171;
}

/* Light mode override */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #F8F7FC;
        --bg-card: #FFFFFF;
        --text: #1A1833;
        --text-muted: #6B6B80;
        --border: #E2E0EF;
        --input-bg: #F0EFF5;
    }
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ─── Animations ────────────────────────────────────────────────── */

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1); opacity: 1; }
}

/* ─── Header ────────────────────────────────────────────────────── */

.app-header {
    text-align: center;
    padding: 1rem 0 0.25rem;
}

.app-logo {
    display: block;
    width: 120px;
    margin: 0 auto;
}

/* ─── Nav Tabs ──────────────────────────────────────────────────── */

.app-nav {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.25rem;
    margin: 0.75rem 0;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.04);
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.6rem 0.5rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.nav-tab:not(.active):hover {
    color: var(--text);
    background: var(--border);
}

.nav-tab:not(.active):active {
    transform: scale(0.97);
}

.nav-logout:hover {
    color: var(--error) !important;
    background: rgba(248, 113, 113, 0.1) !important;
}

/* ─── Views ─────────────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease-out; }

/* ─── Stats Bar ─────────────────────────────────────────────────── */

.stats-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat {
    flex: 1;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem 0.25rem;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.04);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Guess Input ───────────────────────────────────────────────── */

.guess-input-area {
    margin-bottom: 0.75rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

#guess-input {
    flex: 1;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

#guess-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

#guess-input::placeholder {
    color: var(--text-muted);
}

#guess-input:disabled {
    opacity: 0.5;
}

.btn-guess {
    min-width: 48px;
    min-height: 48px;
    padding: 0 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.btn-guess:hover { opacity: 0.9; }
.btn-guess:active { transform: scale(0.95); }
.btn-guess:disabled { opacity: 0.5; cursor: not-allowed; }

.guess-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 0.4rem;
    min-height: 1.2em;
}

/* ─── Hint ──────────────────────────────────────────────────────── */

.hint-area {
    text-align: center;
    margin-bottom: 0.75rem;
}

.btn-hint {
    min-height: 44px;
    padding: 0.5rem 1.2rem;
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-hint:hover {
    background: var(--accent);
    color: #fff;
}

.btn-hint:active {
    transform: scale(0.97);
}

.hint-content {
    margin-top: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 600;
    animation: fadeIn 0.3s ease-out;
}

/* ─── Loading ───────────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ─── Guess List ────────────────────────────────────────────────── */

.guess-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.guess-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.03);
    transition: transform 0.15s;
}

.guess-row:hover {
    transform: translateX(2px);
}

.guess-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 1.5rem;
    text-align: center;
}

.guess-word {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
}

.guess-temp {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.guess-rank {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    min-width: 3rem;
    text-align: center;
    color: #fff;
}

/* Rank colour pills */
.rank-found  { background: var(--rank-found); }
.rank-hot    { background: var(--rank-hot); }
.rank-warm   { background: var(--rank-warm); color: #1A1833; }
.rank-cool   { background: var(--rank-cool); color: #1A1833; }
.rank-cold   { background: var(--rank-cold); }

/* ─── Win Message ───────────────────────────────────────────────── */

.win-message {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 0.75rem;
    background: var(--bg-card);
    border: 2px solid var(--rank-found);
    border-radius: 16px;
    animation: popIn 0.5s ease-out;
    box-shadow: 0 4px 20px rgba(45, 212, 191, 0.12);
}

.win-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.win-message h2 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.win-message p {
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-size: 0.95rem;
}

/* ─── Confetti Canvas ───────────────────────────────────────────── */

#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* ─── Leaderboard ───────────────────────────────────────────────── */

.lb-section {
    margin-bottom: 1.5rem;
}

.lb-heading {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lb-heading i {
    color: var(--primary);
}

.lb-table {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.03);
}

.lb-position {
    font-size: 1.1rem;
    min-width: 1.8rem;
    text-align: center;
}

.lb-info {
    flex: 1;
    min-width: 0;
}

.lb-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.lb-badge {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    color: #fff;
    white-space: nowrap;
}

.lb-solved {
    background: var(--rank-found);
}

.lb-unsolved {
    background: var(--border);
    color: var(--text-muted);
}

.lb-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2rem 0;
}

/* All-time stats grid */
.alltime-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.alltime-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.04);
    transition: transform 0.15s;
}

.alltime-stat:hover {
    transform: translateY(-1px);
}

.alltime-stat .stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
}

.alltime-stat .stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

/* ─── Modal ─────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.75rem;
    max-width: 400px;
    width: 100%;
    border: 1px solid var(--border);
    animation: popIn 0.3s ease-out;
}

.modal h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.modal h2 i {
    color: var(--primary);
}

.modal-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.modal-body p {
    margin-bottom: 0.75rem;
}

.modal-body strong {
    color: var(--text);
}

.modal-ranks {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0.75rem 0;
}

.rank-demo {
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
}

.rank-demo.rank-found { background: var(--rank-found); }
.rank-demo.rank-hot   { background: var(--rank-hot); }
.rank-demo.rank-warm  { background: var(--rank-warm); color: #1A1833; }
.rank-demo.rank-cool  { background: var(--rank-cool); color: #1A1833; }
.rank-demo.rank-cold  { background: var(--rank-cold); }

.modal-btn {
    width: 100%;
    min-height: 48px;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.modal-btn:hover { opacity: 0.9; }
.modal-btn:active { transform: scale(0.97); }

/* ─── Auth Pages (Login/Register) ───────────────────────────────── */

.auth-container {
    width: 100%;
    max-width: 400px;
    animation: fadeIn 0.4s ease-out;
}

.auth-logo {
    display: block;
    width: 180px;
    margin: 0 auto 0.5rem;
}

.auth-slogan {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    font-style: italic;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border);
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    border-color: var(--primary);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 44px;
}

.form-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-primary {
    width: 100%;
    min-height: 48px;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }

.auth-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.auth-success {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-align: center;
    animation: fadeIn 0.3s ease-out;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::selection {
    background: var(--primary);
    color: #fff;
}
