/* =============================================================
   ROOT & BASE
   ============================================================= */
:root {
    color-scheme: dark;  /* prevents browser light-mode defaults in PWA/standalone mode */
    --image-size: 80px;
    --user-color:  #ffffff;
    --user-border: #ffffff;

    /* Palette */
    --bg:         #18181b;
    --surface-1:  #232327;
    --surface-2:  #2c2c31;
    --border:     #38383e;
    --border-hi:  #52525a;

    --purple:     #a29bfe;
    --purple-dim: rgba(162, 155, 254, 0.15);
    --white:      #ffffff;
    --text:       #f2f2f5;
    --text-muted: #8e8e95;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;

    --transition: 0.2s ease;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg);
    color: var(--user-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    width: 100%;
    /* Allow custom text color */
    color: var(--user-color);
}

.menu-btn, .difficulty-btn, .daily-btn, .sidebar-btn,
input, .stat-number, .stat-label {
    color: var(--user-color) !important;
}

.menu-btn, .difficulty-btn, .sidebar-btn, input, .search-container {
    border-color: var(--user-border) !important;
}

/* =============================================================
   TYPOGRAPHY
   ============================================================= */
h1 {
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- MAIN MENU HERO --- */
.main-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    animation: fadeIn 0.7s ease-out;
}

.main-eyebrow {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--purple);
    margin: 0 0 10px 0;
}

.main-title {

    font-size: 56px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--white);
    padding-top: 40px;
    padding-bottom: 12px;
    margin: 0 0 12px 0;
    text-transform: uppercase;
}

.main-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin: 0;
    font-weight: 400;
}

/* --- SCREEN BANNERS --- */
.screen-banner {
    width: 100%;
    max-width: 580px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 8px;
}

.screen-banner:empty { display: none; }

.screen-banner img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
}

/* Tighten title top-padding when a banner sits directly above it in .main-hero */
.main-hero .screen-banner:not(:empty) + .main-title {
    padding-top: 16px;
}

/* Banners outside .main-hero (after a back button) get a little breathing room */
.screen > .screen-banner {
    margin-top: 8px;
    margin-bottom: 16px;
}

/* --- BUTTON GROUP LABEL --- */
.btn-group-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 4px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

/* =============================================================
   LAYOUT
   ============================================================= */
.screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Visually hidden but readable by screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes screenFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
/* Fade-in whenever a screen transitions from d-none to visible */
.screen:not(.d-none) { animation: screenFadeIn 0.2s ease; }
body.reduced-motion .screen:not(.d-none) { animation: none; }
@media (prefers-reduced-motion: reduce) {
    .screen:not(.d-none) { animation: none; }
}

.custom-hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.scrollable-screen {
    justify-content: flex-start;
    overflow-y: auto;
    padding-top: 80px;
    padding-bottom: 50px;
}

.title-md { font-size: 38px; font-weight: 700; }

/* =============================================================
   FIXED UI ELEMENTS
   (profile-display is defined in profile.css — single source)
   ============================================================= */

#version-display {
    position: fixed;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(15px, env(safe-area-inset-left));
    color: rgba(255, 255, 255, 0.25);
    font-size: 11px;
    font-family: inherit;
    z-index: 1000;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    letter-spacing: 0.5px;
}

/* =============================================================
   DATE / COUNTDOWN
   ============================================================= */
.date-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 12px;
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
    cursor: help;
}

.date-container:hover .timer-tooltip { visibility: visible; opacity: 1; }

.timer-tooltip {
    visibility: hidden;
    width: 160px;
    background-color: var(--surface-2);
    color: var(--text);
    text-align: center;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 130%;
    left: 50%;
    margin-left: -80px;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border-hi);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    text-transform: none;
    letter-spacing: 0;
}

.timer-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--border-hi) transparent transparent transparent;
}

/* =============================================================
   KEYBOARD NAVIGATION
   ============================================================= */
.keyboard-selected {
    border-color: var(--white) !important;
    transform: scale(1.03) !important;
    outline: none;
}

/* =============================================================
   CALENDAR LEGEND
   ============================================================= */
/* calendar-legend and cal-legend-dot defined in components.css */

/* =============================================================
   LEFT OR RIGHT
   ============================================================= */
.lor-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
    width: 100%;
    max-width: 900px;
}

.lor-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lor-card:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 30px rgba(162, 155, 254, 0.2);
    border-color: var(--purple);
}

.lor-card img {
    width: 100%;
    height: 380px;
    object-fit: cover;
    border-radius: var(--radius-md);
    pointer-events: none;
}

.lor-name {
    margin-top: 12px;
    font-size: 20px;
    font-weight: 700;
    color: var(--white);
    text-align: center;
}

.lor-vs {
    font-size: 36px;
    font-weight: 800;
    color: var(--purple);
}

/* =============================================================
   LOADING SCREEN
   ============================================================= */
#loading-screen {
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.loading-logo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-md);
    opacity: 0.9;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.loading-text {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.dyk-box {
    margin-top: 24px;
    padding: 14px 20px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-width: 360px;
    text-align: center;
}

.dyk-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--purple);
    margin-bottom: 6px;
}

