:root {
    --md-sys-color-primary: #6750A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #EADDFF;
    --md-sys-color-on-primary-container: #21005D;
    --md-sys-color-secondary: #625B71;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #E8DEF8;
    --md-sys-color-on-secondary-container: #1D192B;
    --md-sys-color-tertiary: #7D5260;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #FFD8E4;
    --md-sys-color-on-tertiary-container: #31111D;
    --md-sys-color-error: #B3261E;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #F9DEDC;
    --md-sys-color-on-error-container: #410E0B;
    --md-sys-color-background: #FFFBFE;
    --md-sys-color-on-background: #1C1B1F;
    --md-sys-color-surface: #FFFBFE;
    --md-sys-color-on-surface: #1C1B1F;
    --md-sys-color-surface-variant: #E7E0EC;
    --md-sys-color-on-surface-variant: #49454F;
    --md-sys-color-outline: #79747E;
    --md-sys-color-shadow: #000000;
    --md-sys-color-inverse-surface: #313033;
    --md-sys-color-inverse-on-surface: #F4EFF4;
    --md-sys-color-inverse-primary: #D0BCFF;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
}

.container {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
}

header {
    padding: 24px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    margin-bottom: 24px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--md-sys-color-primary);
    margin: 0;
}

h1 a {
    text-decoration: none;
    color: inherit;
}

h2 {
    font-size: 2rem;
    font-weight: 400;
    color: var(--md-sys-color-on-surface);
    margin-top: 48px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: 8px;
}

h3 {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--md-sys-color-on-secondary-container);
    margin: 0 0 16px;
}

.section-card {
    background-color: var(--md-sys-color-secondary-container);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.dialogue {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 8px;
    background-color: var(--md-sys-color-surface);
    transition: background-color 0.3s ease-in-out;
}

.dialogue:target {
    background-color: var(--md-sys-color-primary-container);
    border: 2px solid var(--md-sys-color-primary);
}

.character-name {
    font-weight: 500;
    color: var(--md-sys-color-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.link-copy-btn {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    background: var(--md-sys-color-secondary-container);
    border: none;
    border-radius: 4px;
    padding: 4px 6px;
    color: var(--md-sys-color-on-secondary-container);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.dialogue:hover .link-copy-btn {
    opacity: 1;
}

.link-copy-btn:hover {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.link-copy-btn.copied {
    background: var(--md-sys-color-tertiary);
    color: var(--md-sys-color-on-tertiary);
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.narration {
    font-style: italic;
    color: var(--md-sys-color-on-surface-variant);
}

.dialogue-text {
    color: var(--md-sys-color-on-surface);
}

.ruby-text {
    ruby-align: center;
}

.ruby-text rt {
    font-size: 0.7em;
    color: var(--md-sys-color-primary);
    font-weight: 500;
}

.char-with-dots {
    text-emphasis: dot var(--md-sys-color-primary);
    text-emphasis-position: over;
}

.back-link {
    display: inline-block;
    margin-top: 24px;
    padding: 10px 24px;
    border-radius: 20px;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease-in-out;
}

.back-link:hover {
    background-color: #5A3E9C;
}

.choices-container {
    margin-top: 16px;
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    padding: 12px;
    background-color: var(--md-sys-color-surface-container, var(--md-sys-color-surface-variant));
    border-radius: 12px;
    border: 1px solid var(--md-sys-color-outline-variant, var(--md-sys-color-outline));
    justify-content: center;
    align-items: center;
    min-height: 48px;
    overflow-x: auto; /* 横スクロールを許可 */
}

.choice-button {
    padding: 8px 16px;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 24px;
    font-weight: 500;
    border: 1px solid var(--md-sys-color-outline);
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 100px;
    text-align: center;
}

.choice-button.active {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-color: var(--md-sys-color-primary);
}

.dialogue-branch {
    border-left: 2px solid var(--md-sys-color-primary-container);
    padding-left: 16px;
    margin-left: 4px;
    margin-top: 1rem;
    margin-bottom: 1rem;
}
