:root {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
    color: #2a2328;
    background: #fff;
    color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; }
button {
    font: inherit;
    touch-action: manipulation;
    border: 0;
    border-radius: 8px;
    min-height: 44px;
    background: #f3f4f6;
    color: #2a2328;
    font-weight: 700;
}
button:disabled { opacity: .4; }
button:focus-visible { outline: 3px solid #936618; outline-offset: -3px; }
[hidden] { display: none !important; }
main {
    height: calc(100dvh - var(--nav-height, 52px));
    max-width: 450px;
    margin: auto;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    flex-direction: column;
}
#stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #102d3e;
    touch-action: none;
    user-select: none;
}
canvas, #targets { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    padding: 5px 8px;
    gap: 6px;
    background: #fff;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.hud b { font-size: 16px; }
.hud #remaining { color: #6e626a; white-space: nowrap; }
.hud button { pointer-events: auto; width: 44px; flex-shrink: 0; }
.weak {
    display: grid;
    place-items: center;
    position: absolute;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border: 2px solid #ffdc99;
    border-radius: 50%;
    background: #173e52;
    color: #ffe3ac;
    font-size: 23px;
    pointer-events: none;
    z-index: 1;
}
.weak.back {
    width: 56px;
    height: 56px;
    border-style: dashed;
    border-color: #8cddff;
    background: #19455c;
    color: #a4e8ff;
    z-index: 0;
}
.weak.urgent { border-color: #ff9a74; color: #ffbf9b; }
.weak.back.urgent { border-color: #8cddff; color: #a4e8ff; }
#feedback {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    color: #ffe1a3;
    font-size: 14px;
    font-weight: 700;
    pointer-events: none;
}
#overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    padding: 20px 16px;
    background: #fff;
}
.panel { width: 100%; max-width: 340px; text-align: center; }
.companion { display: flex; justify-content: center; align-items: center; gap: 10px; }
.portrait { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.cast { margin: 0; font-size: 13px; font-weight: 700; }
h2 { font-size: 20px; margin: 16px 0; }
.panel p { font-size: 13px; line-height: 1.7; }
#panel-reaction { margin: 0 0 12px; }
#description { margin: 0 0 12px; }
#summary { color: #6e626a; margin: 0 0 20px; }
.panel button { width: 100%; min-height: 48px; }
#best { font-size: 12px; color: #6e626a; margin: 14px 0 0; }
#storage { font-size: 11px; margin: 8px 0 0; color: #6e626a; }
#storage:empty, #summary:empty { display: none; }
.buddy { min-height: 60px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding: 6px 12px; }
main:has(#overlay:not([hidden])) .buddy { visibility: hidden; }
.buddy img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }
.buddy strong { display: block; font-size: 11px; margin-bottom: 3px; }
.buddy p { font-size: 12px; margin: 0; line-height: 1.5; }
@media (max-height: 620px) {
    #overlay { padding: 14px 16px; }
    h2 { font-size: 18px; margin: 12px 0; }
    #summary { margin-bottom: 14px; }
}
