/* frontend/style.css */
/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #ef4444;
    --success: #10b981;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --font: 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --surface: #1e293b;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --primary: #3b82f6;
        --primary-hover: #60a5fa;
        --border: #334155;
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    direction: rtl;
    padding: 1rem;
}

/* ===== Screens ===== */
.screen {
    display: none;
    width: 100%;
    max-width: 480px;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.screen.active {
    display: flex;
}

/* ===== Start Screen ===== */
.game-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    text-align: center;
}

.start-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.start-form label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

.start-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-align: right;
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font);
}

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

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-grid .btn-category {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.category-grid .btn-category:hover {
    border-color: var(--primary);
}

.category-grid .btn-category.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-family: var(--font);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-skip {
    flex: 1;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text-muted);
    border: 2px solid var(--border);
}

.btn-skip:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== Game Screen ===== */
.game-top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.timer-display, .score-display, .streak-display {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.timer-display span:first-child {
    font-size: 1.5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.timer-display.danger span:first-child {
    color: var(--danger);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

.timer-label, .score-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

#score-value {
    font-size: 1.5rem;
    font-weight: 800;
}

#streak-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.game-center {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.category-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.words-counter {
    font-size: 0.85rem;
    color: var(--primary);
}

.current-letter {
    font-size: 5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.input-area {
    width: 100%;
    position: relative;
}

#word-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.3rem;
    text-align: center;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    font-family: var(--font);
}

#word-input:focus {
    border-color: var(--primary);
}

.error-message {
    text-align: center;
    color: var(--danger);
    font-size: 0.9rem;
    min-height: 1.5rem;
    margin-top: 0.25rem;
}

.skip-buttons {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.word-chain {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-height: 150px;
    overflow-y: auto;
    padding: 0.5rem;
}

.word-chain .word-tag {
    padding: 0.3rem 0.75rem;
    font-size: 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2rem;
    animation: slideIn 0.3s ease;
}

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

/* ===== Game Over Screen ===== */
.gameover-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--danger);
}

.gameover-stats {
    display: flex;
    gap: 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.stat-label {
    font-size: 1rem;
    color: var(--text-muted);
}

/* ===== Leaderboard Screen ===== */
.leaderboard-title {
    font-size: 1.8rem;
    font-weight: 800;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.leaderboard-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.leaderboard-table tbody tr:nth-child(-n+3) td:first-child {
    font-weight: 800;
    color: var(--primary);
}

/* ===== Category Announcement ===== */
.category-announcement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary);
    color: white;
    padding: 1.5rem 3rem;
    border-radius: var(--radius);
    font-size: 1.5rem;
    font-weight: 700;
    z-index: 100;
    animation: fadeInOut 1.5s ease forwards;
}

.category-announcement.hidden {
    display: none;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* ===== Bonus Time Animation ===== */
.bonus-time {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    color: var(--success);
    font-size: 1.5rem;
    font-weight: 800;
    animation: floatUp 1s ease forwards;
    z-index: 50;
    pointer-events: none;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* ===== Report Button (gameover corner) ===== */
.btn-report-corner {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    font-size: 0.75rem;
    padding: 0.35rem 0.7rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-family: var(--font);
    transition: border-color 0.15s, color 0.15s;
}

.btn-report-corner:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== Report Modal ===== */
.report-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-modal.hidden {
    display: none;
}

.report-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.report-panel {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: min(90vw, 380px);
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1;
    box-shadow: var(--shadow);
}

.report-title {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.report-word-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.report-word-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--bg);
    cursor: pointer;
    user-select: none;
}

.report-word-item:hover {
    background: var(--border);
}

.word-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.word-dot.valid   { background: var(--success); }
.word-dot.invalid { background: var(--danger); }

.report-word-item label {
    flex: 1;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text);
}

.report-word-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.report-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.report-error {
    color: var(--danger);
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.report-error.hidden { display: none; }
