:root {
    --background: #f9f5f0;
    --foreground: #2b1a17;
    --text-muted: #795548;
    --primary: #a64d4d;
    --primary-hover: #8e3a3a;
    --secondary: #6d7e6d;
    --card-bg: rgba(255, 255, 255, 0.85);
    --shadow: 0 12px 40px rgba(93, 64, 55, 0.12);
    --font-heading: "Kiwi Maru", serif;
    --font-body: "M PLUS Rounded 1c", sans-serif;
    --font-brush: "Yuji Syuku", serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(#e6e1da 1.5px, transparent 1.5px),
        radial-gradient(circle at 10% 20%, rgba(166, 77, 77, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(109, 126, 109, 0.1) 0%, transparent 40%);
    background-size: 24px 24px, 100% 100%, 100% 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-header {
    text-align: center;
    margin-bottom: 2rem;
}

.badge {
    display: inline-block;
    background: rgba(166, 77, 77, 0.1);
    color: var(--primary);
    padding: 0.3rem 1rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
}

h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 8vw, 2.8rem);
    color: var(--foreground);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.subtitle {
    color: var(--text-muted);
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    font-weight: 500;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    width: 100%;
}

@media (min-width: 768px) {
    .content-wrapper {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
        gap: 4rem;
        padding-top: 2rem;
    }
    .site-header { margin-bottom: 3.5rem; }
}

.grandma-container {
    position: relative;
    width: clamp(240px, 60vw, 320px);
    height: auto;
    aspect-ratio: 1/1;
}

.grandma-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 15px 25px rgba(93, 64, 55, 0.2));
    transition: opacity 0.3s ease;
}

.speech-bubble {
    position: absolute;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 2rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    color: var(--foreground);
    font-size: 1rem;
    font-weight: 500;
    top: -20px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 90vw;
    max-width: 280px;
}

@media (min-width: 768px) {
    .speech-bubble {
        top: -10px;
        right: -60px;
        left: auto;
        transform: translateY(10px);
        width: 260px;
        border-bottom-left-radius: 0;
    }
}

.speech-bubble.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
@media (min-width: 768px) {
    .speech-bubble.visible { transform: translateX(0) translateY(0); }
}

.interaction-section {
    width: 100%;
    max-width: 500px;
    min-height: 380px;
    position: relative;
}

.view-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-panel.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    position: relative;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 2rem;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    box-shadow: var(--shadow);
    text-align: center;
}

.glass-card h2 {
    font-family: var(--font-heading);
    font-size: clamp(1.3rem, 5vw, 1.8rem);
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.instruction {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.category-btn {
    background: white;
    border: 2px solid rgba(93, 64, 55, 0.1);
    padding: 1rem;
    border-radius: 1.25rem;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.04);
    min-height: 60px;
}

.category-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(93, 64, 55, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- お守りデザイン：はみ出し防止 --- */
.omamori-capture-target {
    padding: 10px; /* キャプチャ時の余白 */
    background: transparent;
}

.omamori-bg {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-width: 320px;
    margin: 0 auto;
    border-radius: 1.5rem;
    overflow: hidden; /* 背景のはみ出しを確実に防ぐ */
    box-shadow: 0 15px 40px rgba(0,0,0,0.18);
    background-color: #f4e7d3;
    background-image:
        radial-gradient(#e0d1bb 1.2px, transparent 1.2px);
    background-size: 12px 12px;
    border: 10px double var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    /* html2canvas用：クリッピングを明示 */
    z-index: 1;
}

.omamori-text-container {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 2rem 1.5rem;
    text-align: center;
    z-index: 2;
    height: 100%;
}

.advice-category {
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.advice-text {
    font-family: var(--font-brush);
    writing-mode: horizontal-tb;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    line-height: 1.5;
    color: #2b1a17;
    margin: 0 auto;
    font-weight: 500;
    opacity: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 80px;
    max-height: 200px;
    overflow: hidden;
    word-wrap: break-word;
    hyphens: auto;
}

/* 保存時・アニメーション完了時に適用されるクラス */
.advice-text.is-visible {
    opacity: 1 !important;
}

.advice-text.fade-in-omamori {
    animation: omamoriFadeIn 1.5s ease-out forwards;
}

@keyframes omamoriFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stamp {
    width: 65px;
    height: 65px;
    border: 2px solid var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 0.65rem;
    font-weight: 900;
    transform: rotate(-12deg);
    opacity: 0.75;
    padding: 4px;
    text-align: center;
    line-height: 1.1;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .omamori-bg {
        min-height: 350px;
        max-width: 280px;
    }

    .omamori-text-container {
        padding: 1.5rem 1rem;
    }

    .advice-text {
        font-size: clamp(1.1rem, 5vw, 1.3rem);
        min-height: 60px;
        max-height: 150px;
    }

    .stamp {
        width: 55px;
        height: 55px;
        font-size: 0.6rem;
    }
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
}

.action-btn {
    padding: 1rem;
    border-radius: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
    font-family: var(--font-body);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn .lucide {
    width: 1.2rem;
    height: 1.2rem;
    stroke-width: 2.5px;
}

.action-btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 15px rgba(166, 77, 77, 0.35);
}

.action-btn.secondary {
    background: white;
    color: var(--foreground);
    border: 2px solid rgba(93, 64, 55, 0.15);
}

.action-btn.text-only {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.site-footer {
    margin-top: 3rem;
    padding: 2rem 1rem;
    width: 100%;
    text-align: center;
    border-top: 1px solid rgba(166, 77, 77, 0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.custom-dialog {
    border: none;
    border-radius: 2rem;
    padding: 0;
    max-width: 90vw;
    width: 450px;
    background: var(--background);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    margin: auto;
}

.custom-dialog::backdrop {
    background: rgba(43, 26, 23, 0.7);
    backdrop-filter: blur(6px);
}

.dialog-content {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-title {
    font-family: var(--font-heading);
    color: var(--primary);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

.modal-text {
    line-height: 1.6;
    margin-bottom: 1.5rem;
    text-align: left;
    font-size: 0.9rem;
}



.close-dialog-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
}

.hidden { display: none; }