/* CAD Offsite v2 - Player Styles (Material Design 3 - Mobile First) */

/* 1. Base Tokens */
:root {
    /* MD3 Dark Theme Tokens */
    --md-sys-color-background: #111318;
    --md-sys-color-on-background: #e2e2e9;
    --md-sys-color-surface: #111318;
    --md-sys-color-surface-container: #1d2024;
    --md-sys-color-surface-container-high: #282a2f;
    --md-sys-color-on-surface: #e2e2e9;
    --md-sys-color-on-surface-variant: #c4c6d0;

    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #284777;
    --md-sys-color-on-primary-container: #d6e3ff;

    --md-sys-color-secondary: #bfc6dc;
    --md-sys-color-on-secondary: #293041;
    --md-sys-color-secondary-container: #3f4759;
    --md-sys-color-on-secondary-container: #dbe2f9;

    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;

    /* Custom Game Tokens */
    --game-factual: #ffb4ab;
    --game-hallucination: #d0bcff;
    --game-bias: #ffb1c8;
    --game-success: #81c995;

    /* Shape & Elevation */
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-full: 100px;
}

/* 2. Reset & Basics */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100dvh;
    /* use dvh for mobile browser URL bars */
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: text-bottom;
}

/* 3. Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 24px;
    /* Will be adjusted by JS dynamically for sticky bar */
    flex: 1;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex: 1;
    flex-direction: column;
}

.view.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 4. Material Components */

/* Cards (Surface Container) */
.md-card {
    background-color: var(--md-sys-color-surface-container);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 24px;
    margin-bottom: 16px;
    width: 100%;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
}

.card-center {
    text-align: center;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--md-sys-color-on-surface);
}

.card-title .material-symbols-outlined {
    color: var(--md-sys-color-primary);
}

/* Text Fields (Filled Variant MD3) */
.md-text-field {
    position: relative;
    width: 100%;
    margin-bottom: 24px;
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: 4px 4px 0 0;
    border-bottom: 1px solid var(--md-sys-color-on-surface-variant);
}

.md-text-field input {
    width: 100%;
    padding: 24px 16px 8px;
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

.md-text-field input:focus {
    outline: none;
    border-bottom: 2px solid var(--md-sys-color-primary);
    padding-bottom: 7px;
    /* adjust for thicker border */
}

.md-text-field label {
    position: absolute;
    left: 16px;
    top: 16px;
    font-size: 1rem;
    color: var(--md-sys-color-on-surface-variant);
    transition: all 0.2s ease;
    pointer-events: none;
}

.md-text-field input:focus+label,
.md-text-field input:not(:placeholder-shown)+label {
    top: 8px;
    font-size: 0.75rem;
    color: var(--md-sys-color-primary);
}

/* Buttons (Pill shaped) */
.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    /* Safe mobile touch target */
    padding: 0 24px;
    border-radius: var(--md-sys-shape-corner-full);
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    width: 100%;
    /* Default to full width on mobile */
    max-width: 400px;
}

.md-btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.md-btn-filled:active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    background-color: #92b1e2;
}

.md-btn-tonal {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

/* 5. Sticky Bottom Action Bar */
.bottom-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background-color: var(--md-sys-color-surface);
    border-top: 1px solid var(--md-sys-color-surface-container-high);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 100;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.2);
    /* Safe area padding for iOS */
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.game-bottom-bar {
    justify-content: space-between;
}

.game-bottom-bar .md-btn {
    width: auto;
    flex-shrink: 0;
}

.split-actions {
    flex-direction: row;
}

.split-actions .md-btn {
    flex: 1;
}

/* 6. Specific View Styles */

/* Hero */
.hero {
    text-align: center;
    padding: 24px 16px 8px;
    margin-bottom: 24px;
}

.hero-icon .icon-display {
    font-size: 4rem;
    color: var(--md-sys-color-primary);
    margin-bottom: 8px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--md-sys-color-on-surface);
}

.subtitle {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 1rem;
    margin-top: 8px;
}

/* Game Header (Top App Bar style) */
.game-top-app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin: -16px -16px 16px -16px;
    background-color: var(--md-sys-color-surface-container);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--md-sys-color-surface-container-high);
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.md-badge {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
    align-self: flex-start;
}

