/* ======================
   あみだくじセクション - かわいいデザイン
====================== */
.amidakuji-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    min-height: 60vh;
    overflow-x: auto;
    /* 背景色（デフォルト） */
    background-color: #f4e1e1;
    /* 背景画像は背景色の上に表示 */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-color 0.3s ease, background-image 0.3s ease;
}

.amidakuji-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

.amidakuji-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow-x: auto;
    padding: 10px;
}

.amidakuji-canvas {
    background: transparent !important;
    cursor: pointer;
    /* 中央配置 */
    display: block;
    margin: 0 auto;
}

/* ======================
   スタートボタン（丸デザイン）
====================== */
.start-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.start-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid #8B4513;
    background: linear-gradient(145deg, #f2efe0, #e8e5d6);
    color: #8B4513;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(139, 69, 19, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.start-button:hover {
    transform: scale(1.1);
    background: linear-gradient(145deg, #e8e5d6, #dedad0);
    box-shadow: 0 6px 12px rgba(139, 69, 19, 0.3);
}

.start-button.active {
    background: linear-gradient(145deg, #de6171, #c54d60);
    color: white;
    border-color: #c54d60;
    transform: scale(1.15);
}

.start-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ======================
   ゴール表示エリア
====================== */
.goal-items {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.goal-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.goal-item.highlighted {
    transform: scale(1.1);
}

.goal-item.highlighted .goal-image,
.goal-item.highlighted .goal-text {
    box-shadow: 0 0 20px rgba(222, 97, 113, 0.6);
}

/* ゴール画像モード */
.goal-image {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 3px solid #8B4513;
    object-fit: cover;
    background: linear-gradient(145deg, #f2efe0, #e8e5d6);
    box-shadow: 0 4px 8px rgba(139, 69, 19, 0.2);
}

/* ゴールテキストモード */
.goal-text {
    min-width: 80px;
    padding: 15px 20px;
    background: linear-gradient(145deg, #f2efe0, #e8e5d6);
    border: 3px solid #8B4513;
    border-radius: 12px;
    color: #8B4513;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    box-shadow: 0 4px 8px rgba(139, 69, 19, 0.2);
}

/* ======================
   結果表示 - 中央オーバーレイ
====================== */
.result-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, #de6171, #c54d60);
    color: white;
    border: 3px solid #c54d60;
    border-radius: 20px;
    padding: 20px 40px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 100;
    text-align: center;
    /* 初期状態は非表示 */
    display: none;
    opacity: 0;
    pointer-events: none;
}

.result-display.visible {
    display: block;
    opacity: 1;
    animation: resultPopIn 0.4s ease-out forwards;
}

.result-display .result-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 5px;
}

.result-display .result-text {
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
    display: block;
}

@keyframes resultPopIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ======================
   アニメーション
====================== */
@keyframes pathTrace {
    0% {
        stroke-dashoffset: 1000;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.path-animation {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: pathTrace 2s ease-in-out forwards;
}

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

.pulse-animation {
    animation: pulse 0.5s ease-in-out 3;
}

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

.result-animation {
    animation: fadeInResult 0.5s ease-out forwards;
}

/* ======================
   全結果表示モード
====================== */
.reveal-mode .start-button {
    pointer-events: none;
}

.reveal-mode .goal-item.highlighted .goal-text,
.reveal-mode .goal-item.highlighted .goal-image {
    background: linear-gradient(145deg, #de6171, #c54d60);
    border-color: #c54d60;
}

/* ======================
   スマホ対応
====================== */
@media (max-width: 768px) {
    .amidakuji-section {
        padding: 10px;
    }

    .amidakuji-wrapper {
        padding: 5px;
    }

    .amidakuji-canvas {
        max-width: 100%;
        height: auto;
    }

    .start-button {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .goal-image {
        width: 60px;
        height: 60px;
    }

    .goal-text {
        min-width: 60px;
        padding: 10px 15px;
        font-size: 0.8rem;
    }

    .result-display {
        padding: 12px 20px;
    }

    .result-display .result-text {
        font-size: 1rem;
    }
}

/* ======================
   ローディング
====================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(242, 239, 224, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 12px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e8e5d6;
    border-top: 4px solid #8B4513;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ======================
   ツールチップ
====================== */
.tooltip {
    position: absolute;
    background: #5D3A1A;
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    white-space: nowrap;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #5D3A1A;
}
