:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --accent: #a5b4fc;
    --white: #ffffff;
    --bg-gradient: radial-gradient(circle at top left, rgba(125, 211, 252, 0.12), transparent 20%), linear-gradient(135deg, #172554 0%, #312e81 45%, #6d28d9 100%);
    --glass: rgba(255, 255, 255, 0.1);
    --glass-heavy: rgba(255, 255, 255, 0.16);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-muted: rgba(255, 255, 255, 0.75);
    --card-shadow: 0 18px 42px rgba(8, 15, 37, 0.34);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-gradient);
    color: var(--white);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 18px;
    padding-top: max(18px, env(safe-area-inset-top, 0px));
    overflow-x: hidden;
}

#main-content,
.card,
.overlay,
.overlay-content {
    max-width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px 18px;
    backdrop-filter: blur(14px);
    box-shadow: var(--card-shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.logo {
    margin: 0;
    font-size: clamp(1.35rem, 4.2vw, 1.85rem);
    font-weight: 900;
    letter-spacing: -1.5px;
    cursor: pointer;
    color: #ffffff;
}

.logo span { color: #facc15; }

.route-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.25);
    border: 1px solid var(--glass-border);
    min-height: 32px;
    display: inline-flex;
    align-items: center;
}

.lang-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.14);
}

#langSelect {
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.12);
    color: var(--white);
    padding: 8px 10px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 1rem;
    max-width: min(200px, 46vw);
}

#langSelect option { color: #111827; }

main {
    padding-top: 18px;
    display: grid;
    gap: 14px;
    min-width: 0;
}

.card {
    min-width: 0;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: clamp(14px, 3.5vw, 18px);
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(16px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-title {
    margin: 0 0 12px;
    font-size: 1.08rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header .card-title {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #312e81;
    background: rgba(224, 231, 255, 0.92);
    padding: 4px 8px;
    border-radius: 999px;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 900px) {
    .app-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 380px) {
    .app-grid {
        gap: 8px;
    }

    .app-item {
        padding: 12px 8px;
    }

    .icon-box {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .app-item span {
        font-size: 0.78rem;
    }

    .app-item {
        min-height: 110px;
    }

    .app-soon-badge {
        top: 6px;
        right: 6px;
        font-size: 0.62rem;
        padding: 3px 7px;
    }
}

.app-item {
    text-decoration: none;
    color: var(--white);
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.08));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 14px 10px;
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    width: 100%;
    min-width: 0;
    position: relative;
    overflow: hidden;
    min-height: 116px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.app-item:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.45);
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.1));
}

.app-item.app-item--disabled,
.app-item:disabled {
    opacity: 0.9;
    cursor: not-allowed;
    filter: grayscale(0.15);
    pointer-events: none;
}

.app-item.app-item--disabled:hover,
.app-item:disabled:hover {
    transform: none;
    border-color: var(--glass-border);
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.08));
}

.app-item.app-item--disabled::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
}

.app-disabled-cover {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background:
        repeating-linear-gradient(
            135deg,
            rgba(15, 23, 42, 0.8) 0 10px,
            rgba(15, 23, 42, 0.68) 10px 20px
        );
    color: #f8fafc;
}

.app-disabled-cover i {
    font-size: 1rem;
}

.app-disabled-cover strong {
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.icon-box {
    width: 46px;
    height: 46px;
    margin: 0 auto 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.app-item span { font-size: 0.84rem; font-weight: 700; }

.app-soon-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #f8fafc;
    background: rgba(30, 41, 59, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.28);
    white-space: nowrap;
}

.app-item.app-item--disabled .icon-box,
.app-item.app-item--disabled span {
    position: relative;
    z-index: 1;
}

.btn-primary {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 13px 14px;
    font-weight: 800;
    cursor: pointer;
    color: #1e1b4b;
    background: linear-gradient(135deg, #e0e7ff, #c4b5fd);
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.18);
}

.desc-text {
    margin: 10px 0 0;
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.survival-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
    gap: 12px;
    min-width: 0;
}

.survival-item {
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.18);
    color: var(--white);
    border-radius: 14px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: transform 0.18s ease, border-color 0.18s ease;
}

.survival-item:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.34);
}

.survival-item.highlight { border-color: rgba(191, 219, 254, 0.85); }

.survival-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.survival-local {
    font-size: 0.95rem;
    font-weight: 800;
}