.team-name {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
}

.timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--game-success);
    font-variant-numeric: tabular-nums;
}

.timer.urgent {
    color: var(--game-factual);
}

.timer.critical {
    color: var(--md-sys-color-error);
    animation: flash 1s infinite alternate;
}

@keyframes flash {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.5;
    }
}

/* Game Area */
.game-instructions p {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-instructions strong {
    color: var(--md-sys-color-primary);
}

.word-display {
    font-size: 1rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    word-break: break-word;
}

.word-para {
    margin-bottom: 1em;
    line-height: 2;
    overflow-wrap: break-word;
    word-break: break-word;
    -webkit-hyphens: none;
    hyphens: none;
}

.word-para:last-child {
    margin-bottom: 0;
}

.word {
    display: inline;
    font-size: 1rem;
    padding: 1px 2px;
    margin: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.word:hover {
    background-color: rgba(255, 255, 255, 0.07);
}

.word:active {
    background-color: rgba(255, 255, 255, 0.1);
}

.word.selected {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 500;
}

/* Reviews */
.word.review-tp {
    background-color: rgba(129, 201, 149, 0.2);
    border-bottom: 2px solid var(--game-success);
}

.word.review-fp {
    background-color: rgba(255, 180, 171, 0.2);
    border-bottom: 2px solid var(--md-sys-color-error);
}

.word.review-fn {
    background-color: rgba(255, 180, 171, 0.2);
    border-bottom: 2px dashed var(--md-sys-color-error);
    opacity: 0.8;
}

.review-display {
    pointer-events: none;
}

/* Status */
.selection-status {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Results & Stats */
.score-display {
    margin: 24px 0;
}

.score-big {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--md-sys-color-primary);
}

.score-big.negative {
    color: var(--md-sys-color-error);
}

.score-label {
    font-size: 0.875rem;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

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

.stat-item {
    background-color: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 16px 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Category Chips */
.category-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-surface-container-highest);
}

.cat-chip.factual {
    color: var(--game-factual);
}

.cat-chip.hallucination {
    color: var(--game-hallucination);
}

.cat-chip.bias {
    color: var(--game-bias);
}

.cat-chip .material-symbols-outlined {
    font-size: 14px;
}

/* Links */
.nav-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 16px;
    margin-bottom: 16px;
}

.nav-links a {
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
}

.error-text {
    color: var(--md-sys-color-error);
    text-align: center;
    margin: 8px 0;
    font-size: 0.875rem;
}

.final-accuracy {
    font-size: 1.25rem;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 24px;
}

/* Tablet / Desktop Overrides */
@media (min-width: 600px) {
    .app-container {
        padding: 40px 24px;
        align-items: center;
        /* Center the view horizontally */
        justify-content: center;
    }

    .view {
        flex: 0 1 auto;
        max-width: 640px;
        width: 100%;
        background-color: var(--md-sys-color-surface-container);
        border-radius: var(--md-sys-shape-corner-extra-large);
        padding: 32px;
        box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.05);
        margin: 0 auto;
    }

    /* Lessen double-card effect inside the view */
    .md-card {
        background-color: transparent;
        box-shadow: none;
        padding: 16px 0;
        margin-bottom: 0;
    }

    /* Keep the input field background */
    .md-text-field {
        background-color: var(--md-sys-color-surface-container-high);
    }

    .bottom-action-bar {
        position: static;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 24px 0 0 0;
        margin-top: 16px;
    }

    .md-btn {
        width: auto;
        min-width: unset;
        padding: 0 32px;
    }

    .split-actions {
        justify-content: center;
        gap: 16px;
    }

    .split-actions .md-btn {
        flex: unset;
    }

    .game-bottom-bar {
        justify-content: space-between;
    }

    /* Adjust game-top-app-bar to fit within the padded view */
    .game-top-app-bar {
        margin: -32px -32px 16px -32px;
        padding: 24px 32px;
        border-radius: var(--md-sys-shape-corner-extra-large) var(--md-sys-shape-corner-extra-large) 0 0;
        background-color: var(--md-sys-color-surface-container-high);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    /* Make word display slightly larger on desktop */
    .word-display {
        font-size: 1.0625rem;
    }
}