* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
    background: #fff;
    color: #2a2328;
    font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}
button {
    font: inherit;
    border: 0;
    border-radius: 8px;
    min-height: 44px;
    padding: 8px 12px;
    background: #f3f4f6;
    color: #2a2328;
    touch-action: manipulation;
    cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button:focus-visible { outline: 3px solid #c2477c; outline-offset: 2px; }
[hidden] { display: none !important; }
main {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 2px 8px calc(6px + env(safe-area-inset-bottom));
}

.companion { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 2px 0; }
.companion img { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; object-fit: cover; background: #fbeef4; }
.companion > div { flex: 1; min-width: 0; }
.companion strong { display: block; font-size: 11px; color: #6e626a; font-weight: 600; }
.companion p {
    margin: 1px 0 0;
    font-size: 13px;
    line-height: 1.4;
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
#pause { flex: 0 0 auto; min-width: 44px; padding: 8px 12px; font-weight: 700; }

#stage {
    position: relative;
    flex: 1;
    min-height: 360px;
    border-radius: 14px;
    overflow: hidden;
    isolation: isolate;
    background: #f8e6ef url("https://storage.googleapis.com/lenoas-assets/images/games/assets/fe-lenooshinui-room-v1.webp") center / cover no-repeat;
}
canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

/* Plush are drawn above the score panels so an aimed plush is never hidden. */
canvas { z-index: 1; }
.hud {
    position: absolute;
    z-index: 0;
    inset: 8px 10px auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}
.score-box, .next-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px 5px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .82);
    line-height: 1.15;
}
.score-box { align-items: flex-start; min-width: 84px; }
.score-box strong { font-size: 22px; font-variant-numeric: tabular-nums; color: #3a2a33; }
.hud small { font-size: 10px; color: #7a6873; }
.next-box img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; margin-top: 2px; background: #fbeef4; }
#danger {
    z-index: 2;
    position: absolute;
    left: 10px;
    right: 10px;
    top: 26%;
    margin: 0;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(255, 238, 244, .94);
    color: #b02a5a;
    font-size: 12px;
    text-align: center;
    pointer-events: none;
}

#overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    padding: 10px;
    background: rgba(255, 246, 250, .8);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.panel { margin: auto; width: 100%; max-width: 380px; text-align: center; padding: 6px 2px 10px; }
.panel h2 { margin: 2px 0 6px; font-size: 21px; }
#panelDetail { margin: 0 0 8px; font-size: 13px; line-height: 1.6; white-space: pre-line; }
#panelDetail strong { font-size: 30px; color: #c2386f; display: block; line-height: 1.2; font-variant-numeric: tabular-nums; }
.panel-label { margin: 8px 0 2px; font-size: 12px; font-weight: 700; text-align: left; color: #4a3a43; }
.panel-label small { font-weight: 400; color: #7a6873; margin-left: 4px; }
#cast-options.game-cast-portraits > button { background: #f5e8ef; }
#cast-options.game-cast-portraits > button > img { object-fit: cover; object-position: center 30%; }

.order-row {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    margin: 2px 0 6px;
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .78);
}
.order-row li { position: relative; display: grid; place-items: center; }
.order-row img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; background: #fbeef4; }
.order-row li:last-child img { width: 34px; height: 34px; box-shadow: 0 0 0 2px #f2c14e; }
.order-row li:last-child::before { content: "♛"; position: absolute; top: -12px; font-size: 12px; color: #d9a52f; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
#go {
    min-width: 200px;
    padding: 12px 22px;
    background: #d6457f;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}
.ranking-slot:empty { display: none; }
.ranking-slot { margin-top: 8px; display: flex; justify-content: center; }

.shelf {
    list-style: none;
    margin: 4px 0 0;
    padding: 6px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .7);
}
.shelf li { position: relative; aspect-ratio: 1; display: grid; place-items: center; }
.shelf img { width: 100%; height: 100%; object-fit: contain; }
.shelf li.locked img { filter: grayscale(1) brightness(1.25); opacity: .35; }
.shelf li.locked::after { content: "?"; position: absolute; font-weight: 800; color: #b59aa8; font-size: 18px; }
.shelf li span { position: absolute; bottom: 0; right: 0; min-width: 18px; padding: 0 4px; border-radius: 9px; background: #d6457f; color: #fff; font-size: 10px; line-height: 16px; }
#shelfCount { font-weight: 400; color: #7a6873; }

#reward {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(255, 236, 245, .72);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.reward-card {
    width: 100%;
    max-width: 300px;
    padding: 16px 14px 14px;
    border-radius: 16px;
    background: #fff;
    text-align: center;
    box-shadow: 0 10px 30px rgba(190, 80, 130, .25);
    animation: reward-in .45s ease-out;
}
.reward-card img { width: 168px; height: 168px; object-fit: contain; animation: reward-bob 2.4s ease-in-out infinite; }
.reward-card h2 { margin: 6px 0 4px; font-size: 18px; color: #c2386f; }
.reward-card p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.6; white-space: pre-line; color: #5a4a53; }
#rewardClose { min-width: 160px; background: #d6457f; color: #fff; font-weight: 700; }
@keyframes reward-in { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes reward-bob { 50% { transform: translateY(-6px) rotate(-2deg); } }

.controls { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
#hug {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 108px;
    padding: 6px 12px;
    font-weight: 700;
    background: #f3f4f6;
}
#hug.ready { background: #d6457f; color: #fff; opacity: 1; animation: hug-pulse 1.2s ease-in-out infinite; }
.gauge { position: relative; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; background: #e9dce3; -webkit-mask: radial-gradient(circle, #000 64%, transparent 66%); }
.gauge i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: #ff6f9f; }
#hug.ready .gauge i { background: #fff; }
.guide { flex: 1; min-width: 0; font-size: 10.5px; line-height: 1.35; color: #7a6873; }
#help { flex: 0 0 auto; padding: 8px 10px; font-size: 12px; }
@keyframes hug-pulse { 50% { transform: scale(1.05); } }
#saveNote { margin: 4px 0 0; font-size: 11px; color: #b02a5a; }

dialog { width: min(92vw, 400px); max-height: 82svh; border: 0; border-radius: 12px; padding: 16px; color: #2a2328; }
dialog::backdrop { background: rgba(42, 35, 40, .45); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog p { margin: 0 0 10px; font-size: 13px; line-height: 1.7; }
dialog .reduce { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; }
dialog .reduce input { width: 18px; height: 18px; accent-color: #d6457f; }
#helpClose { width: 100%; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
    .reward-card, .reward-card img, #hug.ready { animation: none; }
}
body.reduced .reward-card, body.reduced .reward-card img, body.reduced #hug.ready { animation: none; }
