:root {
    --app-height: 100vh;
    --card-height: 92vh;
    --canvas-pad: 50vh;
    --canvas-anchor: 50vh;
    --scene-bleed: max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px));
    --sheet-bleed: 0px;
    --browser-bottom-occlusion: 0px;
    --sheet-bottom-clearance: calc(32px + env(safe-area-inset-bottom, 0px) + var(--browser-bottom-occlusion));
    --ink: #202732;
    --muted: #737d87;
    --surface: 253, 251, 246;
    --row: 255, 255, 255;
    --line: rgba(112, 120, 123, 0.13);
    --focus: #487d97;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    color-scheme: light;
    font-family: 'Plus Jakarta Sans', 'Noto Sans JP', sans-serif;
    -webkit-font-smoothing: antialiased;
}

@supports (height: 100lvh) {
    :root {
        --app-height: 100lvh;
        --card-height: 92lvh;
        --scene-bleed: max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px), calc(var(--app-height) - 100svh));
    }
}

* { box-sizing: border-box; }

html, body {
    width: 100%;
    margin: 0;
    background: #fdfbf6;
    overscroll-behavior: none;
}

html { scroll-behavior: auto; }

body {
    /* The document has painted room beyond both browser bars. Gestures stay
       in #card-content; ViewportCanvas holds this outer canvas in place. */
    height: calc(var(--app-height) + 2 * var(--canvas-pad));
    color: var(--ink);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button, img { -webkit-user-select: none; user-select: none; }
button { cursor: pointer; }
img { display: block; }

#app-shell {
    position: absolute;
    top: var(--canvas-anchor);
    width: 100%;
    height: var(--app-height);
    touch-action: pinch-zoom;
}

[data-viewport-zoomed] #app-shell { touch-action: pan-x pan-y pinch-zoom; }

#backdrop {
    position: absolute;
    inset: calc(-1 * var(--scene-bleed)) 0;
    background: url('miharashidai.jpg') center / cover no-repeat;
    pointer-events: none;
}

#sheet-stage {
    /* Extend real sheet pixels below the layout viewport, rather than tinting
       the browser chrome with the document's background color. */
    position: absolute;
    inset: 0;
    height: calc(var(--app-height) + var(--sheet-bleed));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

#card {
    --sheet-y: 0px;
    --shade-top: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(var(--card-height) + var(--sheet-bleed));
    overflow: hidden;
    isolation: isolate;
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-bottom: 0;
    border-radius: 26px 26px 0 0;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.91), rgba(var(--surface), 0.81));
    box-shadow: 0 -4px 28px rgba(42, 51, 45, 0.09);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    transform: translate3d(0, var(--sheet-y), 0);
    pointer-events: auto;
    touch-action: pan-y pinch-zoom;
}

#card.is-settling {
    will-change: transform;
    transition: transform var(--snap-duration, 360ms) var(--ease);
}

#card[data-state='dragging'] { will-change: transform; }
.is-entering { animation: surface-in 420ms ease-out both; }

#card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 18px;
    left: 18px;
    z-index: 3;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.92), transparent);
    pointer-events: none;
}

#handle {
    display: flex;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
}

#handle:active, #card[data-state='dragging'] #handle { cursor: grabbing; }

#handle-bar {
    width: 46px;
    height: 5px;
    border-radius: 10px;
    background: rgba(122, 133, 139, 0.28);
    transition: background-color 180ms ease, width 180ms var(--ease);
}

#handle:active #handle-bar { width: 54px; background: rgba(122, 133, 139, 0.48); }
.handle-hint { animation: handle-hint 2100ms ease-in-out 900ms 3; }

#card-content {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 24px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-y pinch-zoom;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /* Fade rows beneath the handle into the actual glass surface. */
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 calc(var(--shade-top) * 28px), #000 100%);
    mask-image: linear-gradient(to bottom, transparent, #000 calc(var(--shade-top) * 28px), #000 100%);
}

