/* PuzzleLore — Dark Fantasy Theme */

:root {
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-surface: #16213e;
    --text-primary: #e8e6e3;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --accent-gold: #d4a853;
    --accent-gold-dim: #a08030;
    --accent-teal: #3aa89f;
    --cell-positive: #2ecc71;
    --cell-negative: #e74c3c;
    --cell-blank: #252540;
    --cell-disabled: transparent;
    --border-grid: #3a3a5a;
    --border-thick: #555580;
    --tier-1-bg: #1a3a2a;
    --tier-1-text: #6fcf97;
    --tier-2-bg: #3a351a;
    --tier-2-text: #f2c94c;
    --tier-3-bg: #3a1a1a;
    --tier-3-text: #eb5757;
    --font-body: 'Georgia', 'Times New Roman', serif;
    --font-heading: 'Georgia', serif;
    --font-mono: 'Courier New', monospace;
}

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

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
#site-header {
    background: linear-gradient(180deg, #0a0a15 0%, var(--bg-dark) 100%);
    border-bottom: 1px solid var(--accent-gold-dim);
    padding: 1.5rem 1rem;
    text-align: center;
}

.header-inner { max-width: 800px; margin: 0 auto; }

.logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent-gold);
    text-decoration: none;
    letter-spacing: 0.1em;
    font-weight: normal;
}

.tagline {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Main */
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* Wider layout when puzzle is active */
#view-puzzle { max-width: 1100px; }

/* Views */
.view { display: block; }
.hidden { display: none !important; }

/* Hero */
.hero {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
}

.hero h1 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
    font-weight: normal;
}

.hero p { color: var(--text-secondary); max-width: 500px; margin: 0 auto; }

/* Pack Gallery */
.pack-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pack-card {
    background: var(--bg-card);
    border: 1px solid var(--border-grid);
    border-radius: 8px;
    padding: 1.5rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.pack-card:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.pack-card h2 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: normal;
}

.pack-card p { color: var(--text-secondary); font-size: 0.9rem; }

.pack-card .pack-meta {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Back Link */
.back-link {
    color: var(--accent-gold-dim);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 1.5rem;
}

.back-link:hover { color: var(--accent-gold); }

/* Pack Header */
.pack-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-grid);
}

.pack-header h1 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.6rem;
    font-weight: normal;
}

.pack-header p { color: var(--text-secondary); margin-top: 0.5rem; }

/* Puzzle List */
.puzzle-list { display: flex; flex-direction: column; gap: 0.75rem; }

.puzzle-list-item {
    background: var(--bg-card);
    border: 1px solid var(--border-grid);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.2s;
}

.puzzle-list-item:hover { border-color: var(--accent-gold); }

.puzzle-number {
    color: var(--accent-gold-dim);
    font-size: 1.4rem;
    font-family: var(--font-mono);
    min-width: 2rem;
    text-align: center;
}

.puzzle-list-item .title { color: var(--text-primary); }
.puzzle-list-item .status { margin-left: auto; font-size: 1.2rem; }
.puzzle-list-item .status.solved { color: var(--cell-positive); }

/* Puzzle Header */
.puzzle-header h1 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1.4rem;
    font-weight: normal;
}

/* Flavor Text */
.puzzle-flavor {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent-gold-dim);
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Item Reference Cards */
.item-reference { margin-bottom: 1.5rem; }

.item-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.item-ref-card {
    background: var(--bg-card);
    border: 1px solid var(--border-grid);
    border-radius: 6px;
    padding: 1rem;
}

.item-ref-card h3 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    font-weight: normal;
}

.item-ref-card ul {
    list-style: none;
    font-size: 0.85rem;
    line-height: 1.6;
}

.item-ref-card li { padding: 2px 0; }
.item-ref-card strong { color: var(--text-primary); }
.item-traits { color: var(--text-muted); font-style: italic; }

/* Puzzle Layout */
.puzzle-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Grid Container */
.grid-container {
    overflow-x: visible;
}

.logic-grid {
    border-collapse: collapse;
    margin: 0 auto;
    user-select: none;
    overflow: visible;
}

