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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f0f0f0;
    color: #111;
    min-height: 100vh;
}

.app {
    max-width: 1300px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── Header ── */
header {
    margin-bottom: 24px;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 14px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

select,
input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9rem;
    background: white;
    color: #111;
    height: 36px;
}

input[type="number"] {
    width: 140px;
}

button {
    padding: 8px 18px;
    height: 36px;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: #2a4d8f;
    color: white;
    transition: background 0.15s;
}

button:hover {
    background: #1d3870;
}

button.secondary {
    background: #666;
}

button.secondary:hover {
    background: #444;
}

.seed-info {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #777;
    font-family: monospace;
}

/* ── Status / Error ── */
#status-bar {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
}

#status-bar.loading {
    background: #e8f0fe;
    color: #1a4cc0;
}

#status-bar.error {
    background: #fde8e8;
    color: #b00020;
}

/* ── Main layout ── */
main {
    display: flex;
    gap: 36px;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* ── Grid ── */
#grid-wrapper {
    overflow-x: auto;
    flex-shrink: 0;
}

#crossword-grid {
    display: inline-grid;
    gap: 2px;
    background: #222;
    border: 3px solid #222;
    border-radius: 3px;
}

.cell {
    width: 40px;
    height: 40px;
    position: relative;
}

.cell-black {
    background: #1e1e1e;
}

.cell-letter {
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Clue hint area inside the first letter cell of each word */
.clue-hint {
    font-size: 6px;
    line-height: 1.25;
    color: #333;
    background: #dde3ee;
    padding: 1px 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    width: 100%;
    cursor: default;
}

.clue-hint.across::before {
    content: '→ ';
    font-weight: 700;
    color: #2a4d8f;
}

.clue-hint.down::before {
    content: '↓ ';
    font-weight: 700;
    color: #8f2a2a;
}

/* Letter display area */
.letter-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Georgia', serif;
    color: #111;
    user-select: none;
}

/* ── Clues panel ── */
#clues-panel {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 220px;
}

#clues-panel section {
    min-width: 180px;
}

#clues-panel h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    border-bottom: 2px solid #ddd;
    padding-bottom: 6px;
    margin-bottom: 10px;
}

#clues-across,
#clues-down {
    list-style: none;
}

#clues-across li,
#clues-down li {
    font-size: 0.82rem;
    line-height: 1.7;
    color: #333;
}

#clues-across li span,
#clues-down li span {
    font-weight: 700;
    color: #111;
    margin-right: 4px;
}

/* ── Utilities ── */
.hidden {
    display: none !important;
}