.survival-local--primary {
    font-size: 1rem;
    line-height: 1.35;
    word-break: break-word;
}

.survival-subwrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 2px;
}

.survival-local--sub {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(253, 224, 71, 0.95);
    line-height: 1.4;
    word-break: break-word;
}

.survival-title {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.68);
}

.survival-title--primary {
    margin-top: 2px;
}

.survival-title--sub {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.52);
    line-height: 1.35;
    word-break: break-word;
}

.sos-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 10px;
    align-items: stretch;
}

.btn-sos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    line-height: 1.25;
    font-size: 0.88rem;
    text-decoration: none;
    text-align: center;
    border-radius: 14px;
    padding: 12px 12px;
    font-weight: 800;
    color: var(--white);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.btn-red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn-blue { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.btn-dark { background: linear-gradient(135deg, #1f2937, #111827); }

footer {
    padding: 18px 4px 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
}

.btn-contact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    color: #1e1b4b;
    background: linear-gradient(135deg, #e0e7ff, #c4b5fd);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.22);
}

.version { opacity: 0.8; }

.overlay {
    position: fixed;
    inset: 0;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
    background: rgba(15, 23, 42, 0.66);
    backdrop-filter: blur(6px);
    display: none;
    flex-direction: column;
    z-index: 999;
    min-height: 100dvh;
    overflow-x: hidden;
}

.overlay.active { display: flex; }

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    flex-shrink: 0;
    min-height: 48px;
}

.overlay-header > span {
    flex: 1;
    min-width: 0;
    font-size: clamp(0.88rem, 3.2vw, 1rem);
    font-weight: 700;
}

.close-icon {
    border: none;
    background: transparent;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

.overlay-content {
    margin: auto 0;
    align-self: center;
    width: min(720px, calc(100% - 24px));
    max-width: 720px;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 56px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: white;
    color: #0f172a;
    border-radius: 16px;
    padding: clamp(14px, 4vw, 20px);
    box-shadow: 0 24px 64px rgba(2, 6, 23, 0.35);
}

#big-text-display {
    margin: 0;
    font-size: clamp(1rem, 3.8vw, 1.35rem);
    line-height: 1.55;
    word-break: break-word;
    overflow-wrap: anywhere;
}

#big-text-display .overlay-phrase--arrival {
    color: #0f172a;
}

#big-text-display .overlay-phrase--departure {
    color: #475569;
}

#big-text-display .overlay-phrase--departure small {
    font-size: 0.95em;
    line-height: 1.55;
}

.overlay-phrase-hr {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.5);
    margin: 14px 0;
}

.app-overlay-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-overlay-why {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.7;
    color: #334155;
}

.app-guide-detail {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.guide-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.app-overlay-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.app-guide-btn {
    background: linear-gradient(135deg, #f8fafc, #dbeafe);
}

.guide-block {
    padding: 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.guide-block-title {
    margin-bottom: 10px;
    font-size: 0.86rem;
    font-weight: 800;
    color: #4338ca;
}

.guide-step-list {
    margin: 0;
    padding-left: 18px;
    color: #1e293b;
    line-height: 1.85;
}

.guide-example-text {
    margin: 0;
    color: #334155;
    line-height: 1.75;
    font-weight: 600;
}

.home-map-input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    font-size: 0.95rem;
}

@media (max-width: 900px) {
    .app-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top, 0px));
    }

    header {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
        border-radius: 16px;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .lang-selector {
        width: 100%;
        justify-content: space-between;
    }

    #langSelect {
        max-width: none;
        flex: 1;
    }

    main {
        padding-top: 12px;
        gap: 12px;
    }

    .card-title {
        font-size: 1rem;
    }

    .sos-group,
    .app-overlay-actions {
        grid-template-columns: 1fr;
    }

    .btn-sos {
        font-size: 0.84rem;
        padding: 14px 12px;
        min-height: 48px;
    }
}

@media (max-width: 560px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .app-item {
        padding: 14px 10px;
    }
}

