/* Native Cursor Visibility by Pointer Type */
@media (pointer: fine) {

    html,
    body,
    a,
    button,
    [role="slider"] {
        cursor: none !important;
    }
}

@media (pointer: coarse) {
    .cursor {
        display: none;
    }
}

/* Mobile Layout Wrappers — 100% transparent on desktop (min-width: 769px) */
.mobile-hero,
.mobile-head-band,
.mobile-shelf-wrap,
.mobile-caption-row,
.mobile-status-stack {
    display: contents;
}

.top-category-bar .cat-sep {
    margin: 0 0.22em;
}

.mobile-about-trigger,
.mobile-open-hint {
    display: none;
}

.about-desc-body {
    margin-top: 1rem;
    padding-top: 1.125rem;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-family: var(--font-sans);
    font-size: 14.5px;
    line-height: 1.65;
    color: rgba(20, 20, 20, 0.78);
}

@media (max-width: 1120px) and (min-width: 769px) {
    .top-category-bar {
        font-size: 0.58rem;
        letter-spacing: 0.08em;
        padding: 4px 10px;
    }
}

/* Tablet Portrait (769px–1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .top-category-bar {
        top: 66px;
        transform: translateX(-50%);
    }

    .ambient-left-index {
        left: 1.4rem;
    }

    .ambient-right-telemetry {
        right: 1.4rem;
    }

    .ambient-left-incoming {
        left: 1.4rem;
        bottom: 92px;
    }

    .ambient-right-incoming {
        right: 1.4rem;
    }

    .ambient-right-stamp {
        right: 1.4rem;
        bottom: 84px;
    }

    .ambient-bottom-about {
        width: min(70vw, 620px);
        bottom: 12px;
        font-size: 11px;
    }

    .social-links {
        right: 1.4rem;
        bottom: 16px;
    }
}

@media (max-width: 900px) {
    .detail {
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .detail-grid {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        height: auto;
        max-height: none;
        min-height: 100%;
        padding: 84px 28px 52px;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 32px;
    }

    .detail-left {
        max-width: 100%;
    }

    .detail-plans,
    .detail-action-row {
        max-width: 100%;
    }

    .detail-right {
        order: -1;
        height: 44svh;
    }

    .detail-poster-svg {
        height: 44svh;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE VERTICAL / PORTRAIT LAYOUT (<= 768px) — Zero Desktop or Landscape Impact
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) and (orientation: portrait),
(max-width: 768px) and (min-height: 541px) {
    :root {
        --H: min(76vw, 43svh);
        --cy: 43%;
    }

    html {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        min-height: 100dvh;
        overscroll-behavior-x: none;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        overflow: visible;
        overflow-x: clip;
        height: auto;
        min-height: 100dvh;
        overscroll-behavior-x: none;
    }

    html:has(> body.is-detail-open),
    html:has(> body.is-dev-open),
    html:has(> body.is-terms-open),
    html:has(> body.is-about-open),
    body.is-detail-open,
    body.is-dev-open,
    body.is-terms-open,
    body.is-about-open {
        overflow: hidden;
    }

    body.is-about-open,
    body.is-about-open * {
        cursor: auto !important;
    }

    body.is-about-open button,
    body.is-about-open a {
        cursor: pointer !important;
    }

    /* 1. First Screen Clean Vertical Flex Flow */
    .mobile-hero {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        min-height: 100dvh;
        width: 100%;
        overflow-x: hidden;
    }

    /* 2. Single-Row Top Header (COASTNEX Left + Controls Right) + Category Strip Below */
    .mobile-head-band {
        order: 1;
        position: relative;
        z-index: 30;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        column-gap: 6px;
        width: 100%;
        padding-top: env(safe-area-inset-top);
    }

    .top-bar {
        display: contents;
    }

    .kanji,
    .kanji-left {
        grid-column: 1;
        grid-row: 1;
        position: static;
        left: auto;
        top: auto;
        padding: clamp(12px, 2svh, 20px) 0 10px clamp(8px, 2.8vw, 14px);
        font-size: clamp(21px, 6.8vw, 38px);
        letter-spacing: 0.01em;
        line-height: 1;
        opacity: 1;
        z-index: 31;
    }

    .top-nav {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        min-width: 0;
        margin-left: 0;
        padding: clamp(10px, 1.8svh, 18px) clamp(8px, 2.8vw, 14px) 10px 0;
        display: flex;
        align-items: center;
        gap: clamp(4px, 1.4vw, 8px);
        white-space: nowrap;
        pointer-events: auto;
        z-index: 31;
    }

    .dev-login-trigger {
        font-size: clamp(7.5px, 2.15vw, 10.5px);
        letter-spacing: 0.04em;
        padding: 5px clamp(5px, 1.5vw, 9px);
        min-height: 26px;
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
    }

    #dev-login-trigger,
    .burger-btn {
        display: none !important;
    }

    .mobile-about-trigger {
        display: inline-flex;
    }

    /* 3. Hide Noisy Desktop-Only Margin Overlays */
    .ambient-left-index,
    .ambient-right-telemetry,
    .ambient-right-stamp {
        display: none !important;
    }

    /* 4. Two-Row Centered Category Bar (2 on Row 1, 3 on Row 2) */
    .top-category-bar {
        grid-column: 1 / -1;
        grid-row: 2;
        position: static;
        left: auto;
        top: auto;
        transform: none;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        row-gap: 7px;
        column-gap: 10px;
        width: 100%;
        margin-top: clamp(14px, 2.2svh, 22px);
        padding: clamp(11px, 1.7svh, 16px) 14px;
        font-size: 0.64rem;
        letter-spacing: 0.08em;
        line-height: 1.25;
        white-space: nowrap;
        overflow: visible;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        pointer-events: none;
    }

    .top-category-bar span {
        flex-shrink: 0;
    }

    .top-category-bar .cat-sep {
        margin: 0;
        opacity: 0.45;
    }

    .top-category-bar> :nth-child(4) {
        flex-basis: 100%;
        height: 0;
        overflow: hidden;
        font-size: 0;
        line-height: 0;
    }

    /* 5. Centered 3D Shelf Stage + Compact Bottom-Left Play Button */
    .mobile-shelf-wrap {
        order: 3;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: calc(var(--H) + 44px);
        margin: 0 0 6px;
        overflow: hidden;
    }

    .floor-shadow {
        position: absolute;
        left: 50%;
        top: calc(50% + (var(--H) - 1cm) * 0.47);
        width: min(94vw, calc(var(--H) * 2.8));
        height: calc(var(--H) * 0.24);
    }

    .shelf {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    .play-ring {
        position: absolute !important;
        width: 36px;
        height: 36px;
        margin-left: 0;
        margin-top: 0;
        left: calc(50% - (var(--H) * 474 / 900) / 2 + 4px) !important;
        top: auto !important;
        bottom: calc(22px + 0.5cm - 2px) !important;
        border-width: 1.5px;
        box-shadow:
            0 5px 14px rgba(31, 63, 176, 0.36),
            0 0 0 3px rgba(31, 63, 176, 0.14);
    }

    .play-ring::after {
        inset: -3px;
        border-width: 1.5px;
    }

    .play-ring svg {
        width: 11px;
        height: 11px;
        transform: translateX(1px);
    }

    /* Active Brand Title + Arrows Row */
    .mobile-caption-row {
        order: 4;
        position: relative;
        z-index: 15;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin: 0 0 auto;
        padding: 0 16px;
        min-height: 54px;
    }

    .caption {
        position: static;
        left: auto;
        top: auto;
        transform: none;
        width: 100%;
        gap: 7px;
    }

    .caption-mask {
        width: 100%;
    }

    .mask-title {
        min-height: 32px;
        padding: 0 44px;
    }

    .mask-title>span {
        font-size: clamp(24px, 6.8vw, 30px);
    }

    .mask-sub {
        min-height: 14px;
    }

    .mask-sub>span {
        font-size: clamp(8.5px, 2.5vw, 10.5px);
        letter-spacing: 0.11em;
    }

    .nav-arrow {
        position: absolute;
        top: -5px;
        bottom: auto;
        transform: none;
        width: 44px;
        height: 44px;
    }

    .arrow-prev {
        left: 6px;
    }

    .arrow-next {
        left: auto;
        right: 6px;
    }

    /* 6. Clean Centered Micro-Status Badges (1000+ Orders Between Section List & Cuboids; Expanding at Bottom) */
    .mobile-status-stack {
        display: contents;
    }

    .ambient-right-incoming,
    .ambient-left-incoming {
        position: relative;
        z-index: 15;
        left: auto;
        right: auto;
        top: auto;
        bottom: auto;
        transform: none;
        width: 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 6px 0.35em;
        text-align: center;
    }

    .mobile-status-stack .ambient-incoming-text {
        flex-wrap: wrap;
        justify-content: center;
        white-space: normal;
    }

    .ambient-incoming-bar {
        display: none;
    }

    .ambient-incoming-row {
        gap: 7px;
    }

    .ambient-incoming-dot {
        width: 5px;
        height: 5px;
    }

    .ambient-right-incoming {
        order: 5;
        margin: 0;
        padding: 12px 16px 0;
    }

    .ambient-right-incoming .ambient-incoming-text {
        font-size: 0.62rem;
        letter-spacing: 0.1em;
    }

    .ambient-left-incoming {
        order: 2;
        margin: auto 0 0;
        padding: 12px 16px 0;
        opacity: 0.78;
    }

    .ambient-left-incoming .ambient-incoming-text {
        font-size: 0.6rem;
        letter-spacing: 0.08em;
    }

    .ambient-left-incoming .ambient-incoming-subline {
        padding-left: 0;
    }

    .mobile-open-hint {
        order: 6;
        display: block;
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: 15;
        width: 100%;
        margin-top: clamp(10px, 1.8svh, 18px);
        padding: 0 20px;
        font-family: var(--font-sans);
        font-size: 0.56rem;
        font-weight: 600;
        letter-spacing: 0.1em;
        line-height: 1.45;
        text-transform: uppercase;
        text-align: center;
        color: rgba(20, 20, 20, 0.52);
        pointer-events: none;
    }

    .social-links {
        order: 7;
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        transform: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-top: clamp(8px, 1.5svh, 16px);
        padding-bottom: calc(clamp(12px, 2.2svh, 24px) + env(safe-area-inset-bottom));
        gap: 14px;
    }

    /* Description moved into the mobile DESCRIPTION overlay */
    .ambient-bottom-about {
        display: none !important;
    }

    /* Dev Login & Developer Console Mobile Rules */
    .dev-login-view,
    .terms-view {
        align-items: flex-start;
        padding: 20px 16px max(28px, env(safe-area-inset-bottom));
    }

    .dev-login-card,
    .terms-card {
        margin: 0 auto;
        padding: 26px 20px;
    }

    .dev-login-heading,
    .terms-card .dev-login-heading {
        font-size: 25px;
    }

    .dev-login-desc {
        font-size: 13.5px;
        margin-bottom: 20px;
    }

    /* Prevent iOS Safari auto-zoom on mobile inputs (must be >= 16px) */
    .dev-input,
    .dev-textarea,
    .detail-coupon-input {
        font-size: 16px;
        min-height: 46px;
    }

    .dev-input-compact {
        height: 46px;
    }

    .dev-btn,
    .dev-btn-row-action {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .terms-list {
        font-size: 14px;
        line-height: 1.6;
        gap: 12px;
        margin-top: 1rem;
        padding-top: 1.125rem;
    }

    .dev-portal-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .dev-portal-brand {
        width: 100%;
        gap: 10px;
        flex-wrap: wrap;
    }

    .dev-portal-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .dev-portal-actions .dev-btn {
        font-size: 10px;
        padding: 8px 10px;
        min-height: 44px;
        width: 100%;
    }

    .dev-portal-actions .dev-btn-primary {
        grid-column: 1 / -1;
    }

    .dev-portal-title {
        font-size: 11px;
    }

    .dev-portal-badge {
        display: none;
    }

    .dev-main {
        padding: 18px 14px max(56px, env(safe-area-inset-bottom));
        gap: 18px;
    }

    .dev-brand-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .dev-plans-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .dev-plan-row,
    .dev-coupons-panel {
        padding: 14px;
    }

    .dev-brand-heading {
        font-size: 22px;
    }

    .dev-toast {
        left: 14px;
        right: 14px;
        bottom: max(14px, env(safe-area-inset-bottom));
        text-align: center;
    }

    /* Product Detail Mobile Rules */
    .detail-close {
        left: 16px;
        top: 18px;
        min-height: 36px;
        padding: 0 12px;
    }

    .detail-brand {
        right: 16px;
        top: 22px;
        height: 21px;
    }

    .detail-brand-logo {
        height: 21px;
    }

    .detail-grid {
        padding: 72px 16px max(48px, env(safe-area-inset-bottom));
        gap: 24px;
    }

    .detail-right {
        height: 40svh;
    }

    .detail-poster-svg {
        height: 40svh;
    }

    .detail-title {
        font-size: clamp(34px, 10vw, 44px);
    }

    .plan-card {
        padding: 14px;
        gap: 12px;
    }

    .plan-title {
        font-size: 16px;
    }

    .plan-specs {
        font-size: 10.5px;
        letter-spacing: 0.06em;
    }

    .plan-price {
        font-size: 14.5px;
        padding: 8px 11px;
    }

    .detail-action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
    }

    .detail-watch-btn {
        width: 100%;
        min-height: 50px;
        padding: 0 18px;
    }

    .detail-coupon-wrap {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .detail-coupon-input {
        height: 50px;
        padding: 0 92px 0 14px;
    }

    .cursor {
        display: none;
    }
}

/* Short Portrait Phones (<= 644px tall, e.g. 320x568 iPhone SE1 & 360x640 Android) */
@media (max-width: 768px) and (orientation: portrait) and (max-height: 644px) {
    :root {
        --H: min(74vw, 37svh);
    }

    .kanji,
    .kanji-left {
        padding-top: 8px;
        padding-bottom: 6px;
    }

    .top-nav {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .top-category-bar {
        margin-top: 6px;
        padding: 7px 10px;
        row-gap: 4px;
    }

    .ambient-left-incoming {
        padding-top: 6px;
    }

    .mobile-shelf-wrap {
        margin-bottom: 0;
    }

    .mobile-caption-row {
        min-height: 46px;
    }

    .mask-title {
        min-height: 26px;
    }

    .mask-title>span {
        font-size: clamp(21px, 6.2vw, 26px);
    }

    .ambient-right-incoming {
        padding-top: 6px;
    }

    .mobile-open-hint {
        margin-top: 6px;
    }

    .social-links {
        margin-top: 6px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    .social-link-btn {
        width: 28px;
        height: 28px;
    }
}

/* Compact Phones (<= 400px, e.g. 390x844 and 360x800) */
@media (max-width: 400px) {
    .plan-card {
        flex-wrap: wrap;
        gap: 10px;
    }

    .plan-price {
        margin-left: auto;
    }
}

/* ══════════════════════════════════════════════════════════════════
   HORIZONTAL / LANDSCAPE PHONE VIEW (max-height: 540px)
   Desktop-faithful fixed editorial layout scaled for short landscape viewports.
   Zero impact on desktop (height >= 541px) or mobile vertical (portrait).
   ══════════════════════════════════════════════════════════════════ */
@media (orientation: landscape) and (max-height: 540px) {
    :root {
        --H: clamp(142px, 46dvh, 210px);
        --cy: 41%;
    }

    .top-bar {
        height: 44px;
        padding: 0 18px;
    }

    .kanji,
    .kanji-left {
        left: 18px;
        top: 9px;
        font-size: clamp(20px, 3.2vw, 30px);
    }

    .top-nav {
        gap: 8px;
    }

    .dev-login-trigger {
        font-size: 0.54rem;
        letter-spacing: 0.1em;
        padding: 4px 8px;
    }

    .burger-btn {
        width: 20px;
        height: 10px;
    }

    .top-category-bar {
        top: 50%;
        transform: translate(-50%, -50%);
        font-size: 0.52rem;
        letter-spacing: 0.06em;
        padding: 3px 10px;
    }

    .top-category-bar .cat-sep {
        margin: 0 0.16em;
    }

    .play-ring {
        width: 28px;
        height: 28px;
        margin-left: -14px;
        margin-top: -14px;
        border-width: 1.5px;
        box-shadow:
            0 5px 14px rgba(31, 63, 176, 0.36),
            0 0 0 3px rgba(31, 63, 176, 0.14);
    }

    .play-ring::after {
        inset: -3px;
        border-width: 1.5px;
    }

    .play-ring svg {
        width: 9px;
        height: 9px;
        transform: translateX(1px);
    }

    .ambient-left-index {
        left: 18px;
        top: var(--cy);
    }

    .brand-index-coord-top,
    .brand-index-coord-bottom {
        display: none;
    }

    .brand-index-item {
        font-size: 0.5rem;
        letter-spacing: 0.08em;
        line-height: 1.55;
        gap: 4px;
    }

    .ambient-right-telemetry {
        right: 16px;
        top: 52px;
        font-size: 0.46rem;
        letter-spacing: 0.08em;
        line-height: 1.35;
    }

    .ambient-right-stamp {
        display: none;
    }

    .caption {
        top: calc(var(--cy) + (var(--H) - 1cm) * 0.5 + 10px);
        gap: 4px;
    }

    .mask-title {
        min-height: 24px;
    }

    .mask-title>span {
        font-size: clamp(19px, 2.7vw, 26px);
    }

    .mask-sub {
        min-height: 11px;
    }

    .mask-sub>span {
        font-size: clamp(7.5px, 1vw, 9.5px);
        letter-spacing: 0.14em;
    }

    .nav-arrow {
        top: calc(var(--cy) + (var(--H) - 1cm) * 0.5 + 10px + 12px - 18px);
        width: 36px;
        height: 36px;
    }

    .arrow-prev {
        left: calc(50% - min(17vw, 190px) - 18px);
    }

    .arrow-next {
        left: calc(50% + min(17vw, 190px) - 18px);
    }

    .ambient-left-incoming {
        left: 22px;
        top: calc(var(--cy) + (var(--H) - 1cm) * 0.5 + 10px);
        bottom: auto;
        gap: 3px;
    }

    .ambient-right-incoming {
        right: 16px;
        top: calc(var(--cy) + (var(--H) - 1cm) * 0.5 + 14px);
        bottom: auto;
        transform: none;
        gap: 4px;
    }

    .ambient-incoming-row {
        gap: 6px;
    }

    .ambient-incoming-dot {
        width: 4.5px;
        height: 4.5px;
    }

    .ambient-incoming-text,
    .ambient-left-incoming .ambient-incoming-text {
        font-size: clamp(7px, 0.85vw, 8.5px);
        letter-spacing: 0.08em;
    }

    .ambient-incoming-subline {
        padding-left: 10.5px;
    }

    .ambient-bottom-about {
        bottom: 8px;
        width: min(84vw, 720px);
        padding-top: 6px;
        font-size: clamp(7.5px, 0.95vw, 9.5px);
        line-height: 1.38;
    }

    .social-links {
        right: 14px;
        bottom: 8px;
        gap: 6px;
    }

    .social-link-btn {
        width: 24px;
        height: 24px;
    }

    .social-link-btn svg {
        width: 13px;
        height: 13px;
    }

    /* Desktop-like 2-column scrollable Detail Sheet & compact overlays in landscape */
    .detail {
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .detail-grid {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        height: auto;
        max-height: none;
        min-height: 100%;
        padding: 56px 28px 32px;
        grid-template-columns: 1.25fr 0.75fr;
        gap: 24px;
        align-items: center;
    }

    .detail-right {
        order: 0;
        height: auto;
    }

    .detail-poster-svg {
        height: min(64dvh, 230px);
        width: auto;
    }

    .detail-close {
        top: 14px;
        left: 20px;
    }

    .detail-brand {
        top: 16px;
        right: 20px;
    }

    .dev-portal-header {
        padding: 10px 18px;
    }

    .dev-login-view,
    .terms-view {
        align-items: flex-start;
        padding: 16px 20px 24px;
    }

    .dev-login-card,
    .terms-card {
        padding: 22px 24px;
    }

    .detail-coupon-input,
    .dev-input,
    .dev-textarea {
        font-size: 16px;
    }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 780px) {
    .top-category-bar {
        top: 44px;
        transform: translateX(-50%);
        font-size: 0.48rem;
        padding: 2px 8px;
    }

    .arrow-prev {
        left: calc(50% - 14.5vw - 18px);
    }

    .arrow-next {
        left: calc(50% + 14.5vw - 18px);
    }

    .ambient-right-incoming {
        right: 12px;
    }

    .ambient-right-incoming .ambient-incoming-text {
        font-size: 6.5px;
        letter-spacing: 0.05em;
    }
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 767px) {
    :root {
        --cy: 38.5%;
    }
}

@media (orientation: landscape) and (max-height: 305px) {
    .ambient-bottom-about {
        bottom: 4px;
        padding-top: 4px;
        font-size: 7px;
        line-height: 1.28;
    }
}