/* ─── Container ─────────────────────────────────────────────────────── */
#game-root .cw-wrap {
    position: relative;
    padding: 0.75rem;
    max-width: 560px;
    margin: 0 auto;
    background: linear-gradient(180deg, #2a1010 0%, #5a1818 100%);
    border-radius: var(--jul-radius-lg, 20px);
    user-select: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* ─── HUD pills ─────────────────────────────────────────────────────── */
#game-root .cw-header {
    display: flex; align-items: stretch; gap: 0.4rem;
    margin-bottom: 0.55rem;
}
#game-root .cw-pill {
    flex: 1 1 0; min-width: 0;
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.32rem 0.65rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .cw-pill-icon { font-size: 1.2rem; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15)); }
#game-root .cw-pill-body { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
#game-root .cw-lbl {
    font-size: 0.6rem; letter-spacing: 0.08em;
    color: #8a5a1a; text-transform: uppercase; font-weight: 700;
}
#game-root .cw-val {
    font-size: 1.2rem; font-weight: 800;
    color: var(--jul-red-700, #8B0000);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
#game-root .cw-audio {
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.28rem 0.5rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .cw-mute { background: transparent; border: 0; width: 26px; height: 26px; cursor: pointer; font-size: 0.95rem; padding: 0; }
#game-root .cw-vol { width: 56px; cursor: pointer; accent-color: var(--jul-red-700, #8B0000); }

/* ─── Mode chips ────────────────────────────────────────────────────── */
#game-root .cw-modes { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
#game-root .cw-mode {
    flex: 1 1 auto;
    padding: 0.32rem 0.55rem;
    font-size: 0.78rem; font-weight: 700;
    color: #fde9a8;
    background: rgba(0,0,0,0.28);
    border: 1px solid rgba(255, 221, 100, 0.18);
    border-radius: 999px;
    cursor: pointer; letter-spacing: 0.02em;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
#game-root .cw-mode:hover:not(.cw-mode--active) { background: rgba(0,0,0,0.42); color: #fff8d0; }
#game-root .cw-mode--active {
    background: linear-gradient(180deg, #fbd24a 0%, #d99b1e 100%);
    color: #4a1a05; border-color: #b8870b;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 4px rgba(0,0,0,0.3);
}

/* ─── Book playfield ────────────────────────────────────────────────── */
#game-root .cw-book {
    position: relative;
    padding: 1rem;
    border: 3px solid #ffd66b;
    border-radius: 14px;
    overflow: hidden;
    background-image: url('/games/jule-krydsord/background.jpg');
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.4), inset 0 0 18px rgba(0,0,0,0.3);
}
#game-root .cw-daily-badge {
    position: absolute; top: 8px; right: 8px;
    padding: 0.22rem 0.55rem;
    font-size: 0.7rem; font-weight: 700;
    color: #4a1a05;
    background: linear-gradient(180deg, #fbd24a 0%, #d99b1e 100%);
    border: 1px solid #b8870b; border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    letter-spacing: 0.04em; z-index: 3;
}
/* cream "book page" panel that holds the readable content */
#game-root .cw-page {
    position: relative;
    background: rgba(255, 250, 235, 0.93);
    border: 2px solid rgba(150, 95, 40, 0.45);
    border-radius: 10px;
    padding: 0.7rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.3), inset 0 0 0 4px rgba(214, 160, 90, 0.18);
}

/* ─── Active-clue bar ───────────────────────────────────────────────── */
#game-root .cw-cluebar {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    min-height: 2.2em;
    margin-bottom: 0.6rem;
    padding: 0.45rem 0.65rem;
    background: linear-gradient(180deg, #fff8e1 0%, #f6e6bd 100%);
    border: 1px solid rgba(150, 95, 40, 0.35);
    border-radius: 8px;
    color: #4a2a10;
    font-size: 0.95rem; font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}
#game-root .cw-cluebar-tag {
    flex: 0 0 auto;
    padding: 0.15rem 0.5rem;
    background: var(--jul-red-700, #8B0000);
    color: #fff8d0;
    border-radius: 999px;
    font-size: 0.75rem; font-weight: 800;
    letter-spacing: 0.03em;
}

