/* Crossword Puzzle - Children's Century Classics */
:root {
    --cell: 38px;
    --blue: #0C476F;
    --red: #B9251A;
    --orange: #fc650a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #ededed;
    color: #222;
}

#wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px;
    background: #fff;
    min-height: 100vh;
}

/* Top bar */
#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0 16px;
}

#gametitle {
    color: var(--blue);
    font-size: 22px;
    margin: 0;
}

#controls { display: flex; align-items: center; gap: 8px; }

#time {
    font-variant-numeric: tabular-nums;
    font-weight: bold;
    color: var(--blue);
    background: #eef4f9;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 15px;
}

.btn {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover { background: #0a3a5c; }
#btnCheck { background: var(--orange); }
#btnCheck:hover { background: #e35709; }

/* Board */
#boardWrap {
    position: relative;
    overflow-x: auto;
    padding: 4px;
}

#board {
    display: grid;
    gap: 2px;
    width: max-content;
    margin: 0 auto;
    background: #d7dde3;
    padding: 8px;
    border-radius: 6px;
}

.cell {
    width: var(--cell);
    height: var(--cell);
    position: relative;
    background: #fff;
    border: 1px solid #b9c2cb;
    border-radius: 3px;
}

.cell.block { background: #3a4a57; border-color: #3a4a57; }

.cell .num {
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: calc(var(--cell) * 0.28);
    line-height: 1.1;
    color: #4a5b68;
    pointer-events: none;
    font-weight: 600;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    text-transform: uppercase;
    font-size: calc(var(--cell) * 0.55);
    font-weight: 600;
    color: #14324c;
    outline: none;
    padding: 0;
    caret-color: var(--red);
    font-family: inherit;
}

.cell.activeWord { background: #dceaf5; border-color: #7fa8c9; }
.cell.activeCell { background: #ffd9a8; border-color: var(--orange); }
.cell input.wrong { color: #c62828; }
.cell input.revealed { color: var(--orange); }

#boardWrap.paused #board { filter: blur(3px); }

#boardWrap.paused::after {
    content: 'PAUSED';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    color: var(--blue);
    background: rgba(237, 237, 237, 0.88);
    letter-spacing: 4px;
}

/* Clues */
#clueArea {
    display: flex;
    gap: 20px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.clueCol { flex: 1 1 260px; min-width: 220px; }

.clueCol h3 {
    color: var(--red);
    font-size: 16px;
    margin: 0 0 6px;
    border-bottom: 2px solid var(--red);
    padding-bottom: 3px;
}

ul.clues { list-style: none; margin: 0; padding: 0; }

ul.clues li {
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.35;
}

ul.clues li:hover { background: #eef4f9; }
ul.clues li.active { background: #dceaf5; }
.clueNum { font-weight: bold; color: var(--blue); margin-right: 2px; }

/* Messages */
.message {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
}

.message.win { background: #2e7d32; color: #fff; }
.message.error { background: #fdecea; color: #b71c1c; }
.hidden { display: none !important; }

/* Start / error overlay */
.homeScreen {
    position: fixed;
    inset: 0;
    background: rgba(12, 71, 111, 0.93);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.homeInner { text-align: center; color: #fff; padding: 20px; max-width: 90%; }
.homeInner h2 { margin: 0 0 24px; font-size: 26px; }
.playBtn { background: var(--orange); font-size: 18px; padding: 12px 42px; }
.playBtn:hover { background: #e35709; }

#errorMsg { margin-top: 14px; font-size: 15px; color: #ffd9a8; }

@media (max-width: 600px) {
    #wrapper { padding: 8px; }
    #gametitle { font-size: 18px; }
    .btn { padding: 6px 12px; font-size: 13px; }
}