.dyk-text {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    margin: 0;
    transition: opacity 0.3s ease;
}

/* =============================================================
   MODEL OF THE DAY
   Mirrors the calendar: position: absolute; right: 0; same width.
   ============================================================= */
.motd-card {
    position: absolute;
    right: 0;
    top: 0;
    width: 340px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.motd-inner { padding: 16px 20px; }

.motd-eyebrow {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 10px;
}

.motd-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.motd-img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    object-position: top;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition);
    display: block;
}
.motd-img:hover { transform: scale(1.02); }

.motd-name-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.motd-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--white);
    margin: 0;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.motd-category {
    font-size: 10px;
    font-weight: 600;
    color: var(--purple);
    background: var(--purple-dim);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.motd-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0;
}

.motd-meta span {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px 8px;
}

.motd-play-btn { width: 100%; font-size: 13px; padding: 7px 12px; }

/* On mobile the gamemode-layout collapses to column, so flow the card normally */
@media (max-width: 1000px) {
    .motd-card {
        position: relative;
        right: auto;
        width: 100%;
        max-width: 640px;
    }
    .motd-body     { flex-direction: row; gap: 14px; align-items: flex-start; }
    .motd-img      { width: 90px; height: 120px; flex-shrink: 0; }
    .motd-name-row { flex-direction: column; gap: 4px; align-items: flex-start; }
    .motd-play-btn { width: auto; }
}

/* =============================================================
   ANIMATIONS
   ============================================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 768px) {
    .lor-container { flex-direction: column; gap: 20px; }
    .lor-vs { transform: rotate(90deg); }
    .lor-card { width: 250px; }
    .lor-card img { height: 300px; }
}

/* =============================================================
   PAGE-LEVEL HELPERS (moved from HTML inline styles)
   ============================================================= */
.page-title-large { font-size: 40px; padding-top: 0; }
.rules-footer     { color: var(--text-muted); font-size: 13px; letter-spacing: 1px; padding-top: 12px; }
.clue-intro-text  { color: var(--text-muted); margin-bottom: 16px; }
.settings-intro   { margin-bottom: 14px; }
.shortcuts-note   { margin-bottom: 12px; }
.credits-info-box { background: #222; border-radius: var(--radius-md); border: 1px solid #444; }

/* =============================================================
   MODEL OF THE WEEK
   Spotlight card on the main menu. Two-column layout at desktop:
   big photo on the left, stats + CTA on the right.
   ============================================================= */

.motw-card {
    width: 100%;
    max-width: 640px;
    margin: 28px auto 0;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.motw-inner { padding: 18px 20px; }

.motw-eyebrow {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: 14px;
}

/* Two-column layout at ≥ 480 px */
.motw-layout {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.motw-img {
    width: 140px;
    height: 190px;
    object-fit: cover;
    object-position: top;
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition);
    display: block;
}
.motw-img:hover { transform: scale(1.02); }

.motw-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.motw-name-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.motw-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.motw-category {
    font-size: 10px;
    font-weight: 600;
    color: var(--purple);
    background: var(--purple-dim);
    border-radius: 20px;
    padding: 2px 9px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* 2×2 stat tiles */
.motw-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.motw-stat {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.motw-stat-lbl {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--purple);
    font-weight: 700;
}

.motw-stat-val {
    font-size: 12px;
    color: var(--white);
    font-weight: 600;
}

/* XP reward badge */
.motw-xp-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--white);
    background: var(--purple-dim);
    border: 1px solid var(--purple);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.motw-xp-badge.motw-xp-claimed {
    background: rgba(40, 168, 29, 0.12);
    border-color: rgba(40, 168, 29, 0.4);
    color: #6fcf6b;
}

.motw-play-btn {
    width: 100%;
    font-size: 13px;
    padding: 9px 14px;
}

.motw-countdown {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
}

/* Stack to one column on very small screens */
@media (max-width: 420px) {
    .motw-layout { flex-direction: column; }
    .motw-img    { width: 100%; height: 220px; }
}

/* =============================================================
   SPOTLIGHT CARD TABS  (Day / Week switcher)
   ============================================================= */

.spotlight-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.spotlight-tab {
    flex: 1;
    padding: 9px 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
    margin-bottom: -1px; /* sit on top of the container border */
}

.spotlight-tab:hover:not(.active) {
    color: var(--white);
    background: var(--surface-2);
}

.spotlight-tab.active {
    color: var(--white);
    border-bottom-color: var(--purple);
}

/* XP row inside the MOTW panel (reuses motd-body gap spacing) */
.motw-xp-row {
    font-size: 11px;
    font-weight: 600;
    color: var(--white);
    background: var(--purple-dim);
    border: 1px solid var(--purple);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    text-align: center;
}

.motw-xp-row.motw-xp-claimed {
    background: rgba(40, 168, 29, 0.12);
    border-color: rgba(40, 168, 29, 0.4);
    color: #6fcf6b;
}

.motw-countdown {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
}
