/* AtomicCross's daily crossword on the web: the look of the Atomic games
   (lib/theme/app_theme.dart) and of juegos.forjait.com, around the app's
   paper board (lib/widgets/crossword_board.dart and paper.dart). */

:root {
    --bg: #0B1026;
    --bg2: #1E1250;
    --glass: rgba(255, 255, 255, .06);
    --glass-strong: rgba(255, 255, 255, .1);
    --border: rgba(255, 255, 255, .14);
    --card: #1B1846;
    --panel: #1E1650;
    --text: #F1F5F9;
    --muted: #A5B4C8;
    --cyan: #22D3EE;
    --violet: #8B5CF6;
    --gold: #FBBF24;
    --orange: #FB923C;
    --success: #34D399;
    --error: #F87171;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* The flags font only exists where the page adds it (Windows, see
       app.js), and only draws flags. */
    font-family: "Twemoji Country Flags", Outfit, system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg) linear-gradient(180deg, var(--bg), var(--bg2)) fixed;
    -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

a { color: var(--cyan); }

button { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

/* Header and footer, as on the rest of the site. */

.top { padding: 18px 0 0; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--text); text-decoration: none; }
.brand span, h1 span {
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.langs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.lang { font-size: 14px; font-weight: 600; text-decoration: none; padding: 4px 12px;
        border: 1px solid var(--border); border-radius: 20px; color: var(--text); }

main { flex: 1; padding-bottom: 32px; }

footer { padding: 20px 0 28px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
footer a { color: var(--muted); }

/* Buttons */

.primary {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 16px;
    padding: 14px 20px;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    box-shadow: 0 8px 24px rgba(139, 92, 246, .3);
    cursor: pointer;
}
.primary.big { font-size: 20px; padding: 16px 20px; }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; cursor: default; }

.ghost {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 16px;
    font-size: 16px;
    font-weight: 700;
    background: var(--glass);
    cursor: pointer;
}

.link { background: none; border: 0; padding: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; font-size: inherit; }
footer .link { color: var(--muted); }

.store {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--glass-strong);
    color: var(--text);
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.panel {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    margin-top: 16px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; text-align: center; }
.panel > .muted { margin: 0; text-align: center; }

/* Presentation */

.hero { text-align: center; padding: 28px 0 8px; }
.icon { width: 88px; height: 88px; border-radius: 22px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.eyebrow { margin: 12px 0 0; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
h1 { font-size: clamp(34px, 9vw, 52px); line-height: 1.1; margin: 4px 0 12px; font-weight: 800; }
.lead { color: var(--muted); font-size: 18px; margin: 0 auto 22px; max-width: 460px; }
.hero .muted.small { margin: 10px 0 0; }
#intro-country { margin: 6px 0 0; }

.how { margin: 20px 0 12px; padding: 0; list-style: none; counter-reset: how; }
.how li {
    counter-increment: how;
    position: relative;
    padding: 10px 12px 10px 48px;
    margin-bottom: 8px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.how li::before {
    content: counter(how);
    position: absolute;
    left: 12px;
    top: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--bg);
    background: var(--cyan);
}

/* Country: a one-line field that opens the list, as in the apps
   ("País del jugador" in AtomicWordServer/docs/linea-atomic.md). */

.question { text-align: center; padding-top: 28px; }
.question h2 { font-size: 28px; margin: 0 0 6px; }
.question p { margin: 0 auto 18px; max-width: 440px; }
.note { margin: 0 0 14px; }

.field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-bottom: 12px;
    padding: 12px 12px 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--glass);
    text-align: left;
    cursor: pointer;
}
.field .value { flex: 1; min-width: 0; font-size: 17px; font-weight: 600;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field .count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.field .chevron { color: var(--muted); font-size: 14px; }

.sheet {
    width: 100%;
    max-width: 560px;
    height: 85vh;
    max-height: 85vh;
    margin: auto auto 0;
    padding: 0;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    background: var(--panel);
    color: var(--text);
}
.sheet::backdrop { background: rgba(5, 8, 20, .65); }
.sheet-body { display: flex; flex-direction: column; height: 100%; padding: 20px 20px 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 21px; font-weight: 800; }
.sheet-head h2 span { font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.sheet .x {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--glass);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
}
.search {
    width: 100%;
    margin: 12px 0 8px;
    padding: 12px 14px 12px 42px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 16px; /* 16px or more: iPhones don't zoom in */
    color: var(--text);
    background: var(--glass) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23A5B4C8' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: 2px solid rgba(34, 211, 238, .6); }
.list-wrap { position: relative; flex: 1; min-height: 0; }
.list { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 40px; }
.options { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8px; }
.option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 9px 4px;
    border: 0;
    border-radius: 10px;
    background: none;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.option:hover, .option:focus-visible { background: var(--glass); }
.option::before {
    content: '';
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border: 2px solid var(--muted);
    border-radius: 50%;
}
.option.selected { font-weight: 700; }
.option.selected::before {
    border-color: var(--cyan);
    background: radial-gradient(circle, var(--cyan) 0 4px, transparent 5px);
}
.option .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.none-option { margin-top: 8px; }
.more {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 28px 0 4px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    background: linear-gradient(180deg, rgba(30, 22, 80, 0), var(--panel) 65%);
    pointer-events: none;
}
.empty { margin: 24px 0 0; text-align: center; color: var(--muted); }

@media (min-width: 600px) {
    .sheet { height: 80vh; margin: auto; border-bottom: 1px solid var(--border); border-radius: 24px; }
}

/* Game: the bar, the paper board, the clue and the keyboard */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 0 10px;
    font-weight: 700;
    font-size: 14px;
}
.bar .daily { white-space: nowrap; }
.bar .progress { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.bar .track { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .3s; }
.bar .count { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.bar .clock { font-variant-numeric: tabular-nums; }
.bar .streak { color: var(--muted); white-space: nowrap; }
.bar .streak.on { color: var(--orange); }

/* The sheet of paper the crossword is printed on. */
.paper {
    position: relative;
    margin: 4px auto 0;
    max-width: 460px;
    padding: 10px;
    border-radius: 18px;
    background:
        radial-gradient(130% 100% at 15% 0%, rgba(255, 255, 255, .4), rgba(255, 255, 255, 0) 60%),
        radial-gradient(110% 110% at 50% 50%, rgba(70, 50, 20, 0) 55%, rgba(70, 50, 20, .12)),
        linear-gradient(135deg, #F8F2E4, #F1E9D6);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .35);
}

.board {
    /* One cell: the sheet's width (the page less its gutters, 460 px at
       most) less the paper's margin, over the cells in a row. */
    --cell: calc((min(100vw - 32px, 460px) - 20px) / var(--n));
    display: grid;
    grid-template-columns: repeat(var(--n), 1fr);
    gap: 1.2px;
    width: 100%;
    aspect-ratio: 1;
    padding: .6px;
    border: 1.5px solid rgba(11, 16, 38, .22);
    border-radius: calc(var(--cell) * .36);
    overflow: hidden;
    /* The thin printed lines between the cells: the paper shows through. */
    background: rgba(11, 16, 38, .16);
    box-shadow: 0 8px 14px rgba(11, 16, 38, .10);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background: rgba(255, 255, 255, .62);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75);
}
/* A cell that isn't played: the same paper, a tone darker and pressed in. */
.cell.black {
    background: linear-gradient(180deg, rgba(60, 40, 10, .28), rgba(60, 40, 10, 0) 34%), #E3D8C0;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .5);
    cursor: default;
}
/* The active word, like a highlighter stroke. */
.cell.active { background: linear-gradient(rgba(34, 211, 238, .38), rgba(34, 211, 238, .38)), rgba(255, 255, 255, .62); }
.cell.active.wrong {
    background:
        linear-gradient(rgba(220, 38, 38, .2), rgba(220, 38, 38, .2)),
        linear-gradient(rgba(34, 211, 238, .38), rgba(34, 211, 238, .38)),
        rgba(255, 255, 255, .62);
}
.cell.cursor { box-shadow: inset 0 0 0 2.2px var(--cyan); }

.cell .num {
    position: absolute;
    top: calc(var(--cell) * .05);
    left: calc(var(--cell) * .08);
    font-size: calc(var(--cell) * .27);
    font-weight: 700;
    line-height: 1;
    color: #5B6283;
}

/* Written by hand: each letter leans and sits a little differently. */
.cell .hand {
    font-family: Caveat, "Segoe Print", "Bradley Hand", cursive;
    font-weight: 700;
    font-size: calc(var(--cell) * .78);
    line-height: 1;
    color: #343849;
    transform: translate(calc(var(--cell) * var(--dx)), calc(var(--cell) * var(--dy))) rotate(var(--rot));
}
.cell.revealed .hand { color: #5B6283; }
.cell.wrong .hand { color: #DC2626; }

.cell .caret {
    position: absolute;
    left: 50%;
    bottom: calc(var(--cell) * .14);
    width: calc(var(--cell) * .42);
    height: max(1.5px, calc(var(--cell) * .06));
    transform: translateX(-50%);
    background: #0891B2;
    animation: blink 1.06s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.board.shake { animation: shake .4s; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

/* The clue */

.clue {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 460px;
    margin: 12px auto 0;
    padding: 10px 6px;
    border-radius: 18px;
    background: var(--glass);
    border: 1px solid var(--border);
}
.clue .arrow {
    flex: 0 0 auto;
    width: 38px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--cyan);
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.clue .arrow:hover, .clue .arrow:focus-visible { background: var(--glass); }
.clue-body { flex: 1; min-width: 0; }
.clue-head { display: flex; align-items: center; gap: 6px; }
.clue-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--cyan);
}
.dots { display: flex; gap: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid rgba(248, 113, 113, .6); }
.dot.on { background: var(--cyan); border-color: var(--cyan); }
.clue-text { margin: 4px 0 0; font-size: 16px; line-height: 1.3; }

.no-help { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

/* The keyboard: the line's glass keys. */

.keyboard { max-width: 520px; margin: 12px auto 0; }
.krow { display: flex; justify-content: center; gap: 5px; margin-bottom: 7px; }
.key {
    flex: 1 1 0;
    max-width: 48px;
    min-width: 0;
    height: 52px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .09);
    font-size: 21px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}
.key:active, .key.pressed { background: rgba(255, 255, 255, .2); }
.key.erase { flex: 1.6 1 0; max-width: 76px; background: rgba(139, 92, 246, .3); }

/* Result */

.result-head { text-align: center; padding-top: 22px; }
.result-head h2 { margin: 0; font-size: 26px; }
.result-head .challenge { margin: 0; color: var(--muted); font-weight: 600; }
.score {
    margin: 6px 0 0;
    font-size: 56px;
    font-weight: 800;
    line-height: 1.1;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.grid { margin: 4px 0 0; font-size: 24px; letter-spacing: 2px; }
.result-head .muted.small { margin: 4px 0 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; margin: 18px 0; }
.stats b { display: block; font-size: 24px; font-weight: 800; }
.stats span { font-size: 12px; color: var(--muted); }

.copied { margin: 8px 0 0; text-align: center; color: var(--success); font-weight: 700; }

.standing { margin: 2px 0 0; text-align: center; color: var(--cyan); font-weight: 800; font-size: 16px; }
.bars { margin-top: 10px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; }
.bar-row .label { width: 34px; color: var(--muted); }
.bar-row .track { flex: 1; }
.bar-row .fill { height: 16px; min-width: 4px; border-radius: 6px; background: var(--violet); }
.bar-row .pct { width: 76px; text-align: right; color: var(--muted); }
.bar-row.mine .label, .bar-row.mine .pct { color: var(--cyan); font-weight: 800; }
.bar-row.mine .fill { background: var(--cyan); }

.rank-row { display: flex; gap: 8px; padding: 2px 0; }
.rank-row .pos { width: 34px; color: var(--muted); }
.rank-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .avg { font-weight: 800; }
.rank-row.mine { color: var(--cyan); font-weight: 800; }
.rank-row.mine .pos { color: var(--cyan); }

.countdown { text-align: center; margin: 18px 0 10px; font-size: 16px; }
.countdown b { font-variant-numeric: tabular-nums; }

#screen > .ghost + .paper { margin-top: 12px; }

.spinner {
    width: 26px;
    height: 26px;
    margin: 8px auto;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--cyan);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    .cell .caret { animation: none; }
    .board.shake { animation: none; }
    .bar .fill { transition: none; }
}

@media (max-width: 380px) {
    .bar { gap: 8px; font-size: 13px; }
    .bar .count { display: none; }
    .key { height: 48px; font-size: 19px; }
    .krow { gap: 4px; }
}

@media (min-width: 600px) {
    .hero { padding-top: 48px; }
}
