/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fafafa;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

.hidden {
    display: none !important;
}

/* ===== 初期画面 ===== */
#start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    width: 100vw;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 50%, #faf0ff 100%);
    padding-bottom: 8vh;
}

.start-content {
    text-align: center;
    padding: 0 24px;
    max-width: 480px;
    width: 100%;
}

.start-title {
    font-size: 3.5rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.start-subtitle {
    font-size: 1rem;
    color: #718096;
    margin-bottom: 40px;
    line-height: 1.8;
}

.start-form {
    display: flex;
    gap: 0;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 100px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    background: #fff;
}

.start-form input {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 24px;
    font-size: 1rem;
    font-family: inherit;
    color: #333;
    background: transparent;
    min-width: 0;
}

.start-form input::placeholder {
    color: #a0aec0;
}

.start-form button {
    border: none;
    background: #667eea;
    color: #fff;
    padding: 16px 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.start-form button:hover {
    background: #5a6fd6;
}

.start-form button:active {
    background: #4c5ec2;
}

/* --- スライダー（初期画面） --- */
.slider-section {
    margin-top: 32px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.slider-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
}

.slider-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-end {
    font-size: 0.8125rem;
    color: #a0aec0;
    white-space: nowrap;
    flex-shrink: 0;
}

.slider-section input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #667eea 0%, #ec4899 50%, #ef4444 100%);
    outline: none;
}

.slider-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: border-color 0.2s;
}

.slider-section input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* --- 言語切り替えボタン --- */
.lang-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.lang-toggle:hover {
    background: #f7fafc;
    border-color: #667eea;
}

.lang-toggle-small {
    background: none;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
    transition: border-color 0.2s;
}

.lang-toggle-small:hover {
    border-color: #667eea;
}

/* --- About リンク --- */
.about-link {
    display: inline-block;
    margin-top: 24px;
    font-size: 0.875rem;
    color: #667eea;
    text-decoration: none;
    transition: opacity 0.2s;
}

.about-link:hover {
    opacity: 0.7;
}

/* --- フッター（初期画面） --- */
.start-footer {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.75rem;
    color: #a0aec0;
}

/* ===== グラフ画面 ===== */
#graph-screen {
    height: 100dvh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

/* --- 上部バー --- */
#top-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #e8ecf1;
    z-index: 10;
    flex-shrink: 0;
    gap: 8px;
}

#top-bar .logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.03em;
    text-align: center;
}

.top-action-btn {
    border: 1px solid #e2e8f0;
    background: none;
    color: #4a5568;
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    transition: border-color 0.2s, color 0.2s;
}

.top-action-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.top-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* --- フッターバー --- */
#bottom-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
    background: #fff;
    border-top: 1px solid #e8ecf1;
    z-index: 10;
    flex-shrink: 0;
}

.bottom-btn {
    border: 1px solid #e2e8f0;
    background: none;
    color: #4a5568;
    padding: 8px 14px;
    border-radius: 100px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: border-color 0.2s, color 0.2s;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
}

.bottom-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

#restart-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    min-height: unset;
}

/* --- フッタースライダー --- */
.bottom-slider {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.bottom-slider-end {
    font-size: 0.75rem;
    color: #a0aec0;
    white-space: nowrap;
    flex-shrink: 0;
}

.bottom-slider input[type="range"] {
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    border-radius: 3px;
    background: linear-gradient(90deg, #667eea 0%, #ec4899 50%, #ef4444 100%);
    outline: none;
}

.bottom-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid #667eea;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
}

.bottom-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid #667eea;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.15);
}

/* --- グラフ領域 --- */
#graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#graph-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- ノードスタイル --- */
.node-group {
    cursor: pointer;
}

.node-circle {
    stroke: #fff;
    stroke-width: 2;
    transition: filter 0.2s;
}

.node-group:hover .node-circle {
    filter: brightness(1.1);
}

.node-group.expanded .node-circle {
    stroke-dasharray: none;
}

.node-group.loading .node-circle {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

.node-label {
    font-family: 'Noto Sans JP', 'Inter', sans-serif;
    font-weight: 500;
    fill: #fff;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

.link-line {
    stroke: #cbd5e0;
    stroke-width: 1.5;
    stroke-opacity: 0.5;
}

/* --- ヒント --- */
.hint {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(74, 85, 104, 0.85);
    color: #fff;
    padding: 10px 24px;
    border-radius: 100px;
    font-size: 0.875rem;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.5s;
    z-index: 10;
}

.hint.fade-out {
    opacity: 0;
}

/* ===== About ページ ===== */
.about-body {
    overflow: auto;
    height: auto;
}

.about-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 50%, #faf0ff 100%);
}

.about-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
}

.about-back {
    font-size: 0.875rem;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.about-back:hover {
    opacity: 0.7;
}

.about-main {
    flex: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 20px 24px 60px;
    width: 100%;
}

.about-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.about-tagline {
    font-size: 1rem;
    color: #718096;
    margin-bottom: 40px;
}

.about-section {
    margin-bottom: 32px;
}

.about-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 12px;
}

.about-section p {
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.8;
}

.about-steps {
    list-style: none;
    counter-reset: steps;
    padding: 0;
}

.about-steps li {
    counter-increment: steps;
    padding: 8px 0 8px 36px;
    position: relative;
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.6;
}

.about-steps li::before {
    content: counter(steps);
    position: absolute;
    left: 0;
    width: 24px;
    height: 24px;
    background: #667eea;
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 10px;
}

.about-list {
    list-style: none;
    padding: 0;
}

.about-list li {
    padding: 6px 0 6px 20px;
    position: relative;
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.6;
}

.about-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
}

.about-author p {
    display: flex;
    align-items: center;
    gap: 12px;
}

.x-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #4a5568;
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.2s;
}

.x-link:hover {
    color: #667eea;
}

.about-footer {
    text-align: center;
    padding: 20px;
    font-size: 0.75rem;
    color: #a0aec0;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
    .start-title {
        font-size: 2.5rem;
    }

    .start-subtitle {
        font-size: 0.9375rem;
    }

    .start-form {
        flex-direction: column;
        border-radius: 16px;
    }

    .start-form input {
        padding: 14px 20px;
        text-align: center;
    }

    .start-form button {
        padding: 14px 24px;
        border-radius: 0;
    }

    #top-bar {
        padding: 8px 12px;
    }

    #top-bar .logo {
        font-size: 1rem;
    }

    .bottom-btn {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
}
