/* Bentomino: a casual mobile puzzle game. Soft glossy buttons, rounded cards, Allo throughout, and a blurred
   Japanese scene behind everything that changes with each part of the world. */
:root {
    --ink: #2b2150;
    --cream: #fff9ef;
    --red: #c8282f;
    --gold: #ffc533;
    --round: "ROND" 100;
    --font: "Allo", "Hiragino Maru Gothic ProN", "Hiragino Sans", "PingFang SC", "Apple SD Gothic Neo", "Noto Sans CJK JP", system-ui, sans-serif;
    --top: max(12px, env(safe-area-inset-top));
    --bottom: max(14px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #c17a98;
    color: var(--ink);
    font-family: var(--font);
    font-variation-settings: var(--round);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

body { touch-action: none; overscroll-behavior: none; }

button {
    font: inherit;
    color: inherit;
    border: 0;
    padding: 0;
    background: none;
    cursor: pointer;
    touch-action: manipulation;
}

svg { display: block; }

/* ---------------------------------------------------------------- loading */

#loader {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 26px;
    background: radial-gradient(ellipse at 50% 40%, #f6b8cc, #c8607e);
    transition: opacity 0.4s;
}

#loader img { width: min(70vw, 360px); animation: breathe-logo 1.6s ease-in-out infinite alternate; }
#loader i { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; animation: spin 0.9s linear infinite; }
#loader.gone { opacity: 0; pointer-events: none; }

@keyframes breathe-logo { to { transform: scale(1.04); } }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------------------------------------------------------------- the scene behind */

/* Two layers of the same blurred scene drifting at different speeds, one fading in and out over the other, so it
   slowly moves. Transforms and opacity only. */
#bg { position: fixed; inset: 0; overflow: hidden; background: #c17a98; }

#bg i {
    position: absolute;
    inset: -12%;
    background: var(--back, url(media/back-sakura.jpg)) center / cover;
    animation: drift 46s ease-in-out infinite alternate;
    will-change: transform;
}

#bg i + i {
    background-image: var(--back2, url(media/back-sakura-2.jpg));
    transform: scaleX(-1);
    animation: drift2 38s ease-in-out infinite alternate, breathe 23s ease-in-out infinite alternate;
    opacity: 0.55;
}

#bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(96, 22, 62, 0.4) 100%);
}

@keyframes drift {
    from { transform: scale(1.05) translate(-3%, -2%) rotate(-2deg); }
    to { transform: scale(1.18) translate(3%, 3%) rotate(3deg); }
}

@keyframes drift2 {
    from { transform: scaleX(-1) scale(1.2) translate(4%, 2%) rotate(4deg); }
    to { transform: scaleX(-1) scale(1.08) translate(-3%, -4%) rotate(-3deg); }
}

@keyframes breathe { from { opacity: 0.15; } to { opacity: 0.75; } }

/* ---------------------------------------------------------------- screens */

#home, #game { position: fixed; inset: 0; display: none; }
body[data-screen="home"] #home, body[data-screen="game"] #game { display: block; }

/* ---------------------------------------------------------------- buttons */

