:root {
    --pink: #ff488a;
    --pink-soft: rgba(255, 72, 138, 0.18);
    --ink: #fff7fa;
    --muted: rgba(255, 240, 246, 0.72);
    --faint: rgba(255, 240, 246, 0.48);
    --glass: rgba(26, 10, 18, 0.46);
    --glass-strong: rgba(22, 8, 15, 0.78);
    --line: rgba(255, 255, 255, 0.16);
    --ok: #7dffb3;
    --warn: #ffd166;
    --font: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #1a0b11;
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.mono { font-family: var(--mono); font-feature-settings: "tnum"; }

button { font: inherit; color: inherit; cursor: pointer; }

a { color: var(--pink); }

/* ---------- 桃（静的な背景と WebGL の川） ---------- */
.peach-static {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1.2s ease;
}
.peach-static.next { opacity: 0; }

#river {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    transition: opacity 0.9s ease;
    touch-action: none;
}
body.gl #river { opacity: 1; }

/* ---------- 共通のガラス ---------- */
.status-pill, .round, .dashboard, .toast, .catch-sub, .narration {
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
}

/* ---------- ロゴ ---------- */
.brand {
    position: fixed;
    top: calc(16px + var(--safe-t));
    left: calc(18px + var(--safe-l));
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--glass);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    backdrop-filter: blur(14px) saturate(1.3);
}
.wordmark {
    pointer-events: auto;
    font-family: var(--mono);
    font-weight: 500;
    font-size: 22px;
    letter-spacing: -0.02em;
    color: #fff;
    text-decoration: none;
}
.ver {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px 2px;
    border-radius: 5px;
    background: var(--pink);
    color: #fff;
    font-size: 12px;
    vertical-align: 5px;
    text-shadow: none;
    box-shadow: 0 4px 16px -4px rgba(255, 72, 138, 0.9);
}
.brand .tagline {
    margin: 0;
    padding-left: 12px;
    border-left: 1px solid var(--line);
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
}

/* ---------- ステータス ---------- */
.status-pill {
    position: fixed;
    top: calc(18px + var(--safe-t));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--glass);
    font-size: 12px;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s;
}
.status-pill:hover { background: var(--glass-strong); border-color: rgba(255, 255, 255, 0.28); }
.status-pill .sep { color: var(--faint); }
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warn);
    box-shadow: 0 0 0 0 rgba(125, 255, 179, 0.6);
}
.dot.ok { background: var(--ok); animation: pulse 2.4s ease-out infinite; }
.dot.off { background: #ff6b6b; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(125, 255, 179, 0.55); }
    70% { box-shadow: 0 0 0 9px rgba(125, 255, 179, 0); }
    100% { box-shadow: 0 0 0 0 rgba(125, 255, 179, 0); }
}

/* ---------- 右上の操作 ---------- */
.corner {
    position: fixed;
    top: calc(16px + var(--safe-t));
    right: calc(18px + var(--safe-r));
    z-index: 10;
    display: flex;
    gap: 8px;
}
.round {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--glass);
    display: grid;
    place-items: center;
    padding: 0;
    font-family: var(--mono);
    font-size: 16px;
    transition: background-color 0.2s, transform 0.1s;
}
.round:hover { background: var(--glass-strong); }
.round:active { transform: scale(0.94); }
.round.small { width: 32px; height: 32px; font-size: 18px; }
.round.pill-link {
    width: auto;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    color: #fff;
    text-decoration: none;
}
.round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round svg .spk { fill: currentColor; stroke: none; }
#btn-sound .wave { display: none; }
#btn-sound[aria-pressed="true"] .wave { display: block; }
#btn-sound[aria-pressed="true"] .mute { display: none; }

:focus-visible { outline: 2px solid var(--pink); outline-offset: 3px; }

/* ---------- ダッシュボード ---------- */
.dashboard {
    position: fixed;
    z-index: 20;
    top: calc(64px + var(--safe-t));
    left: 50%;
    translate: -50% 0;
    width: min(420px, calc(100vw - 36px));
    max-height: calc(100dvh - 64px - 150px - var(--safe-t) - var(--safe-b));
    overflow-y: auto;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--glass-strong);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
    animation: slide-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    scrollbar-width: thin;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(-10px); } }

