/* ============================================================
   Durian Word Search – style.css
   ============================================================ */
:root {
    --ink: #18311d;
    --ink-soft: rgba(24, 49, 29, 0.62);
    --card: rgba(255, 250, 240, 0.93);
    --line: rgba(24, 49, 29, 0.14);
    --green: #5f8128;
    --green-deep: #284b2d;
    --orange: #e8a03f;
    --correct: #2d7a2d;
    --wrong: #b83232;
}

/* ── Page layout ─────────────────────────────────────────── */
.game-page {
    width: min(1140px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
}
.layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
}

/* ── Game panel ──────────────────────────────────────────── */
.game-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    padding: 1.6rem;
    box-shadow: 0 20px 50px rgba(20, 54, 31, 0.13);
}
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.title-actions { display: flex; gap: 0.5rem; align-items: center; }
.eyebrow {
    display: inline-block; padding: 0.3rem 0.7rem; border-radius: 999px;
    background: rgba(92, 124, 31, 0.12); color: var(--green); font-size: 0.82rem;
    letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700;
}
h1 { margin: 0.5rem 0 0; font-size: clamp(1.6rem, 4vw, 2.4rem); color: var(--ink); line-height: 1.1; }
.lead { color: var(--ink-soft); line-height: 1.65; margin: 0.75rem 0 1rem; font-size: 0.98rem; }

/* ── HUD ─────────────────────────────────────────────────── */
.hud {
    display: flex; gap: 1rem; flex-wrap: wrap;
    padding: 0.6rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    margin-bottom: 1rem;
}
.hud-item { text-align: center; min-width: 60px; }
.hud-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.hud-item strong { font-size: 1.2rem; color: var(--ink); }

/* ── Buttons ─────────────────────────────────────────────── */
.primary-button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.65rem 1.4rem; border-radius: 999px; border: none;
    background: var(--green-deep); color: #fffaf0; font-weight: 700;
    font-size: 0.95rem; cursor: pointer; transition: background 180ms;
}
.primary-button:hover { background: var(--green); }
.control-button {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: 999px; border: 1px solid var(--line);
    background: transparent; color: var(--ink); font-size: 0.88rem; cursor: pointer;
    transition: background 180ms;
}
.control-button:hover { background: rgba(95, 129, 40, 0.08); }
.canvas-fullscreen-button {
    width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer;
    color: var(--ink); transition: background 180ms;
}
.canvas-fullscreen-button:hover { background: rgba(95, 129, 40, 0.08); }

/* ── Overlay ─────────────────────────────────────────────── */
.ws-shell { position: relative; min-height: 340px; }
.overlay {
    position: absolute; inset: 0; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 250, 240, 0.92); backdrop-filter: blur(6px);
    border-radius: 1rem;
}
.overlay.hidden { display: none; }
.overlay-card { text-align: center; max-width: 420px; padding: 1.5rem; }
.overlay-brand { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.overlay-brand-icon { width: 32px; height: 32px; border-radius: 8px; }
.overlay-brand-name { font-weight: 700; font-size: 0.88rem; color: var(--green-deep); }
.overlay-kicker { font-size: 0.9rem; color: var(--orange); font-weight: 600; margin: 0 0 0.3rem; }
.overlay-card h2 { margin: 0 0 0.6rem; font-size: 1.8rem; color: var(--ink); }
.overlay-card p { color: var(--ink-soft); line-height: 1.6; margin: 0 0 1.2rem; font-size: 0.95rem; }
.overlay-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.hidden-action { display: none !important; }

/* ── Grid ────────────────────────────────────────────────── */
.grid-container {
    display: inline-grid;
    gap: 2px;
    margin: 0 auto;
    user-select: none;
    -webkit-user-select: none;
}
.grid-cell {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700; font-family: 'Courier New', Courier, monospace;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    transition: background 150ms, color 150ms, transform 150ms;
}
.grid-cell:hover { background: rgba(95, 129, 40, 0.08); }
.grid-cell.selected {
    background: rgba(232, 160, 63, 0.3);
    border-color: var(--orange);
    transform: scale(1.08);
}
.grid-cell.found {
    background: rgba(45, 122, 45, 0.18);
    color: var(--correct);
    border-color: var(--correct);
}
.grid-cell.found.highlight {
    background: rgba(45, 122, 45, 0.35);
    transform: scale(1.1);
}

#grid-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

/* ── Word bank ───────────────────────────────────────────── */
.word-bank {
    display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;
    padding: 0.75rem 0;
}
.word-chip {
    display: inline-flex; align-items: center; padding: 0.4rem 0.85rem;
    border-radius: 999px; font-size: 0.88rem; font-weight: 600;
    background: rgba(24, 49, 29, 0.07); color: var(--ink);
    border: 1px solid var(--line); transition: all 200ms;
}
.word-chip.found {
    background: rgba(45, 122, 45, 0.15);
    color: var(--correct);
    border-color: var(--correct);
    text-decoration: line-through;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: 1.25rem;
    padding: 1.25rem; box-shadow: 0 8px 24px rgba(20, 54, 31, 0.06);
}
.card-heading { margin: 0 0 0.6rem; font-size: 1.1rem; color: var(--ink); }
.card h2 { margin: 0 0 0.6rem; font-size: 1.05rem; color: var(--ink); }

/* leaderboard */
.leaderboard-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.6rem; }
.leaderboard-tab {
    flex: 1; padding: 0.4rem; border-radius: 999px; border: 1px solid var(--line);
    background: transparent; font-size: 0.78rem; font-weight: 600; cursor: pointer;
    color: var(--ink-soft); transition: all 180ms;
}
.leaderboard-tab.active { background: var(--green-deep); color: #fffaf0; border-color: var(--green-deep); }
.leaderboard-list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.leaderboard-item { display: flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.leaderboard-item:last-child { border: none; }
.lb-rank { font-weight: 700; min-width: 1.6rem; color: var(--ink-soft); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--green); white-space: nowrap; }
.leaderboard-empty { color: var(--ink-soft); font-size: 0.88rem; padding: 0.6rem 0; }
.refresh-button { width: 100%; }

/* submit */
.form-label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.3rem; }
.form-input {
    width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--line);
    border-radius: 0.6rem; font-size: 0.95rem; margin-bottom: 0.6rem;
    background: #fff; color: var(--ink);
}
.leaderboard-status { font-size: 0.82rem; color: var(--green); margin: 0.4rem 0 0; }

/* how to play */
.how-list { padding-left: 1.2rem; margin: 0; font-size: 0.92rem; line-height: 1.7; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 560px) {
    .grid-cell { width: 28px; height: 28px; font-size: 0.82rem; }
    .game-panel { padding: 1rem; }
}
