/* Uff Da - A cozy, small-town newspaper aesthetic */
/* Mobile-first responsive design */

:root {
    --cream: #FDF6E3;
    --cream-dark: #F5EFDC;
    --brown: #5C4033;
    --brown-light: #8B7355;
    --maroon: #722F37;
    --maroon-light: #9B4F57;
    --forest: #2D5A3D;
    --gold: #C9A227;
    --gold-muted: #B8956E;
    --ink: #2C2416;
    --ink-light: #4A4035;
    --paper-shadow: rgba(92, 64, 51, 0.1);
    
    --font-display: 'Libre Baskerville', Georgia, serif;
    --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
    
    /* Grid cell sizes - responsive */
    --cell-size: 34px;
    --header-width: 130px;
    --col-header-height: 110px;
}

@media (min-width: 600px) {
    :root {
        --cell-size: 40px;
        --header-width: 160px;
        --col-header-height: 130px;
    }
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 28px,
            rgba(92, 64, 51, 0.03) 28px,
            rgba(92, 64, 51, 0.03) 29px
        ),
        linear-gradient(180deg, var(--cream) 0%, var(--cream-dark) 100%);
    background-attachment: fixed;
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 12px;
}

@media (min-width: 600px) {
    .container {
        padding: 20px;
    }
}

/* Header / Masthead */
header {
    text-align: center;
    padding: 20px 12px;
    border-bottom: 3px double var(--brown);
    margin-bottom: 20px;
}

@media (min-width: 600px) {
    header {
        padding: 30px 20px;
        margin-bottom: 30px;
    }
}

.masthead {
    position: relative;
}

.edition {
    font-family: var(--font-body);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--brown-light);
    margin-bottom: 8px;
}

@media (min-width: 600px) {
    .edition {
        font-size: 12px;
        letter-spacing: 3px;
    }
}

h1 {
    font-family: var(--font-display);
    font-size: clamp(28px, 8vw, 56px);
    font-weight: 700;
    color: var(--maroon);
    letter-spacing: -1px;
    text-shadow: 2px 2px 0 rgba(92, 64, 51, 0.1);
}

.tagline {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 14px;
    color: var(--brown-light);
    margin-top: 6px;
}

@media (min-width: 600px) {
    .tagline {
        font-size: 16px;
        margin-top: 8px;
    }
}

/* Sections */
section {
    background: white;
    border: 1px solid var(--cream-dark);
    box-shadow: 
        0 2px 4px var(--paper-shadow),
        0 4px 8px var(--paper-shadow);
    padding: 12px;
    margin-bottom: 12px;
    position: relative;
}

@media (min-width: 600px) {
    section {
        padding: 24px;
        margin-bottom: 20px;
    }
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--maroon), var(--gold-muted), var(--maroon));
}

h2 {
    font-family: var(--font-display);
    font-size: 17px;
    color: var(--maroon);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cream-dark);
}

@media (min-width: 600px) {
    h2 {
        font-size: 22px;
        margin-bottom: 16px;
        padding-bottom: 8px;
    }
}

h3 {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--brown);
    margin-bottom: 8px;
}

/* Incident Report */
.incident-report {
    background: linear-gradient(135deg, white 0%, var(--cream) 100%);
}

.incident-report p {
    font-family: var(--font-display);
    font-size: 16px;
    line-height: 1.7;
    color: var(--ink);
}

@media (min-width: 600px) {
    .incident-report p {
        font-size: 18px;
        line-height: 1.8;
    }
}

/* Categories Panel - horizontal scroll on mobile */
.categories-section {
    margin-bottom: 0;
}

.categories-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.categories-scroll::-webkit-scrollbar {
    height: 4px;
}

.categories-scroll::-webkit-scrollbar-track {
    background: var(--cream);
    border-radius: 2px;
}

.categories-scroll::-webkit-scrollbar-thumb {
    background: var(--brown-light);
    border-radius: 2px;
}

@media (min-width: 700px) {
    .categories-scroll {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        overflow-x: visible;
    }
    
    .scroll-hint {
        display: none;
    }
}

.scroll-hint {
    text-align: center;
    font-size: 12px;
    color: var(--brown-light);
    padding: 6px 0 0 0;
}

.category {
    flex: 0 0 auto;
    min-width: 160px;
    scroll-snap-align: start;
    padding: 12px;
    background: var(--cream);
    border-radius: 4px;
}

.category h3 {
    font-size: 14px;
    margin-bottom: 8px;
}

.category ul {
    list-style: none;
}

.category li {
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px dotted var(--cream-dark);
}

.category li:last-child {
    border-bottom: none;
}

/* Clues Panel */
.clues-panel {
    background: linear-gradient(180deg, white 0%, #FFFEF8 100%);
}

.clue {
    position: relative;
    padding: 10px 10px 10px 32px;
    margin-bottom: 8px;
    background: var(--cream);
    border-left: 3px solid var(--gold-muted);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-light);
}

@media (min-width: 600px) {
    .clue {
        padding: 16px 20px 16px 44px;
        font-size: 15px;
        line-height: 1.7;
        margin-bottom: 10px;
    }
}

.clue:last-child {
    margin-bottom: 0;
}

.clue-number {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--maroon);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-style: normal;
    font-size: 10px;
    font-weight: 600;
}

@media (min-width: 600px) {
    .clue-number {
        left: 10px;
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}

/* ============================================
   LOGIC GRIDS - 3 INDEPENDENT TABLES
   ============================================ */

.logic-grid-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.grid-instructions {
    font-size: 12px;
    color: var(--brown-light);
    margin-bottom: 16px;
    text-align: center;
}

.grids-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.grids-top-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.grids-bottom-row {
    display: flex;
    justify-content: center;
}

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

.grid-title {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--maroon-light);
    margin-bottom: 6px;
}

