/* ==============================================================
   Quick Math — Home / Mode Selection Page
   Theme values (background gradient, cyan accent, font, card style,
   back-btn) copied verbatim from the existing quickmath.html <style>
   block, so this page feels like the same game.
   ============================================================== */

:root {
    --accent: #00eaff;
    --accent-hover: #294949;
    --warn: #ffea00;
    --muted: #9aa7b2;
    --correct: #37d67a;
    --wrong: #ff5c5c;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-bg-raised: rgba(255, 255, 255, 0.08);
    --border: rgba(0, 234, 255, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    background: radial-gradient(circle at center, #0a0f1f, #000);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: none;
    color: var(--accent);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: color 0.3s, transform 0.3s;
}

.back-btn:hover {
    color: var(--accent-hover);
    transform: scale(1.05);
}

.container {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.05);
    padding: 30px 26px;
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.header {
    text-align: center;
    margin-bottom: 26px;
}

.header h1 {
    color: var(--accent);
    margin: 0 0 8px;
    font-size: 1.7rem;
    text-shadow: 0 0 10px rgba(0, 234, 255, 0.25);
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ---------------- Difficulty selector ---------------- */

.difficulty-section {
    margin-bottom: 26px;
}

.section-label {
    display: block;
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 12px;
}

.difficulty-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.diff-btn {
    position: relative;
    background: var(--card-bg);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 12px 6px 10px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.18s ease, transform 0.15s ease, background-color 0.18s ease;
}

.diff-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 234, 255, 0.3);
}

.diff-btn.active {
    border-color: var(--accent);
    background: rgba(0, 234, 255, 0.08);
}

.diff-btn.active .diff-name {
    color: var(--accent);
}

.diff-name {
    font-weight: 700;
    font-size: 13.5px;
}

.diff-meta {
    font-size: 9.5px;
    color: var(--muted);
    text-align: center;
    line-height: 1.3;
}

.difficulty-note {
    text-align: center;
    color: var(--warn);
    font-size: 12px;
    min-height: 16px;
    margin-top: 10px;
}

/* ---------------- Mode cards ---------------- */

.mode-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: var(--card-bg-raised);
    border: 1.5px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 14px 18px;
    color: #fff;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s ease, border-color 0.18s ease, box-shadow 0.2s ease;
}

.mode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 234, 255, 0.08);
    border-color: rgba(0, 234, 255, 0.35);
}

.mode-icon {
    font-size: 22px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.mode-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.mode-text strong {
    font-size: 15px;
}

.mode-text small {
    color: var(--muted);
    font-size: 12px;
}

.mode-arrow {
    color: var(--muted);
    font-size: 18px;
    transition: transform 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.mode-card:hover .mode-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* ==============================================================
   NEW: Invite / Join overlays
   Same overlay + modal-box pattern already used on the multiplayer
   game screen, so this feels consistent across the whole flow.
   ============================================================== */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-box {
    background: linear-gradient(180deg, rgba(10, 15, 31, 0.98), rgba(0, 0, 0, 0.98));
    border: 1px solid rgba(0, 234, 255, 0.15);
    color: #fff;
    width: min(420px, 92%);
    padding: 26px;
    border-radius: 16px;
    box-shadow: 0 14px 48px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.modal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.modal-header-row h2 {
    color: var(--accent);
    margin: 0;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(0, 234, 255, 0.25);
}

.close-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.close-btn:hover {
    color: #fff;
    background: none;
    box-shadow: none;
}

.modal-sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 18px;
}

.modal-difficulty {
    color: var(--accent);
    font-weight: 700;
}

.dim-text {
    color: var(--muted);
    font-size: 13.5px;
    margin-bottom: 18px;
}

/* Room code display (after generating) */

.room-code-display {
    display: block;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.35);
    border: 1px dashed rgba(0, 234, 255, 0.4);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.copy-btn-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.ghost-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--muted);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
}

.ghost-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: transparent;
    box-shadow: none;
}

.waiting-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 234, 255, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: qmh-spin 0.8s linear infinite;
}

@keyframes qmh-spin {
    to { transform: rotate(360deg); }
}

/* Join code input */

.code-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 10px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.code-input:focus {
    border-color: var(--accent);
}

.join-error {
    color: var(--wrong);
    font-size: 12.5px;
    margin-bottom: 14px;
}

button {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 6px;
    font-weight: bold;
    font-family: inherit;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 10px var(--accent-hover);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 420px) {
    .container {
        padding: 24px 18px;
    }
    .header h1 {
        font-size: 1.4rem;
    }
    .diff-name {
        font-size: 12px;
    }
    .diff-meta {
        font-size: 8.5px;
    }
    .mode-icon {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }
    .mode-text strong {
        font-size: 13.5px;
    }
    .room-code-display {
        font-size: 24px;
    }
}