#card-content::-webkit-scrollbar { width: 0; }
.card-inner { width: 100%; max-width: 432px; margin: 0 auto; padding-bottom: var(--sheet-bottom-clearance); }

#header-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 26px;
    text-align: center;
    touch-action: pan-y pinch-zoom;
}

.profile-avatar {
    width: 112px;
    height: 112px;
    border: 4px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 6px 16px rgba(47, 52, 40, 0.13), 0 1px 3px rgba(47, 52, 40, 0.08);
}

h1 { margin: 20px 0 0; font-size: 25px; font-weight: 800; line-height: 32px; letter-spacing: -0.9px; }
.profile-motto { margin: 8px 0 0; color: #46515d; font-size: 14px; font-weight: 500; line-height: 24px; }
.profile-affiliation { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 21px; }

.is-entering #header-info > * { animation: content-in 460ms var(--ease) both; }
.is-entering #header-info > :nth-child(2) { animation-delay: 45ms; }
.is-entering #header-info > :nth-child(3) { animation-delay: 80ms; }
.is-entering #header-info > :nth-child(4) { animation-delay: 110ms; }

#profile-links { margin-top: 14px; }
.link-group { display: grid; gap: 14px; }
.link-group + .link-group { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.link-group:last-child { margin-top: 24px; }

.link-card {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: 82px;
    padding: 16px;
    border: 1px solid rgba(var(--row), 0.64);
    border-radius: 17px;
    background: rgba(var(--row), 0.63);
    color: var(--ink);
    text-align: left;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(46, 55, 47, 0.035);
    transition: background-color 180ms ease, border-color 180ms ease;
    touch-action: pan-y pinch-zoom;
}

.card-icon {
    display: flex;
    flex: 0 0 48px;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 14px;
    background: var(--icon-bg);
    color: var(--accent);
    transition: transform 200ms var(--ease);
}

.card-icon > .fa-brands { font-size: 22px; }
.card-icon > .material-symbols-outlined { font-size: 24px; }
.filled-icon { font-variation-settings: 'FILL' 1; }
.icon-twitter { --accent: #3693eb; --icon-bg: #edf5ff; }
.icon-telegram, .icon-bilibili { --accent: #08a5dc; --icon-bg: #edfaff; }
.icon-rednote, .icon-youtube { --accent: #f04450; --icon-bg: #fff1f1; }
.icon-discord { --accent: #6366df; --icon-bg: #f0f0fe; }
.icon-qq { --accent: #313941; --icon-bg: #eff1f3; }
.game-icon { border-radius: 50%; background: #e9eceb; }
.game-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-label { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 700; line-height: 22px; }
.card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.card-subtitle { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 19px; }
.row-arrow { width: 19px; height: 19px; margin-left: auto; color: #99a2aa; font-size: 19px; line-height: 1; transition: transform 180ms var(--ease), color 180ms ease; }

.copy-state { position: relative; flex: 0 0 22px; width: 22px; height: 22px; margin-left: auto; color: #99a2aa; }
.copy-state .material-symbols-outlined { position: absolute; inset: 0; width: 22px; height: 22px; font-size: 22px; line-height: 1; transition: opacity 160ms ease, transform 240ms var(--ease); }
.check-glyph { color: #2c9b6b; opacity: 0; transform: scale(0.65); }
.link-card[data-copied] .copy-glyph { opacity: 0; transform: scale(0.7); }
.link-card[data-copied] .check-glyph { opacity: 1; transform: scale(1); }

.active-badge { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 5px; padding: 2px 7px; border: 1px solid rgba(43, 154, 101, 0.19); border-radius: 20px; background: rgba(43, 154, 101, 0.08); color: #288b5a; font-size: 10px; font-weight: 500; line-height: 16px; letter-spacing: 0.01em; }
.active-dot { position: relative; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.active-dot::before { content: ''; position: absolute; inset: -3px; border: 1px solid currentColor; border-radius: inherit; opacity: 0; }
.active-badge.is-visible .active-dot::before { animation: status-pulse 2600ms ease-out infinite; }

#toast {
    position: absolute;
    top: max(24px, env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    padding: 11px 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 24px;
    background: rgba(33, 43, 48, 0.93);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    box-shadow: 0 6px 20px rgba(25, 35, 40, 0.14);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translate(-50%, -8px);
    transition: opacity 180ms ease, transform 240ms var(--ease);
    pointer-events: none;
}

#toast[data-visible] { opacity: 1; transform: translate(-50%, 0); }
#toast .toast-icon { font-size: 17px; line-height: 1; }
#toast[data-error] .toast-icon { display: none; }
a:focus-visible, button:focus-visible, #card-content:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
#handle:focus-visible, #card-content:focus-visible { outline-offset: -6px; }

@media (hover: hover) and (pointer: fine) {
    .link-card:hover { border-color: rgba(var(--row), 0.95); background: rgba(var(--row), 0.9); }
    .link-card:hover .card-icon { transform: scale(1.055); }
    .link-card:hover .row-arrow { color: #647780; transform: translateX(2px); }
    #handle:hover #handle-bar { background: rgba(122, 133, 139, 0.42); }
}

.link-card:active { background: rgba(var(--row), 0.94); transition-duration: 80ms; }
.link-card[data-copied] { border-color: rgba(44, 155, 107, 0.25); background: rgba(var(--row), 0.84); }

@media (max-width: 767px) {
    :root { --sheet-bleed: var(--canvas-pad); }
    /* Cover the extra sampling strip above Safari's status bar. */
    #backdrop { top: calc(-1 * (var(--scene-bleed) + 32px)); }
    #card[data-content-visible='false'] #profile-links { opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity 120ms ease, transform 160ms ease, visibility 0s 160ms; }
    #profile-links { opacity: 1; visibility: visible; transform: translateY(0); transition: opacity 220ms ease 50ms, transform 300ms var(--ease) 50ms, visibility 0s; }
}

@media (min-width: 768px) {
    #backdrop { background-image: url('miharashidai_landscape.jpg'); }
    #sheet-stage { align-items: center; padding: 32px 0; }
    #card { width: 480px; height: auto; max-height: 85vh; max-height: 85dvh; border-bottom: 1px solid rgba(255, 255, 255, 0.62); border-radius: 26px; box-shadow: 0 18px 60px rgba(34, 49, 42, 0.16), 0 2px 8px rgba(34, 49, 42, 0.04); transform: none; }
    #handle { display: none; }
    #card-content { padding-top: 36px; scrollbar-width: thin; scrollbar-color: rgba(100, 114, 116, 0.25) transparent; }
    #card-content::-webkit-scrollbar { width: 4px; }
    #card-content::-webkit-scrollbar-thumb { border-radius: 4px; background: rgba(100, 114, 116, 0.25); }
    #card-content::-webkit-scrollbar-track { margin: 24px 0; }
    .card-inner { padding-bottom: 28px; }
    .is-entering .link-group { animation: content-in 440ms var(--ease) 120ms both; }
    .is-entering .link-group:nth-child(2) { animation-delay: 160ms; }
    .is-entering .link-group:nth-child(3) { animation-delay: 200ms; }
}

@media (max-width: 767px) and (max-height: 480px) {
    :root { --card-height: calc(var(--app-height) - 20px); }
    #handle { display: none; }
    #card-content { padding-top: 22px; }
}

[data-page-hidden] *, [data-page-hidden] *::before { animation-play-state: paused !important; }

@keyframes surface-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes content-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes handle-hint { 0%, 30%, 100% { transform: translateY(0); } 15% { transform: translateY(-4px); } }
@keyframes status-pulse { 0% { transform: scale(0.5); opacity: 0.45; } 65%, 100% { transform: scale(1.4); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
