/* ========================================
   Dailies — Design System
   Black bg, white text, bordered cards
   ======================================== */

:root {
    --bg: #000000;
    --bg-raised: #0a0a0a;
    --fg: #ffffff;
    --fg-muted: #777777;
    --border: #2a2a2a;
    --border-hover: #444444;
    --radius: 8px;
    --radius-sm: 6px;
    --completed: #538d4e;
    --completed-muted: rgba(83, 141, 78, 0.15);
    --danger: #e74c3c;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', monospace;
}

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

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    max-width: 940px;
    margin: 0 auto;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

#date-display {
    color: var(--fg-muted);
    font-size: 13px;
}

#progress {
    color: var(--fg-muted);
    font-size: 13px;
    font-family: var(--font-mono);
}

/* ---- Buttons ---- */

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.03);
}

.btn-primary {
    background: var(--fg);
    color: var(--bg);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.15s;
    font-family: inherit;
}

.btn-primary:hover {
    opacity: 0.9;
}

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

.btn-small {
    font-size: 12px;
    padding: 4px 10px;
    border: none;
    color: var(--fg-muted);
}

/* ---- Games Grid ---- */

#games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 8px 24px 40px;
    max-width: 940px;
    margin: 0 auto;
}

@media (max-width: 480px) {
    header { padding: 14px 16px; }
    #games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 8px 16px 32px;
    }
    .header-right { gap: 8px; }
    #date-display { display: none; }
}

@media (min-width: 481px) and (max-width: 768px) {
    #games-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ---- Game Card ---- */

.game-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    text-decoration: none;
    color: var(--fg);
    user-select: none;
    -webkit-user-select: none;
}

.game-card:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.02);
}

.game-card.completed {
    border-color: var(--completed);
    background: var(--completed-muted);
}

.game-card .icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    image-rendering: auto;
}

.game-card .icon-fallback {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--fg);
}

.game-card .name {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* Completion toggle (top-right circle) */
.game-card .toggle {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}

.game-card .toggle:hover {
    border-color: var(--fg-muted);
}

.game-card.completed .toggle {
    border-color: var(--completed);
    background: var(--completed);
    color: #fff;
}

/* ---- Modals ---- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-small {
    max-width: 360px;
}

.modal-medium {
    max-width: 480px;
}

.modal-large {
    max-width: 90vw;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    border: none;
    font-size: 16px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

/* ---- Auth Modal ---- */

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#auth-form input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

#auth-form input:focus {
    border-color: var(--fg-muted);
}

#auth-form input::placeholder {
    color: var(--fg-muted);
}

#auth-toggle {
    margin-top: 8px;
    display: block;
    width: 100%;
    text-align: center;
}

.error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

/* ---- Iframe ---- */

#game-iframe {
    width: 100%;
    height: calc(90vh - 2px);
    border: none;
    border-radius: var(--radius);
}

/* ---- Stats ---- */

.stats-section {
    margin-bottom: 24px;
}

.stats-section:last-child {
    margin-bottom: 0;
}

.stats-section h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.stats-row:last-child {
    border-bottom: none;
}

.stats-row .label {
    color: var(--fg);
}

.stats-row .value {
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 13px;
}

.stats-row .value.highlight {
    color: var(--completed);
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    text-align: center;
    padding: 16px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--fg-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Utilities ---- */

.hidden { display: none !important; }

.muted { color: var(--fg-muted); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