.logic-table {
    border-collapse: collapse;
    border: 2px solid var(--brown);
}

.logic-table th,
.logic-table td {
    border: 1px solid var(--cream-dark);
    width: var(--cell-size);
    height: var(--cell-size);
    text-align: center;
    vertical-align: middle;
    font-size: 10px;
    padding: 0;
    user-select: none;
}

/* Interactive cells */
.logic-table td.cell {
    background: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.15s ease;
}

.logic-table td.cell:hover {
    background: var(--cream);
}

.logic-table td.cell:active {
    background: var(--cream-dark);
}

.logic-table td.cell.eliminated {
    background: #FFEAEA;
    color: var(--maroon);
}

.logic-table td.cell.confirmed {
    background: #EAFAEA;
    color: var(--forest);
}

/* Header cells */
.logic-table th {
    background: var(--cream);
    font-weight: 600;
    color: var(--brown);
    cursor: pointer;
    line-height: 1.1;
}

.logic-table th:hover {
    background: var(--cream-dark);
}

.logic-table th:active {
    background: #E8E0D0;
}

.logic-table th.crossed {
    background: #FFE0E0;
    text-decoration: line-through;
    color: var(--maroon-light);
}

/* Column headers (top) - rotated text */
.logic-table th.col-header {
    height: var(--col-header-height);
    width: var(--cell-size);
    vertical-align: bottom;
    padding: 4px 2px;
}

.logic-table th.col-header > div {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 11px;
    line-height: 1.2;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
}

/* Row headers (left side) */
.logic-table th.row-header {
    width: var(--header-width);
    min-width: var(--header-width);
    max-width: var(--header-width);
    text-align: right;
    vertical-align: middle;
    padding: 4px 8px 4px 4px;
    font-size: 11px;
    line-height: 1.2;
    white-space: normal;
    word-wrap: break-word;
}

/* Corner cells */
.logic-table th.corner {
    background: var(--brown-light);
    cursor: default;
    border: 1px solid var(--brown-light);
}

.logic-table th.corner:hover {
    background: var(--brown-light);
}

/* ============================================
   ACCUSATION FORM
   ============================================ */

.accusation-form {
    max-width: 400px;
    margin: 0 auto;
}

.accusation-row {
    margin-bottom: 14px;
}

.accusation-row label {
    display: block;
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--brown);
    margin-bottom: 6px;
}

.accusation-row select {
    width: 100%;
    padding: 12px;
    font-family: var(--font-body);
    font-size: 15px;
    border: 2px solid var(--cream-dark);
    border-radius: 4px;
    background: white;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235C4033' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.accusation-row select:focus {
    outline: none;
    border-color: var(--maroon);
}

.submit-btn {
    width: 100%;
    padding: 14px 24px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    background: var(--maroon);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.submit-btn:hover {
    background: var(--maroon-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--paper-shadow);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: var(--brown-light);
    cursor: not-allowed;
    transform: none;
}

/* Result Message */
.result-message {
    margin-top: 16px;
    padding: 16px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 15px;
    line-height: 1.6;
    border-radius: 4px;
    display: none;
}

.result-message.show {
    display: block;
}

.result-message.correct {
    background: #E5F5E5;
    border: 2px solid var(--forest);
    color: var(--forest);
}

.result-message.incorrect {
    background: #FFE5E5;
    border: 2px solid var(--maroon);
    color: var(--maroon);
}

/* Stats */
.stats-grid {
    display: flex;
    justify-content: space-around;
    text-align: center;
    flex-wrap: wrap;
    gap: 8px;
}

.stat {
    display: flex;
    flex-direction: column;
    min-width: 60px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--maroon);
}

@media (min-width: 600px) {
    .stat-value {
        font-size: 32px;
    }
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--brown-light);
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 12px;
    margin-top: 16px;
    border-top: 3px double var(--brown);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 13px;
    color: var(--brown-light);
}

@media (min-width: 600px) {
    footer {
        padding: 30px 20px;
        margin-top: 20px;
        font-size: 14px;
    }
}

/* Solved state */
body.solved .logic-grid-section,
body.solved .accusation-form {
    opacity: 0.6;
    pointer-events: none;
}

body.solved .submit-btn {
    display: none;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --cream: #1A1814;
        --cream-dark: #252019;
        --ink: #E8E4DC;
        --ink-light: #C5BFB3;
        --paper-shadow: rgba(0, 0, 0, 0.3);
    }
    
    section {
        background: #1F1B16;
    }
    
    .grid-cell {
        background: #2A2520;
    }
    
    .grid-cell.interactive:hover {
        background: #353025;
    }
    
    .grid-cell.eliminated {
        background: #3D2020;
    }
    
    .grid-cell.confirmed {
        background: #203D25;
    }
    
    .grid-cell.header,
    .grid-cell.corner,
    .grid-cell.empty {
        background: #252019;
    }
    
    .grid-cell.header:hover {
        background: #302A20;
    }
    
    .grid-cell.header.crossed {
        background: #3D2525;
    }
    
    .clue {
        background: #252019;
    }
    
    .category {
        background: #252019;
    }
    
    .accusation-row select {
        background: #2A2520;
        border-color: #353025;
        color: var(--ink);
    }
    
    .incident-report {
        background: linear-gradient(135deg, #1F1B16 0%, #252019 100%);
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    section {
        box-shadow: none;
        break-inside: avoid;
    }
    
    .submit-btn,
    .stats-section {
        display: none;
    }
}