.dash-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.dash-kicker { margin: 0; font-size: 10px; letter-spacing: 0.18em; color: var(--pink); }
.dash-head h2 { margin: 2px 0 0; font-size: 18px; font-weight: 700; }

.card {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 10px;
}
.card h3 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.card h3 .en { font-size: 10px; letter-spacing: 0.14em; color: var(--pink); }
.card dl { margin: 0; display: grid; gap: 4px; }
.card dl > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.card dt { color: var(--faint); font-size: 12px; white-space: nowrap; }
.card dd { margin: 0; text-align: right; font-size: 12.5px; overflow-wrap: anywhere; }
.card dd.big { font-size: 16px; color: #fff; }
.card dd.small-text { font-size: 11px; color: var(--muted); }

.blocks {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
    font-size: 11px;
}
.blocks li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    padding: 7px 9px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.22);
}
.blocks .h { font-family: var(--mono); color: var(--pink); grid-row: span 2; align-self: center; }
.blocks .who { color: var(--ink); }
.blocks .hash { font-family: var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blocks li.fresh { animation: fresh 1.4s ease; }
@keyframes fresh { from { background: rgba(255, 72, 138, 0.45); } }

.waste { background: linear-gradient(160deg, rgba(255, 72, 138, 0.16), rgba(255, 255, 255, 0.03)); }
.waste-number { margin: 2px 0 0; font-size: 26px; color: #fff; letter-spacing: -0.02em; }
.waste-caption { margin: 0 0 8px; font-size: 11px; color: var(--muted); }

.dash-foot { font-size: 11.5px; color: var(--muted); padding: 4px 2px 0; }
.dash-foot p { margin: 6px 0; }

/* ---------- 語り ---------- */
.narration {
    position: fixed;
    z-index: 5;
    left: calc(24px + var(--safe-l));
    bottom: calc(26px + var(--safe-b));
    max-width: min(560px, calc(100vw - 300px));
    margin: 0;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--glass);
    font-size: 16px;
    line-height: 1.7;
    font-weight: 500;
    color: #fff;
    pointer-events: none;
    transition: opacity 1s ease;
}
.narration:empty { display: none; }
.narration small { display: block; margin-top: 2px; font-size: 11.5px; font-family: var(--mono); color: var(--muted); font-weight: 400; }
.narration.fade { opacity: 0; }

/* ---------- 桃を拾う ---------- */
.catch {
    position: fixed;
    z-index: 6;
    right: calc(22px + var(--safe-r));
    bottom: calc(22px + var(--safe-b));
    display: grid;
    justify-items: end;
    gap: 8px;
}
.hash-stream {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 10.5px;
    line-height: 1.5;
    color: var(--ok);
    text-align: right;
    border-radius: 8px;
    background: transparent;
    min-height: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.7);
}
.hash-stream li { opacity: 0.85; white-space: nowrap; }
.hash-stream li:nth-child(n + 4) { opacity: 0.5; }
.hash-stream li:nth-child(n + 6) { opacity: 0.25; }

.catch-btn {
    position: relative;
    border: 0;
    border-radius: 999px;
    padding: 14px 24px;
    min-width: 200px;
    background: var(--pink);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow: 0 12px 34px -10px rgba(255, 72, 138, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    overflow: hidden;
    transition: transform 0.12s, box-shadow 0.2s, background-color 0.2s, opacity 0.2s;
}
.catch-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 40px -10px rgba(255, 72, 138, 1), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.catch-btn:active:not(:disabled) { transform: scale(0.97); }
.catch-btn:disabled { cursor: default; background: rgba(40, 18, 28, 0.72); box-shadow: none; color: var(--muted); }
.catch-btn.mining { background: #2a0f1c; color: #fff; }
.catch-btn.mining::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 72, 138, 0.55), transparent);
    transform: translateX(-100%);
    animation: sweep 1.1s linear infinite;
}
@keyframes sweep { to { transform: translateX(100%); } }
.catch-label { position: relative; }

