/* Nonogram — Simple Board Games */
:root {
    --ng-bg: #0a0f1e;
    --ng-panel: #101a2e;
    --ng-line: #24324d;
    --ng-text: #e6edf7;
    --ng-muted: #94a3b8;
    --ng-accent: #00e5ff;
    --ng-gold: #ffd700;
    --ng-danger: #ff5470;
    --ng-cell: 26px;
    --ng-clue: 46px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--ng-bg);
    color: var(--ng-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.ng-container {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 12px;
    text-align: center;
}

.ng-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.ng-back {
    color: var(--ng-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 4px;
}

.ng-title {
    margin: 0;
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--ng-accent), var(--ng-gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ng-header-right { display: flex; gap: 6px; }

.ng-icon-btn {
    background: var(--ng-panel);
    border: 1px solid var(--ng-line);
    color: var(--ng-text);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    font-size: 1.05rem;
    cursor: pointer;
}

.ng-icon-btn:active { transform: scale(0.94); }

.ng-sound-off { display: none; }
body.ng-muted .ng-sound-on { display: none; }
body.ng-muted .ng-sound-off { display: inline; }

.ng-hud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ng-chip {
    background: var(--ng-panel);
    border: 1px solid var(--ng-line);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 86px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ng-chip-label {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--ng-muted);
}

.ng-chip-value { font-size: 1rem; font-weight: 700; color: var(--ng-accent); }

.ng-stage {
    background: radial-gradient(circle at 50% 0%, #12203a 0%, var(--ng-bg) 70%);
    border: 1px solid var(--ng-line);
    border-radius: 16px;
    padding: 14px 10px 16px;
    position: relative;
    overflow: hidden;
}

/* ---------- board ---------- */
.ng-board {
    display: grid;
    justify-content: center;
    gap: 0;
    user-select: none;
    margin: 0 auto 14px;
    width: max-content;
}

.ng-corner { border: 0; }

.ng-colclue, .ng-rowclue {
    display: flex;
    gap: 4px;
    color: var(--ng-muted);
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ng-colclue {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 5px;
    line-height: 1.1;
}

.ng-rowclue {
    align-items: center;
    justify-content: flex-end;
    padding-right: 7px;
    white-space: nowrap;
}

.ng-colclue.done, .ng-rowclue.done { color: var(--ng-gold); opacity: 0.75; }

.ng-cell {
    width: var(--ng-cell);
    height: var(--ng-cell);
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--ng-line);
    background: #0d1526;
    cursor: pointer;
    position: relative;
    transition: background 0.12s ease, transform 0.08s ease;
}

.ng-cell:hover { border-color: var(--ng-accent); }
.ng-cell:active { transform: scale(0.9); }

.ng-cell.filled {
    background: linear-gradient(135deg, var(--ng-accent), #0091ff);
    border-color: var(--ng-accent);
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.35);
}

.ng-cell.mark {
    background: #16233d;
    color: var(--ng-danger);
    font-size: calc(var(--ng-cell) * 0.62);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ng-cell.mark::after { content: "✕"; }

.ng-cell.wrong {
    animation: ng-shake 0.35s ease;
    box-shadow: inset 0 0 0 2px var(--ng-danger);
}

.ng-cell.good {
    animation: ng-pop 0.4s ease;
    box-shadow: inset 0 0 0 2px var(--ng-gold);
}

.ng-block { cursor: default; background: transparent; border-color: transparent; }

@keyframes ng-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

@keyframes ng-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

/* ---------- toolbar ---------- */
.ng-toolbar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.ng-mode {
    background: var(--ng-panel);
    border: 1px solid var(--ng-line);
    color: var(--ng-text);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
}

.ng-mode.active {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.22), rgba(255, 215, 0, 0.16));
    border-color: var(--ng-accent);
    color: #fff;
}

.ng-check { border-color: var(--ng-gold); color: var(--ng-gold); }
.ng-check:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- overlays ---------- */
.ng-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 22, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
    animation: ng-fade 0.25s ease;
}

.hidden { display: none !important; }

@keyframes ng-fade { from { opacity: 0; } to { opacity: 1; } }

.ng-panel {
    background: var(--ng-panel);
    border: 1px solid var(--ng-line);
    border-radius: 18px;
    padding: 22px 20px;
    width: min(420px, 100%);
    max-height: 100%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.ng-logo {
    width: min(300px, 80%);
    height: auto;
    filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.5));
    max-width: 100%;
    margin-bottom: 6px;
}

.ng-panel-title {
    margin: 6px 0 10px;
    font-size: 1.35rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ng-gold);
}

.ng-tagline { color: var(--ng-muted); margin: 4px 0 16px; font-size: 0.95rem; }

.ng-section { margin-bottom: 14px; text-align: left; }

.ng-label { display: block; font-size: 0.8rem; color: var(--ng-muted); margin-bottom: 6px; }

#playerNameInput {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid var(--ng-line);
    background: #0b1425;
    color: var(--ng-text);
    font-size: 1rem;
    min-height: 44px;
}

#playerNameInput:focus { outline: 2px solid var(--ng-accent); border-color: transparent; }

.ng-difficulty { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }

.ng-btn {
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.1s ease, filter 0.15s ease;
}

.ng-btn small { font-weight: 600; opacity: 0.75; }
.ng-btn:active { transform: translateY(2px); }

.ng-btn-primary {
    background: linear-gradient(135deg, var(--ng-accent), #0072ff);
    color: #04121f;
}

.ng-btn-ghost {
    background: transparent;
    border-color: var(--ng-line);
    color: var(--ng-text);
}

.ng-btn:hover { filter: brightness(1.08); }

.ng-hint { font-size: 0.82rem; color: var(--ng-muted); margin: 0; }

.ng-results { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }

.ng-result {
    background: #0b1425;
    border: 1px solid var(--ng-line);
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 110px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ng-result-label { font-size: 0.65rem; letter-spacing: 0.14em; color: var(--ng-muted); }
.ng-result-value { font-size: 1.5rem; font-weight: 800; color: var(--ng-gold); }

/* ---------- responsive ---------- */
@media (max-width: 480px) {
    .ng-container { padding: 8px; }
    .ng-chip { min-width: 74px; padding: 5px 8px; }
    .ng-stage { padding: 10px 6px 14px; }
    .ng-panel { padding: 18px 14px; }
}