/* ─── Grid ──────────────────────────────────────────────────────────── */
#game-root .cw-grid-wrap { display: flex; justify-content: center; }
#game-root .cw-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 2px;
    width: min(100%, calc(var(--cols) * 38px));
}
#game-root .cw-cell {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: none;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--jul-font-display, Georgia, serif);
    font-weight: 800;
    color: #2a1808;
    cursor: pointer;
    border-radius: 3px;
}
/* real (letter) cells get the paper-white tile look */
#game-root .cw-cell:not(.cw-cell--blank) {
    background: linear-gradient(180deg, #ffffff 0%, #fbf4e3 100%);
    box-shadow: inset 0 0 0 1px rgba(120, 80, 40, 0.55), 0 1px 2px rgba(0,0,0,0.2);
}
#game-root .cw-cell--blank { background: transparent; cursor: default; box-shadow: none; }
#game-root .cw-cell--word {
    background: linear-gradient(180deg, #fff2c9 0%, #ffe49c 100%);
    box-shadow: inset 0 0 0 1px rgba(150, 95, 40, 0.6), 0 1px 2px rgba(0,0,0,0.22);
}
#game-root .cw-cell--sel {
    background: linear-gradient(180deg, #ffd66b 0%, #f4b53a 100%) !important;
    box-shadow: inset 0 0 0 2px #b8870b, 0 0 8px rgba(244, 181, 58, 0.7) !important;
}
#game-root .cw-cell--wrong {
    background: linear-gradient(180deg, #fca5a5 0%, #ef4444 100%) !important;
    box-shadow: inset 0 0 0 2px #991b1b !important;
    color: #fff !important;
    animation: cw-wrong 0.4s ease;
}
@keyframes cw-wrong {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}
#game-root .cw-cell--right {
    background: linear-gradient(180deg, #86efac 0%, #16a34a 100%) !important;
    box-shadow: inset 0 0 0 2px #14532d, 0 0 8px rgba(34, 197, 94, 0.6) !important;
    color: #08300f !important;
    animation: cw-right 0.45s ease;
}
@keyframes cw-right {
    0% { transform: scale(1); }
    45% { transform: scale(1.14); }
    100% { transform: scale(1); }
}
#game-root .cw-num {
    position: absolute; top: 0; left: 2px;
    font-size: clamp(0.4rem, 1.6vw, 0.58rem);
    font-weight: 700; color: #9a6a2a;
    line-height: 1; pointer-events: none;
    font-family: system-ui, sans-serif;
}
#game-root .cw-letter {
    font-size: clamp(0.85rem, 4vw, 1.25rem);
    line-height: 1;
    animation: cw-letter-pop 0.2s ease;
}
@keyframes cw-letter-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
#game-root .cw-hidden-input {
    position: absolute; opacity: 0; pointer-events: none;
    width: 1px; height: 1px; left: 50%; bottom: 0;
    font-size: 16px; /* avoid iOS zoom on focus */
}

/* ─── Confetti ──────────────────────────────────────────────────────── */
#game-root .cw-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#game-root .cw-confetti-piece {
    position: absolute; top: 30%; left: 50%;
    width: 8px; height: 12px; border-radius: 2px;
    animation: cw-confetti-fall 1.4s ease-out forwards;
}
@keyframes cw-confetti-fall {
    0% { transform: translate(0,0) rotate(0); opacity: 1; }
    100% { transform: translate(var(--dx), 260px) rotate(var(--rot)); opacity: 0; }
}

/* ─── Actions ───────────────────────────────────────────────────────── */
#game-root .cw-actions {
    display: flex; justify-content: center; gap: 0.4rem;
    margin-top: 0.7rem; flex-wrap: wrap;
}
#game-root .cw-btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem; font-weight: 700;
    border-radius: 999px; cursor: pointer;
    transition: transform 0.08s ease, background 0.2s ease, opacity 0.2s ease;
}
#game-root .cw-btn--primary {
    background: linear-gradient(180deg, #dc2626 0%, #991b1b 100%);
    color: #fff; border: 1px solid #7f1d1d;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
#game-root .cw-btn--primary:hover { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); transform: translateY(-1px); }
#game-root .cw-btn--primary:active { transform: translateY(1px); }
#game-root .cw-btn--ghost {
    background: rgba(255, 248, 225, 0.95);
    color: #4a1a05; border: 1px solid rgba(0,0,0,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 2px 4px rgba(0,0,0,0.18);
}
#game-root .cw-btn--ghost:hover { background: #fff; transform: translateY(-1px); }
#game-root .cw-btn--ghost:active { transform: translateY(1px); }