.catch-sub {
    margin: 0;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 10.5px;
    color: var(--muted);
    background: var(--glass);
}

/* ---------- 他のおばあさんの気配 ---------- */
.remote-labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.remote-label {
    position: absolute;
    transform: translate(-50%, -140%);
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(26, 10, 18, 0.62);
    font-size: 11px;
    white-space: nowrap;
    color: #fff;
    animation: float-up 1.8s ease-out forwards;
}
@keyframes float-up {
    0% { opacity: 0; transform: translate(-50%, -110%); }
    15% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -260%); }
}

/* ---------- 通知 ---------- */
.toasts {
    position: fixed;
    z-index: 30;
    top: calc(66px + var(--safe-t));
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    width: min(440px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--glass-strong);
    font-size: 13px;
    line-height: 1.55;
    animation: toast-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.win { border-color: rgba(255, 72, 138, 0.7); box-shadow: 0 10px 40px -12px rgba(255, 72, 138, 0.9); }
.toast.leave { opacity: 0; transform: translateY(-6px); transition: opacity 0.4s, transform 0.4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- 情報 ---------- */
.info {
    border: 0;
    padding: 0;
    background: transparent;
    color: #2b1520;
    width: min(420px, calc(100vw - 32px));
}
.info::backdrop { background: rgba(20, 6, 12, 0.5); backdrop-filter: blur(4px); }
.info-card {
    position: relative;
    padding: 24px 22px 20px;
    border-radius: 18px;
    background: #fff7fa;
    font-size: 13px;
    line-height: 1.7;
}
.info-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--pink); }
.info-card p { margin: 0 0 8px; }
.info-lead { color: #6b4a58; }
.info-close { position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, 0.06); border-color: transparent; color: #2b1520; }
.copy-row { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: #f3e6ec; }
.copy-row span { flex: 1; overflow-wrap: anywhere; font-size: 12px; }
.copy-row button { border: 0; border-radius: 6px; padding: 6px 12px; background: var(--pink); color: #fff; font-size: 12px; }
.copy-feedback { min-height: 1.4em; font-size: 11px; color: #1c8a4b; }
.info-tools { margin-top: 6px !important; padding-top: 10px; border-top: 1px solid #efdbe4; }
.info-device { margin: 8px 0 4px; padding: 8px 10px; border-radius: 10px; background: #f6ebf0; font-size: 12px; }
.info-device summary { cursor: pointer; font-weight: 700; color: #6b4a58; }
.info-device ul { margin: 6px 0 0; padding-left: 1.2em; line-height: 1.65; color: #4a3340; }
.card-note { margin: 8px 0 0; font-size: 11px; color: var(--faint); }

/* ---------- スマートフォン ---------- */
@media (max-width: 1000px) {
    .brand .tagline { display: none; }
}

@media (max-width: 760px) {
    .brand .tagline { display: none; }
    .wordmark { font-size: 18px; }
    .status-pill {
        top: auto;
        bottom: calc(96px + var(--safe-b));
        font-size: 11px;
        padding: 7px 12px;
        gap: 6px;
        max-width: calc(100vw - 24px);
    }
    .narration {
        left: 16px;
        right: 16px;
        max-width: none;
        top: calc(64px + var(--safe-t));
        bottom: auto;
        font-size: 15px;
    }
    .catch { left: 16px; right: 16px; justify-items: center; bottom: calc(18px + var(--safe-b)); }
    .catch-btn { width: 100%; }
    .catch-sub { display: none; }
    .hash-stream { display: none; }
    .dashboard {
        top: auto;
        left: 10px;
        right: 10px;
        translate: none;
        width: auto;
        bottom: calc(82px + var(--safe-b));
        max-height: calc(100dvh - 150px - var(--safe-t) - var(--safe-b));
        animation-name: sheet-in;
    }
    .toasts { top: auto; bottom: calc(150px + var(--safe-b)); }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