@media (max-width: 380px) {
    .app-grid {
        gap: 8px;
    }

    .app-item {
        padding: 12px 8px;
    }

    .icon-box {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .app-item span {
        font-size: 0.78rem;
    }

    .route-badge {
        font-size: 0.68rem;
        padding: 6px 9px;
    }
}

/* Cheat Codes */
.cheat-carousel-rail-wrap {
    position: relative;
    margin-top: 8px;
    min-width: 0;
}

.cheat-carousel-rail {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 6px 2px 12px;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

.cheat-slide {
    /* Use rail width (not 100vw) so slides don’t force the card wider than the column and get clipped */
    flex: 0 0 clamp(260px, min(320px, calc(100% - 20px)), 320px);
    scroll-snap-align: start;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.08));
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cheat-slide h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    word-break: break-word;
}

.cheat-slide-title-sub {
    margin: -2px 0 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(253, 224, 71, 0.95);
    line-height: 1.35;
    word-break: break-word;
}

.cheat-slide-desc {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.cheat-slide-desc--sub {
    font-size: 0.78rem !important;
    line-height: 1.45 !important;
    color: rgba(254, 243, 199, 0.88) !important;
    margin-top: 2px !important;
}

.btn-cheat-open {
    margin-top: auto;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 800;
    cursor: pointer;
    color: #1e1b4b;
    background: linear-gradient(135deg, #e0e7ff, #c4b5fd);
}

.cheat-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.cheat-dot {
    width: 8px;
    height: 8px;
    border: none;
    border-radius: 999px;
    background: rgba(165, 180, 252, 0.35);
}

.cheat-dot.active {
    background: rgba(255, 255, 255, 0.95);
}

.cheat-feature-overlay .overlay-content.cheat-overlay-panel {
    max-height: calc(100dvh - 64px);
    overflow-y: auto;
}

.cheat-overlay-lead {
    margin: 0 0 12px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #475569;
}

.table-xray-scene {
    margin-bottom: 16px;
}

.table-xray-tabletop {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 14px;
    background: linear-gradient(180deg, #c4a574, #8b6914 55%, #5c4010);
    overflow: hidden;
}

.table-xray-surface {
    position: absolute;
    inset: 10% 8% 18%;
    border-radius: 10px;
    background: linear-gradient(180deg, #fefce8, #fde68a 45%, #eab30833);
}

.table-xray-pin {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fde047;
    color: #422006;
    font-size: 0.68rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.table-xray-pin--1 { right: 16%; top: 16%; }
.table-xray-pin--2 { left: 9%; bottom: 20%; }
.table-xray-pin--3 { left: 37%; bottom: 22%; }

.table-xray-drawer,
.table-xray-water,
.table-xray-banchan {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-xray-drawer {
    right: 5%;
    top: 22%;
    width: 14%;
    height: 42%;
    border-radius: 6px;
    background: linear-gradient(90deg, #78350f, #92400e);
    color: #fef08a;
}

.table-xray-water {
    left: 12%;
    bottom: 14%;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255,255,255,0.92);
    color: #0369a1;
}

.table-xray-banchan {
    left: 38%;
    bottom: 16%;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fecdd3, #fb7185);
    color: #9f1239;
}

.table-xray-points {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.table-xray-point {
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

.table-xray-point--note {
    background: #fffbeb;
    border-color: #fde68a;
}

.symptom-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.symptom-block {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    background: #f8fafc;
}

.symptom-block-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: #4338ca;
    margin-bottom: 8px;
}

.symptom-allergy-grid,
.symptom-chips,
.symptom-segment {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.symptom-allergy-chip,
.symptom-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 11px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 0.8rem;
}

.symptom-inline-input {
    width: 100%;
    margin-top: 10px;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
}

.symptom-body-zones {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.symptom-zone {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #fff;
    padding: 10px 6px;
    font-size: 0.75rem;
}

.symptom-zone i {
    display: block;
    margin-bottom: 6px;
}

.symptom-zone.is-on,
.symptom-chip.is-on,
.symptom-allergy-chip.is-on,
.symptom-segment button.is-on {
    border-color: #6366f1;
    background: #eef2ff;
}

.symptom-segment button {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 8px;
    background: #fff;
}

.symptom-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.symptom-rotate-hint {
    margin: 0;
    font-size: 0.82rem;
    color: #64748b;
}

.symptom-big-text {
    font-size: clamp(1.45rem, 5.2vw, 2.7rem);
    font-weight: 800;
    line-height: 1.35;
    margin: 0;
}

.symptom-big-sub {
    font-size: clamp(0.98rem, 2.7vw, 1.2rem);
    margin: 0;
    color: #475569;
}