.logic-grid th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: normal;
    padding: 6px 10px;
    text-align: center;
    white-space: nowrap;
}

.logic-grid th.col-label {
    height: 130px;
    white-space: nowrap;
    vertical-align: bottom;
    padding: 0 2px 6px 2px;
    text-align: center;
}

.logic-grid th.col-label > span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.8rem;
    white-space: nowrap;
    display: inline-block;
}

.logic-grid th.cat-header {
    background: var(--bg-card);
    color: var(--accent-gold);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.logic-grid th.cat-header-col {
    background: var(--bg-card);
    color: var(--accent-gold);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    height: auto;
    padding: 4px 6px;
}

.logic-grid th.row-label {
    text-align: right;
    padding-right: 10px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.logic-grid td {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid var(--border-grid);
    cursor: pointer;
    font-size: 1.1rem;
    transition: background-color 0.1s;
}

.logic-grid td.cell-blank {
    background: var(--cell-blank);
}

.logic-grid td.cell-blank:hover {
    background: #303055;
}

.logic-grid td.cell-positive {
    background: #1a4a2a;
    color: var(--cell-positive);
    font-weight: bold;
}

.logic-grid td.cell-negative {
    background: #3a1a1a;
    color: var(--cell-negative);
    font-size: 0.8rem;
}

.logic-grid td.cell-disabled {
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.logic-grid .thick-border-right { border-right: 2px solid var(--border-thick); }
.logic-grid .thick-border-bottom { border-bottom: 2px solid var(--border-thick); }

/* Clue Panel */
.clue-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-grid);
    border-radius: 6px;
    padding: 1.25rem;
}

.clue-panel h2 {
    font-family: var(--font-heading);
    color: var(--accent-gold);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: normal;
}

.clue-list { list-style: none; }

.clue-item {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-grid);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    font-size: 0.9rem;
    line-height: 1.5;
}

.clue-item:last-child { border-bottom: none; }

.clue-number {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    min-width: 1.5rem;
    padding-top: 2px;
}

.clue-text { color: var(--text-primary); }

.tier-badge {
    display: inline-block;
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 0.5rem;
    vertical-align: middle;
    font-family: var(--font-mono);
}

.tier-1 { background: var(--tier-1-bg); color: var(--tier-1-text); }
.tier-2 { background: var(--tier-2-bg); color: var(--tier-2-text); }
.tier-3 { background: var(--tier-3-bg); color: var(--tier-3-text); }

/* Buttons */
.puzzle-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.6rem 1.25rem;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-gold);
    color: var(--bg-dark);
    border-color: var(--accent-gold);
}

.btn-primary:hover { background: #e0b660; }

.btn-secondary {
    background: transparent;
    color: var(--accent-gold);
    border-color: var(--accent-gold-dim);
}

.btn-secondary:hover { background: rgba(212, 168, 83, 0.1); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-grid);
}

.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* Puzzle Result */
.puzzle-result {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 6px;
    text-align: center;
    font-size: 1.1rem;
}

.puzzle-result.correct {
    background: var(--tier-1-bg);
    color: var(--cell-positive);
    border: 1px solid var(--cell-positive);
}

.puzzle-result.incorrect {
    background: var(--tier-3-bg);
    color: var(--cell-negative);
    border: 1px solid var(--cell-negative);
}

.puzzle-result.revealed {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-grid);
    text-align: left;
    font-size: 0.9rem;
}

/* Puzzle Navigation */
.puzzle-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-grid);
}

.puzzle-progress {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-grid);
    margin-top: 3rem;
}

/* Responsive */
@media (max-width: 600px) {
    .logo { font-size: 1.5rem; }
    .hero h1 { font-size: 1.4rem; }
    main { padding: 1rem 0.75rem; }

    .logic-grid td {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        font-size: 1rem;
    }

    .logic-grid th {
        font-size: 0.75rem;
        padding: 4px 6px;
    }

    .puzzle-actions { flex-direction: column; }
    .btn { width: 100%; text-align: center; }
}