.key, .big {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    color: var(--ink);
    background: linear-gradient(#ffffff, #efe6f6);
    box-shadow: 0 5px 0 #b9a8cf, 0 8px 0 rgba(20, 12, 50, 0.22);
    transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}

.key svg, .big svg { width: 27px; height: 27px; fill: currentColor; }
.key:active, .big:active { transform: translateY(4px); box-shadow: 0 1px 0 #b9a8cf, 0 3px 0 rgba(20, 12, 50, 0.22); }

.key.gold, .big {
    color: #fff;
    background: linear-gradient(#ffd75a, #ffa51f);
    box-shadow: 0 5px 0 #c9700b, 0 8px 0 rgba(20, 12, 50, 0.22);
}

.key.gold:active, .big:active { box-shadow: 0 1px 0 #c9700b, 0 3px 0 rgba(20, 12, 50, 0.22); }
.key.gold svg, .big svg { filter: drop-shadow(0 2px 0 rgba(150, 70, 0, 0.45)); }

/* Round buttons at the top: smaller. */
.key.round { width: 48px; height: 48px; }
.key.round svg { width: 24px; height: 24px; }

/* Settings in the bar sits apart: smaller, quieter. */
.key.small {
    width: 44px;
    height: 44px;
    margin-left: 10px;
    color: #fff;
    background: rgba(110, 30, 74, 0.38);
    box-shadow: none;
}

.key.small svg { width: 22px; height: 22px; }
.key.small:active { transform: scale(0.92); box-shadow: none; }

.key:disabled, .big:disabled { opacity: 0.45; pointer-events: none; }
.key.busy svg { animation: glow 0.8s ease-in-out infinite; }
.key.nudge { animation: nudge 0.9s ease-in-out infinite; }
.key.wake { animation: wake 1.4s ease-in-out infinite; }

@keyframes glow { 50% { opacity: 0.35; } }
@keyframes wake {
    0%, 100% { transform: none; box-shadow: 0 5px 0 #c9700b, 0 8px 0 rgba(20, 12, 50, 0.22), 0 0 0 0 rgba(255, 220, 110, 0); }
    50% { transform: scale(1.1); box-shadow: 0 5px 0 #c9700b, 0 8px 0 rgba(20, 12, 50, 0.22), 0 0 0 10px rgba(255, 220, 110, 0.4); }
}
@keyframes nudge { 0%, 100% { transform: none; } 15% { transform: translateY(-7px) scale(1.06); } 30% { transform: none; } 42% { transform: translateY(-3px); } 55% { transform: none; } }

/* ---------------------------------------------------------------- home */

#mapview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#scroller {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    touch-action: pan-y;
    overscroll-behavior: contain;
    scrollbar-width: none;
}

#scroller::-webkit-scrollbar { display: none; }
@media (pointer: fine) { #scroller { cursor: grab; } #scroller.dragging { cursor: grabbing; } }

.bar-top {
    position: absolute;
    top: var(--top);
    left: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.bar-top > * { pointer-events: auto; }

#logo {
    width: min(52vw, 240px);
    filter: drop-shadow(0 3px 0 rgba(90, 10, 30, 0.35));
    pointer-events: none;
}

#daily { position: relative; }
#daily .dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #e8343a;
    border: 2px solid #fff;
}
#daily.done .dot { display: none; }

.bar-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--bottom);
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.play {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 68px;
    padding: 0 34px 0 26px;
    border-radius: 34px;
    color: #fff;
    font-size: 26px;
    font-weight: 850;
    background: linear-gradient(#ffd75a, #ffa51f);
    box-shadow: 0 6px 0 #c9700b, 0 10px 0 rgba(20, 12, 50, 0.22);
    text-shadow: 0 2px 0 rgba(150, 70, 0, 0.45);
    transition: transform 0.08s, box-shadow 0.08s;
    animation: pulse-play 1.8s ease-in-out infinite;
}

.play svg { width: 26px; height: 26px; fill: currentColor; filter: drop-shadow(0 2px 0 rgba(150, 70, 0, 0.45)); }
.play b { font-feature-settings: "tnum"; }
.play:active { transform: translateY(5px); box-shadow: 0 1px 0 #c9700b, 0 4px 0 rgba(20, 12, 50, 0.22); animation: none; }

@keyframes pulse-play { 50% { transform: scale(1.04); } }

/* ---------------------------------------------------------------- the level, the moves */

#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#top {
    position: absolute;
    top: var(--top);
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

#top > * { pointer-events: auto; }

#home-btn { position: absolute; left: 14px; top: 4px; }

#title {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    padding: 2px 14px 6px;
}

#title small, #moves small {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.85;
}

#title b {
    font-size: 40px;
    font-weight: 850;
    line-height: 1;
    font-feature-settings: "tnum";
    margin-top: 2px;
    text-shadow: 0 3px 0 rgba(110, 24, 64, 0.6);
}

#title.daily b { font-size: 26px; margin-top: 6px; }

#moves {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    top: 0;
    min-width: 58px;
    height: 58px;
    padding: 0 6px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--ink);
    background: linear-gradient(#fffdf8, #f1e7d6);
    box-shadow: 0 4px 0 #c9b79a, 0 6px 0 rgba(20, 12, 50, 0.25);
}

#moves b { font-size: 27px; font-weight: 850; line-height: 1; font-feature-settings: "tnum"; }
#moves small { font-size: 9px; letter-spacing: 0.06em; opacity: 0.6; }
#moves.low { color: #fff; background: linear-gradient(#ff8a65, #ec4b3c); box-shadow: 0 4px 0 #a92e24, 0 6px 0 rgba(20, 12, 50, 0.25); }
#moves.low small { opacity: 0.85; }
#moves.bump { animation: bump 0.3s; }
#moves.gain { animation: gain 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes gain { 40% { transform: scale(1.3); filter: brightness(1.2); } }

/* The extra-move power-up, beside the moves: +1, and how many you have in its corner. */
.extra {
    position: absolute;
    right: calc(max(14px, env(safe-area-inset-right)) + 70px);
    top: 6px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(#ffd75a, #ffa51f);
    box-shadow: 0 4px 0 #c9700b, 0 6px 0 rgba(20, 12, 50, 0.22);
    transition: transform 0.08s, box-shadow 0.08s;
}

.extra[hidden] { display: none; }
.extra b, .extra-big b { font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 rgba(150, 70, 0, 0.45); }
.extra-big b { font-size: 28px; }
.extra:active { transform: translateY(3px); box-shadow: 0 1px 0 #c9700b, 0 3px 0 rgba(20, 12, 50, 0.22); }
.extra .count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: 11px;
    font-style: normal;
    font-size: 13px;
    font-weight: 850;
    line-height: 22px;
    color: #fff;
    background: var(--red);
    box-shadow: 0 0 0 2px #fff;
}

/* The +1 on its way into the moves. */
.flyer {
    position: fixed;
    z-index: 30;
    pointer-events: none;
    font-size: 26px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 2px 0 #c9700b, 0 0 12px rgba(255, 210, 90, 0.9);
}
#moves.out { animation: shake 0.5s; }

@keyframes bump { 40% { transform: scale(1.14); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

#bar {
    position: absolute;
    left: 50%;
    bottom: var(--bottom);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 11;
}

/* A bento level announces itself. */
#banner {
    position: absolute;
    left: 0;
    right: 0;
    top: 38%;
    display: grid;
    place-items: center;
    pointer-events: none;
}

#banner[hidden] { display: none; }

#banner span {
    padding: 10px 34px;
    border-radius: 18px;
    font-size: 42px;
    font-weight: 900;
    color: var(--cream);
    background: linear-gradient(#e5392f, #b0171f);
    box-shadow: 0 0 0 4px #f7c95c, 0 8px 0 4px rgba(70, 8, 20, 0.45);
    text-shadow: 0 3px 0 rgba(80, 0, 10, 0.5);
    animation: banner 1.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes banner {
    0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
    20% { transform: scale(1.05) rotate(2deg); opacity: 1; }
    30%, 75% { transform: scale(1) rotate(0); opacity: 1; }
    100% { transform: scale(0.9) translateY(-30px); opacity: 0; }
}

/* ---------------------------------------------------------------- cards */

.sheet {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(24, 16, 52, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: fade 0.3s both;
    z-index: 20;
}

.sheet[hidden] { display: none; }


.card {
    position: relative;
    width: min(330px, 100%);
    padding: 30px 24px 26px;
    border-radius: 30px;
    text-align: center;
    color: var(--ink);
    background: linear-gradient(#fffdf8, #f6eee1);
    box-shadow: 0 8px 0 #c9b79a, 0 14px 0 rgba(20, 12, 50, 0.3);
    animation: rise 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.card h2 { margin: 4px 0 18px; font-size: 32px; font-weight: 850; line-height: 1.05; }
.card .row { display: flex; justify-content: center; gap: 14px; margin-top: 6px; }
.card .chips { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.chip.gold { background: linear-gradient(#ffd75a, #ffa51f); box-shadow: 0 3px 0 #c9700b; text-shadow: 0 1px 0 rgba(150, 70, 0, 0.4); }
.card .sub { margin: -8px 0 14px; font-size: 16px; font-weight: 700; opacity: 0.65; display: flex; justify-content: center; align-items: center; gap: 6px; }
.card .sub[hidden] { display: none; }
.card .sub svg { width: 18px; height: 18px; fill: #20a650; }

.big { position: relative; width: 74px; height: 74px; }
.big svg { width: 33px; height: 33px; }
.big.plain { color: var(--ink); background: linear-gradient(#ffffff, #efe6f6); box-shadow: 0 5px 0 #b9a8cf, 0 8px 0 rgba(20, 12, 50, 0.22); }
.big.plain svg { filter: none; }
.big[hidden] { display: none; }
#daily-go { margin: 6px auto 0; }

.big .count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 13px;
    font-style: normal;
    font-size: 15px;
    font-weight: 850;
    line-height: 26px;
    color: #fff;
    background: var(--red);
    box-shadow: 0 0 0 3px #fff;
}

.close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(43, 33, 80, 0.08);
}

.close svg { width: 18px; height: 18px; fill: var(--ink); opacity: 0.7; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: -6px auto 14px;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 850;
    color: #fff;
    background: linear-gradient(#5aa8ff, #2f6cf0);
    box-shadow: 0 3px 0 #1d4bb0;
    animation: pop 0.5s 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.chip[hidden] { display: none; }
.chip svg { width: 20px; height: 20px; fill: currentColor; }

.streak { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.streak b { font-size: 26px; color: var(--red); margin-left: 4px; }

.stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: -64px 0 10px; }
.stars img { width: 74px; height: auto; filter: grayscale(1) brightness(0.55) opacity(0.5); }
.stars img:nth-child(2) { width: 96px; margin-bottom: 14px; }
.stars img.on { filter: drop-shadow(0 4px 0 rgba(150, 70, 0, 0.35)); animation: star 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.stars img.on:nth-child(2) { animation-delay: 0.18s; }
.stars img.on:nth-child(3) { animation-delay: 0.36s; }

@keyframes star { from { transform: scale(0) rotate(-40deg); } }
@keyframes pop { from { transform: scale(0); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px) scale(0.9); opacity: 0; } }

/* ---------------------------------------------------------------- settings */

.card.form { text-align: left; padding: 26px 22px 18px; }
.card.form h2 { text-align: center; }

.line {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    font-size: 18px;
    font-weight: 750;
}

.line > svg { width: 24px; height: 24px; fill: var(--ink); opacity: 0.75; flex: none; }
.line > span { flex: 1; }

.switch {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 54px;
    height: 32px;
    margin: 0;
    border-radius: 16px;
    background: #ddd2ec;
    transition: background 0.2s;
    cursor: pointer;
    flex: none;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 0 rgba(20, 12, 50, 0.2);
    transition: transform 0.2s;
}

.switch:checked { background: linear-gradient(#ffd75a, #ffa51f); }
.switch:checked::after { transform: translateX(22px); }

.form input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: calc(100% - 36px);
    margin: 0 0 8px 36px;
    height: 26px;
    background: none;
}

.form input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #ddd2ec; }
.form input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #ddd2ec; }
.form input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: linear-gradient(#ffd75a, #ffa51f); box-shadow: 0 2px 0 #c9700b; }
.form input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: linear-gradient(#ffd75a, #ffa51f); }
.form input[type="range"]:disabled { opacity: 0.35; }

.form select {
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    padding: 6px 30px 6px 12px;
    border: 0;
    border-radius: 12px;
    background: #efe6f6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%232b2150'/%3E%3C/svg%3E") right 10px center / 10px no-repeat;
    -webkit-appearance: none;
    appearance: none;
}

.credit { margin: 14px 0 0; text-align: center; font-size: 12px; font-weight: 600; opacity: 0.45; }
