/* Sokoban. Tutte le classi hanno prefisso .skb- */

.skb-app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 18px 14px 60px;
    color: #0f172a;
}
.skb-app [hidden] { display: none !important; }

.skb-hero { text-align: center; margin-bottom: 18px; }
.skb-hero h1 {
    font-size: clamp(1.7rem, 4.5vw, 2.6rem);
    font-weight: 800;
    margin: 0 0 10px;
    background: linear-gradient(90deg, #c2410c, #f59e0b 55%, #16a34a);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.skb-hero p { margin: 0 auto; max-width: 680px; color: #475569; font-size: 1.02rem; line-height: 1.6; }

/* ---- tab ---- */
.skb-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 18px;
    margin: 0 auto 16px;
    max-width: 640px;
}
.skb-tab {
    min-height: 50px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    font-size: 1rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}
.skb-tab.is-active { background: #fff; color: #9a3412; box-shadow: 0 2px 10px rgba(15, 23, 42, .12); }

/* ---- bottoni ---- */
.skb-btn {
    min-height: 48px;
    padding: 10px 16px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #1e293b;
    font-size: .98rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .1s, border-color .15s, background .15s;
    touch-action: manipulation;
}
.skb-btn:hover { border-color: #fdba74; }
.skb-btn:active { transform: scale(.97); }
.skb-btn:disabled { opacity: .45; cursor: not-allowed; }
.skb-btn.is-primary {
    background: linear-gradient(135deg, #ea580c, #f59e0b);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 16px rgba(234, 88, 12, .3);
}
.skb-btn.is-ghost { background: transparent; }
.skb-btn.is-big { min-height: 54px; font-size: 1.05rem; }
.skb-btn.is-small { min-height: 44px; padding: 6px 12px; font-size: .92rem; }

.skb-round {
    width: 52px; height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    background: #fff;
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    touch-action: manipulation;
}
.skb-round:disabled { opacity: .35; cursor: default; }
.skb-round.is-sm { width: 46px; height: 46px; flex-basis: 46px; font-size: 1.4rem; }

/* ---- gioco ---- */
.skb-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 20px;
    align-items: start;
}
.skb-topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.skb-title {
    flex: 1;
    min-height: 52px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 0; background: none; cursor: pointer; padding: 2px 6px;
}
.skb-title b { font-size: 1.25rem; color: #0f172a; }
.skb-title span { font-size: .9rem; color: #64748b; font-weight: 600; }

.skb-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.skb-stats > div {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 6px 4px;
    text-align: center;
}
.skb-stats span { display: block; font-size: .72rem; color: #64748b; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.skb-stats b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

.skb-boardwrap {
    --skb-void: #0b1220;
    --skb-void2: #1f2937;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 260px;
    padding: 8px;
    border-radius: 22px;
    background: linear-gradient(160deg, var(--skb-void2), var(--skb-void));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 14px 34px rgba(15, 23, 42, .25);
    overflow: hidden;
}
#skbCanvas {
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    border-radius: 8px;
    cursor: pointer;
}

.skb-warn {
    position: absolute;
    left: 10px; right: 10px; bottom: 10px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 8px 8px 14px;
    border-radius: 14px;
    background: rgba(127, 29, 29, .92);
    color: #fff;
    font-weight: 600;
    font-size: .93rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .3);
    animation: skb-pop .25s ease-out;
}
.skb-warn .skb-btn { flex: 0 0 auto; }

.skb-toast {
    position: absolute;
    left: 50%; top: 12px;
    transform: translate(-50%, -20px);
    opacity: 0;
    pointer-events: none;
    max-width: calc(100% - 24px);
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .9);
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
    text-align: center;
    transition: opacity .2s, transform .2s;
}
.skb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.skb-win {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
}
.skb-win-card {
    width: min(380px, 100%);
    background: #fff;
    border-radius: 22px;
    padding: 20px 18px 18px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
    animation: skb-pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.skb-win-card h2 { margin: 4px 0 6px; font-size: 1.45rem; }
.skb-win-card p { margin: 0 0 14px; color: #475569; line-height: 1.5; }
.skb-win-card small { color: #64748b; }
.skb-rec { color: #16a34a; }
.skb-win-stars { font-size: 2.6rem; letter-spacing: 4px; line-height: 1; }
.skb-win-stars span { color: #e2e8f0; display: inline-block; }
.skb-win-stars span.on { color: #f59e0b; text-shadow: 0 2px 8px rgba(245, 158, 11, .5); animation: skb-star .5s both; }
.skb-win-stars span.on:nth-child(2) { animation-delay: .15s; }
.skb-win-stars span.on:nth-child(3) { animation-delay: .3s; }
.skb-win-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skb-win-actions .is-primary { grid-column: 1 / -1; }

@keyframes skb-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes skb-star { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.3); } to { transform: scale(1); } }

/* ---- pad e azioni ---- */
.skb-side { display: flex; flex-direction: column; gap: 14px; }
.skb-pad {
    display: grid;
    grid-template-columns: repeat(3, 76px);
    grid-template-rows: repeat(3, 68px);
    gap: 8px;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}
.skb-pad button {
    border: 0;
    border-radius: 18px;
    background: linear-gradient(180deg, #334155, #1e293b);
    color: #fff;
    font-size: 1.5rem;
    box-shadow: 0 5px 0 #0f172a, 0 8px 16px rgba(15, 23, 42, .25);
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .06s, box-shadow .06s;
}
.skb-pad button.is-down, .skb-pad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #0f172a, 0 3px 8px rgba(15, 23, 42, .25); }
.skb-pad .skb-pad-undo { background: linear-gradient(180deg, #f59e0b, #d97706); box-shadow: 0 5px 0 #92400e, 0 8px 16px rgba(217, 119, 6, .3); font-size: 1.6rem; }

.skb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skb-actions .skb-wide { grid-column: 1 / -1; }
.skb-help { margin: 0; color: #64748b; font-size: .9rem; line-height: 1.5; }

/* ---- livelli ---- */
.skb-totals { text-align: center; font-weight: 700; color: #334155; margin: 0 0 14px; }
.skb-world {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 14px;
    margin-bottom: 14px;
}
.skb-world-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.skb-world-emoji {
    width: 52px; height: 52px; flex: 0 0 52px;
    display: grid; place-items: center;
    font-size: 1.7rem;
    border-radius: 14px;
    background: var(--w-bg, #f1f5f9);
}
.skb-world-head h3 { margin: 0; font-size: 1.15rem; }
.skb-world-head small { color: #64748b; }
.skb-world-head > div { flex: 1; min-width: 0; }
.skb-world-prog { font-weight: 700; color: #b45309; white-space: nowrap; }
.skb-w-warehouse { --w-bg: #fde7d6; --w-c: #c2410c; }
.skb-w-harbor { --w-bg: #dbeafe; --w-c: #1d4ed8; }
.skb-w-desert { --w-bg: #fef3c7; --w-c: #b45309; }
.skb-w-ice { --w-bg: #e0f2fe; --w-c: #0369a1; }
.skb-w-jungle { --w-bg: #dcfce7; --w-c: #15803d; }
.skb-w-volcano { --w-bg: #fee2e2; --w-c: #b91c1c; }

.skb-lv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.skb-lv {
    min-height: 60px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: #334155;
    touch-action: manipulation;
}
.skb-lv b { font-size: 1.1rem; }
.skb-lv i { font-style: normal; font-size: .72rem; color: #f59e0b; letter-spacing: 1px; }
.skb-lv i em { font-style: normal; color: #cbd5e1; }
.skb-lv.is-done { background: var(--w-bg); border-color: transparent; color: var(--w-c); }
.skb-lv.is-cur { border-color: var(--w-c, #ea580c); box-shadow: 0 0 0 3px rgba(234, 88, 12, .15); }
.skb-lv:hover { transform: translateY(-1px); }

/* ---- editor ---- */
.skb-ed { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.skb-tools { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.skb-tool {
    min-height: 62px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #fff;
    font-size: 1.45rem;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    touch-action: manipulation;
}
.skb-tool span { font-size: .72rem; font-weight: 700; color: #475569; }
.skb-tool.is-active { border-color: #ea580c; background: #fff7ed; box-shadow: 0 0 0 3px rgba(234, 88, 12, .15); }

.skb-ed-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.skb-size { display: flex; align-items: center; gap: 6px; }
.skb-size span { font-size: .85rem; color: #64748b; font-weight: 700; }
#skbEdSize { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.skb-ed-scroll {
    overflow: auto;
    border-radius: 18px;
    background: #0f172a;
    padding: 6px;
    max-height: 75vh;
    display: flex;
}
#skbEdCanvas { display: block; margin: auto; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 8px; }

.skb-ed-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.skb-ed-actions .skb-btn { padding: 8px 6px; font-size: .9rem; }

.skb-themes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.skb-themes span { font-size: .85rem; color: #64748b; font-weight: 700; margin-right: 4px; }
.skb-theme-pick {
    width: 48px; height: 48px;
    border-radius: 12px;
    border: 3px solid transparent;
    font-size: 1.3rem;
    cursor: pointer;
}
.skb-theme-pick.is-active { border-color: #0f172a; }
.t-warehouse { background: #b4532a; } .t-harbor { background: #2563eb; } .t-desert { background: #e4b36b; }
.t-ice { background: #bfdcf5; } .t-jungle { background: #1f7a3a; } .t-volcano { background: #b93a0e; }

.skb-ed-side {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.skb-ed-side h3 { margin: 0; font-size: 1.1rem; }
.skb-check { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.skb-check li { display: flex; gap: 8px; align-items: flex-start; font-size: .93rem; line-height: 1.4; }
.skb-check li span {
    flex: 0 0 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 800; color: #fff;
}
.skb-check li.ok span { background: #16a34a; }
.skb-check li.ko span { background: #dc2626; }
.skb-check li.ko { color: #991b1b; }

.skb-solve {
    border-radius: 14px;
    padding: 12px;
    font-size: .95rem;
    line-height: 1.45;
    display: flex; flex-direction: column; gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.skb-solve.is-ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.skb-solve.is-ko { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.skb-solve.is-warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.skb-solve.is-run .skb-solve-msg::after { content: ''; display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid #94a3b8; border-top-color: transparent; border-radius: 50%; animation: skb-spin .8s linear infinite; vertical-align: -2px; }
.skb-solve.is-idle { color: #64748b; }
@keyframes skb-spin { to { transform: rotate(360deg); } }

.skb-field { display: flex; flex-direction: column; gap: 4px; }
.skb-field span { font-size: .85rem; font-weight: 700; color: #475569; }
.skb-field input {
    min-height: 48px; padding: 10px 12px;
    border-radius: 12px; border: 2px solid #e2e8f0;
    font-size: 1rem;
}
.skb-field input:focus { outline: none; border-color: #f59e0b; }
.skb-ed-save { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.skb-ed-save .skb-btn { padding: 8px 4px; }
.skb-ed-toast { min-height: 0; font-weight: 700; color: #15803d; font-size: .93rem; opacity: 0; transition: opacity .2s; }
.skb-ed-toast.is-on { opacity: 1; }

.skb-xsb summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.skb-xsb p { font-size: .88rem; color: #64748b; margin: 6px 0; line-height: 1.5; }
.skb-xsb textarea {
    width: 100%; box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .95rem; line-height: 1.15;
    border: 2px solid #e2e8f0; border-radius: 12px; padding: 10px;
    white-space: pre; overflow: auto;
    margin-bottom: 8px;
}
.skb-xsb .skb-ed-save { grid-template-columns: 1fr 1fr; }

/* ---- i miei ---- */
.skb-mine { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.skb-empty { grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: #64748b; background: #fff; border: 2px dashed #e2e8f0; border-radius: 20px; }
.skb-mine-card {
    display: flex; gap: 12px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 18px; padding: 12px;
}
.skb-mini { flex: 0 0 auto; align-self: center; border-radius: 10px; max-width: 150px; height: auto !important; }
.skb-mine-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.skb-mine-body h4 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.skb-badge { align-self: flex-start; font-size: .8rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.skb-badge.ok { background: #dcfce7; color: #166534; }
.skb-badge.warn { background: #fef3c7; color: #92400e; }
.skb-badge.ko { background: #f1f5f9; color: #475569; }
.skb-mine-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.skb-mine-actions .skb-btn { padding: 8px 12px; font-size: .9rem; }

/* ---- testo ---- */
.skb-seo { margin-top: 40px; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; padding: 22px; line-height: 1.7; color: #334155; }
.skb-seo h2 { font-size: 1.3rem; margin: 18px 0 8px; color: #0f172a; }
.skb-seo h2:first-child { margin-top: 0; }
.skb-seo ul { padding-left: 20px; }

/* ---- telefono ---- */
@media (max-width: 900px) {
    .skb-stage, .skb-ed { grid-template-columns: 1fr; }
    .skb-side { align-items: stretch; }
}
@media (max-width: 560px) {
    .skb-app { padding: 10px 8px 40px; }
    .skb-hero p { font-size: .95rem; }
    .skb-tab span { display: block; font-size: .8rem; }
    .skb-tab { min-height: 56px; font-size: 1.15rem; line-height: 1.1; }
    .skb-stats { gap: 5px; }
    .skb-stats span { font-size: .62rem; letter-spacing: 0; }
    .skb-stats b { font-size: 1.05rem; }
    .skb-boardwrap { padding: 4px; border-radius: 16px; }
    .skb-pad { grid-template-columns: repeat(3, minmax(76px, 92px)); grid-template-rows: repeat(3, 70px); }
    .skb-keys { display: none; }
    .skb-tools { grid-template-columns: repeat(3, 1fr); }
    .skb-ed-actions { grid-template-columns: 1fr 1fr; }
    .skb-mine { grid-template-columns: 1fr; }
    .skb-mine-card { flex-direction: column; }
    .skb-mini { max-width: 100%; }
}
@media (hover: hover) and (pointer: fine) and (min-width: 901px) {
    .skb-pad { grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 58px); }
}