/* ─── Clue lists ────────────────────────────────────────────────────── */
#game-root .cw-clues {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem;
    margin-top: 0.8rem;
}
#game-root .cw-clues h4 {
    margin: 0 0 0.4rem;
    color: #fde9a8;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255, 221, 100, 0.3);
    padding-bottom: 0.25rem;
}
#game-root .cw-clue {
    font-size: 0.82rem;
    color: #f3e6cf;
    padding: 0.28rem 0.45rem;
    border-radius: 6px;
    cursor: pointer; margin-bottom: 0.1rem;
    transition: background 0.15s ease, color 0.15s ease;
}
#game-root .cw-clue strong { color: #ffd66b; }
/* hover keeps light text but lifts on a warm gold tint (not a washed-out light fill) */
#game-root .cw-clue:hover:not(.cw-clue--active) {
    background: rgba(255, 214, 107, 0.22);
    color: #fff;
}
/* active = current clue: solid cream fill with dark text so it's clearly readable */
#game-root .cw-clue--active {
    background: linear-gradient(180deg, #fff8e1 0%, #f4e3b4 100%);
    color: #3a2008;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.7);
}
#game-root .cw-clue--active strong { color: var(--jul-red-700, #8B0000); }

/* ─── Status message ────────────────────────────────────────────────── */
#game-root .cw-msg {
    text-align: center; margin-top: 0.65rem; min-height: 1.6em;
    font-weight: 600; color: #fde9a8;
}
#game-root .cw-msg-good { color: #4ade80; font-size: 1.1rem; text-shadow: 0 1px 6px rgba(74,222,128,0.4); }
#game-root .cw-msg-hint { color: #fde9a8; font-size: 0.95rem; }
#game-root .cw-msg-time {
    display: inline-block; margin-left: 0.4rem;
    padding: 0.1rem 0.55rem;
    background: rgba(0,0,0,0.45); border-radius: 999px;
    color: #fff8d0; font-weight: 700; font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

/* ─── Confirm modal ─────────────────────────────────────────────────── */
#game-root .cw-modal {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background: rgba(20, 6, 6, 0.62);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    border-radius: var(--jul-radius-lg, 20px);
    z-index: 30;
    animation: cw-modal-fade 0.18s ease;
}
#game-root .cw-modal[hidden] { display: none; }
@keyframes cw-modal-fade { 0% { opacity: 0; } 100% { opacity: 1; } }
#game-root .cw-modal-card {
    max-width: 340px; width: 100%;
    text-align: center;
    padding: 1.4rem 1.3rem 1.2rem;
    background: linear-gradient(180deg, #fff8e1 0%, #fbf0c8 100%);
    border: 1px solid rgba(150, 95, 40, 0.45);
    border-radius: 16px;
    box-shadow: 0 12px 34px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.7);
    animation: cw-modal-pop 0.3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes cw-modal-pop {
    0% { transform: scale(0.8) translateY(8px); opacity: 0; }
    100% { transform: none; opacity: 1; }
}
#game-root .cw-modal-icon { font-size: 2rem; line-height: 1; margin-bottom: 0.3rem; }
#game-root .cw-modal-card h3 {
    margin: 0 0 0.45rem;
    color: var(--jul-red-700, #8B0000);
    font-size: 1.2rem;
}
#game-root .cw-modal-card p {
    margin: 0 0 1rem;
    color: #4a2a10;
    font-size: 0.92rem; line-height: 1.45;
}
#game-root .cw-modal-actions {
    display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap;
}

/* ─── Desktop scale-up ──────────────────────────────────────────────── */
@media (min-width: 720px) {
    #game-root .cw-wrap { max-width: 720px; padding: 1rem; }
    #game-root .cw-val { font-size: 1.4rem; }
    #game-root .cw-pill-icon { font-size: 1.35rem; }
    #game-root .cw-mode { padding: 0.42rem 0.7rem; font-size: 0.86rem; }
    #game-root .cw-book { padding: 1.4rem; }
    #game-root .cw-grid { width: min(100%, calc(var(--cols) * 46px)); }
    #game-root .cw-cluebar { font-size: 1.02rem; }
    #game-root .cw-clue { font-size: 0.88rem; }
    #game-root .cw-btn { font-size: 0.95rem; padding: 0.6rem 1.2rem; }
}
@media (min-width: 1024px) {
    #game-root .cw-wrap { max-width: 840px; padding: 1.15rem; }
    #game-root .cw-grid { width: min(100%, calc(var(--cols) * 52px)); }
}

/* ─── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #game-root .cw-wrap { padding: 0.6rem; }
    #game-root .cw-header { flex-wrap: wrap; gap: 0.3rem; }
    #game-root .cw-val { font-size: 1.05rem; }
    #game-root .cw-audio { padding: 0.25rem 0.4rem; }
    #game-root .cw-vol { width: 48px; }
    #game-root .cw-modes { gap: 0.25rem; }
    #game-root .cw-mode { padding: 0.3rem 0.5rem; font-size: 0.74rem; }
    #game-root .cw-book { padding: 0.6rem; }
    #game-root .cw-page { padding: 0.5rem; }
    #game-root .cw-grid { gap: 1px; }
    #game-root .cw-clues { grid-template-columns: 1fr; gap: 0.5rem; }
}
