:root {
    --primary-color: #f0c5e8;
    --secondary-color: #b5e6e6;
    --accent-color: #f9d7ad;
    --text-color: #6a5a7d;
    --border-color: #d4b8e0;
    --bg-color: #f9f4ff;
    --dark-bg: #6a5a7d;
}

body {
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../images/background.jpg') no-repeat top center;
    background-size: cover;
    opacity: 0.1;
    z-index: -1;
}

h1 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 1px 1px 3px rgba(106, 90, 125, 0.3);
}

.crafting-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.ingredients-section, .result-section {
    background-color: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--border-color);
}

h2 {
    color: var(--text-color);
    border-bottom: 2px dashed var(--accent-color);
    padding-bottom: 8px;
    margin-top: 0;
}

.ingredient-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.ingredient {
    background-color: var(--secondary-color);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.ingredient:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.ingredient.selected {
    background-color: var(--primary-color);
    border-color: var(--text-color);
    font-weight: bold;
}

.ingredient.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
}

.ingredient img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 5px;
    background-color: white;
    padding: 5px;
}

.ingredient-name {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 2px;
}

.ingredient-stock {
    font-size: 0.75rem;
    margin-top: 3px;
    color: #6a5a7d;
}

.selected-ingredients {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    background-color: rgba(181, 230, 230, 0.3);
    padding: 15px;
    border-radius: 10px;
}

.selected-slot {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px dashed var(--border-color);
    position: relative;
}

.selected-slot img {
    width: 90%;
    height: 90%;
    object-fit: cover;
    border-radius: 50%;
}

.selected-slot::after {
    content: "+";
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: var(--text-color);
}

.selected-slot:last-child::after {
    display: none;
}

.craft-button {
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 0 4px 0 rgba(106, 90, 125, 0.2);
    position: relative;
    overflow: hidden;
}

.craft-button:hover {
    background-color: #fae6c3;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(106, 90, 125, 0.2);
}

.craft-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(106, 90, 125, 0.2);
}

.craft-button:disabled {
    background-color: #e0e0e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.craft-button::before {
    content: "";
    position: absolute;
    background: rgba(255, 255, 255, 0.5);
    width: 60px;
    height: 100%;
    left: -85px;
    top: 0;
    transform: skewX(-45deg);
    transition: 0.5s;
}

.craft-button:hover::before {
    left: 150%;
}

.result-item {
    text-align: center;
    margin-bottom: 20px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.result-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: white;
    padding: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    border: 3px solid var(--primary-color);
}

.result-name {
    font-size: 1.3rem;
    color: var(--text-color);
    margin-bottom: 10px;
    font-weight: bold;
}

.result-description {
    color: var(--text-color);
    font-style: italic;
    max-width: 80%;
    margin: 0 auto 10px auto;
}

.result-value {
    font-weight: bold;
    color: #c27c0e;
    margin-bottom: 15px;
}

.sell-button {
    background-color: #ffc107;
    color: #6a5a7d;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

.sell-button:hover {
    background-color: #ffcd38;
    transform: translateY(-2px);
}

.sell-button:active {
    transform: translateY(1px);
}

.crafting-history {
    margin-top: 30px;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.history-item {
    padding: 8px;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
}

.history-item:last-child {
    border-bottom: none;
}

.history-image {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    border: 2px solid var(--primary-color);
}

/* Animation */
@keyframes sparkle {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0.5; }
}

/* 更に改良したアニメーション */
.crafting-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.crafting-animation.active {
    opacity: 1;
    pointer-events: all;
}

.cauldron {
    position: relative;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, #444 0%, #111 80%);
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 
                inset 0 5px 15px rgba(255, 255, 255, 0.1),
                0 0 20px rgba(240, 197, 232, 0.5);
    overflow: hidden;
    transform: scale(0.8);
    animation: pulsate 0.8s infinite alternate, rotate 10s infinite linear;
}

.cauldron::before {
    content: '';
    position: absolute;
    top: 20px;
    width: 85%;
    height: 60%;
    background: linear-gradient(90deg, 
                var(--primary-color), 
                var(--secondary-color), 
                var(--accent-color), 
                var(--primary-color));
    background-size: 300% 100%;
    border-radius: 50%;
    left: 50%;
    transform: translateX(-50%);
    animation: colorShift 2s infinite alternate, 
               bubbling 0.8s infinite,
               glow 1.5s infinite alternate;
    box-shadow: 0 0 25px rgba(240, 197, 232, 0.8);
}

@keyframes colorShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes pulsate {
    0% { transform: scale(0.8); }
    100% { transform: scale(0.85); }
}

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

@keyframes glow {
    0% { box-shadow: 0 0 10px rgba(240, 197, 232, 0.5); }
    100% { box-shadow: 0 0 30px rgba(240, 197, 232, 1), 0 0 50px rgba(181, 230, 230, 0.8); }
}

/* 魔法の粒子エフェクト（改良版） */
.magic-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: white;
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    transform-origin: center center;
}

@keyframes floatUp {
    0% {
        opacity: 0.1;
        transform: translateY(0) scale(0.2) rotate(0deg);
    }
    50% {
        opacity: 0.9;
        transform: translateY(-40px) scale(1) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) scale(0) rotate(360deg);
    }
}

@keyframes floatSpiral {
    0% {
        opacity: 0.1;
        transform: translateY(0) translateX(0) scale(0.2);
    }
    50% {
        opacity: 0.9;
        transform: translateY(-60px) translateX(30px) scale(1);
    }
    75% {
        opacity: 0.7;
        transform: translateY(-90px) translateX(-30px) scale(0.7);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) translateX(0) scale(0);
    }
}

/* 閃光エフェクト（改良版） */
.flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    opacity: 0;
    z-index: 2;
    animation: flashEnhanced 0.7s;
}

@keyframes flashEnhanced {
    0% { opacity: 0; }
    30% { opacity: 0.9; }
    40% { opacity: 0.3; }
    50% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* 波紋エフェクト（新規追加） */
.ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: transparent;
    border: 2px solid white;
    border-radius: 50%;
    opacity: 1;
    pointer-events: none;
    animation: rippleEffect 1s linear forwards;
}

@keyframes rippleEffect {
    0% {
        width: 0;
        height: 0;
        opacity: 0.8;
        border-width: 5px;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
        border-width: 1px;
    }
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: white;
    border-radius: 50%;
    animation: sparkle 1s infinite;
}

.message {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 15px;
    border-radius: 20px;
    margin-top: 10px;
    display: none;
}

.message.error {
    color: #d8000c;
    background-color: #ffbaba;
}

.message.success {
    color: #4F8A10;
    background-color: #DFF2BF;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 15px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.gold-display {
    font-weight: bold;
    color: #c27c0e;
    font-size: 1.2rem;
}

.day-display {
    font-weight: bold;
    color: var(--text-color);
    background-color: rgba(240, 197, 232, 0.3);
    padding: 5px 10px;
    border-radius: 10px;
}

.shop-button {
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.shop-button:hover {
    background-color: #ffe0b5;
}

/* Shop styles */
.shop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.shop-content {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--border-color);
}

.shop-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.shop-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-color);
    background-color: rgba(181, 230, 230, 0.2);
    border-radius: 10px 10px 0 0;
    margin-right: 5px;
}

.shop-tab.active {
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.shop-description {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-color);
}

.shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.shop-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(181, 230, 230, 0.2);
    border: 1px solid var(--border-color);
}

.shop-item-image {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: white;
    padding: 5px;
}

.shop-item-info {
    flex-grow: 1;
}

.shop-item-name {
    font-weight: bold;
    color: var(--text-color);
}

.shop-item-price {
    color: #c27c0e;
    font-weight: bold;
}

.shop-item-stock {
    font-size: 0.8rem;
    color: #6a5a7d;
}

.buy-button {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 5px 10px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.buy-button:hover {
    background-color: #f9d5f0;
    transform: translateY(-2px);
}

.close-button {
    background-color: #e0e0e0;
    color: #333;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    font-weight: bold;
}

.close-button:hover {
    background-color: #d0d0d0;
}

/* Recipe book styles */
.recipe-button {
    background-color: #b5e6e6;
    color: var(--text-color);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    margin-left: 10px;
}

.recipe-button:hover {
    background-color: #a0d0d0;
}

.recipe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.recipe-content {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--border-color);
}

.recipe-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.recipe-item {
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(250, 215, 173, 0.2);
    border: 1px solid var(--border-color);
    text-align: center;
}

.recipe-item img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 10px;
    display: block;
    background-color: white;
    padding: 5px;
    border: 2px solid var(--primary-color);
}

.recipe-ingredients {
    margin-top: 10px;
    font-size: 0.85rem;
}

.recipe-value {
    color: #c27c0e;
    font-weight: bold;
    margin-top: 5px;
}

.recipe-mystery {
    opacity: 0.6;
}

.recipe-mystery img {
    filter: brightness(0.5) grayscale(0.5);
}

/* 採取場所スタイル */
.gathering-button {
    background-color: #a4e1a0;
    color: var(--text-color);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    margin-left: 10px;
}

.gathering-button:hover {
    background-color: #8fd28a;
}

.gathering-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.gathering-content {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--border-color);
}

.gathering-places {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.gathering-place {
    height: 150px;
    border-radius: 10px;
    background-color: rgba(164, 225, 160, 0.2);
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.gathering-place:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.gathering-place-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
    opacity: 0.7;
}

.gathering-place-name {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 0;
    font-weight: bold;
    color: var(--text-color);
    z-index: 2;
}

/* 目標表示 */
.goal-progress {
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.goal-title {
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 10px;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 10px;
    transition: width 0.5s;
}

.progress-text {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-color);
}

/* ゲームオーバー・クリア画面 */
.game-end-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-end-content {
    background-color: white;
    border-radius: 15px;
    padding: 30px;
    width: 80%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--border-color);
}

.game-end-title {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

.game-end-text {
    color: var(--text-color);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.retry-button {
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.retry-button:hover {
    background-color: #fae6c3;
    transform: translateY(-3px);
}

/* 結果アニメーション */
.gathering-result {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.gathering-result.active {
    opacity: 1;
    pointer-events: all;
}

.gathering-result-content {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.gathering-item {
    display: inline-block;
    margin: 10px;
    text-align: center;
}

.gathering-item img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 5px;
    background-color: white;
    padding: 5px;
    border: 2px solid var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .crafting-area {
        grid-template-columns: 1fr;
    }
    
    .ingredient-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* style.css に追加 */
.alchemy-info {
    background-color: rgba(240, 197, 232, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.exp-bar-container {
    width: 100%;
    height: 10px;
    background-color: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin: 5px 0;
}

.exp-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.5s;
}

/* 採取場所の未解放スタイル */
.gathering-place.locked {
    background-color: rgba(0, 0, 0, 0.1);
    cursor: default;
    position: relative;
}

.locked-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -70%);
    color: rgba(0, 0, 0, 0.5);
    font-size: 2rem;
    z-index: 2;
}

.unlock-condition {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    padding: 5px;
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.7);
    color: var(--text-color);
}


.time-required {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    padding: 5px;
    font-size: 0.8rem;
    background-color: rgba(255, 255, 255, 0.7);
    color: var(--text-color);
}


.day-change-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

.day-change-overlay.active {
    opacity: 1;
}

.day-change-content {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 30px rgba(240, 197, 232, 0.8);
    transform: scale(0.8);
    transition: transform 0.5s;
}

.day-change-overlay.active .day-change-content {
    transform: scale(1);
}

.day-change-title {
    font-size: 2.5rem;
    color: var(--text-color);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.day-change-text {
    font-size: 1.2rem;
    color: var(--text-color);
}

.gathering-place-items {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 5px;
}

.place-item-icon {
    width: 30px;
    height: 30px;
    margin: 0 5px;
    background-color: white;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.place-item-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* style.css に追加 */
.sleep-button {
    background-color: #8e44ad;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    margin-left: 10px;
}

.sleep-button:hover {
    background-color: #9b59b6;
}

.message.warning {
    color: #8a6d3b;
    background-color: #fcf8e3;
    border: 1px solid #faebcc;
}
/* style.css に追加 */
.warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.warning-content {
    background-color: #fcf8e3;
    border: 1px solid #faebcc;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 500px;
    text-align: center;
}

.warning-content h3 {
    color: #8a6d3b;
    margin-top: 0;
}


.time-unavailable {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.time-unavailable::before {
    content: '時間不足';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    z-index: 3;
    font-weight: bold;
}

.result-exp {
    color: #8e44ad;
    font-weight: bold;
    margin-bottom: 10px;
}

/* 遊び方ガイド */
.game-guide {
    background-color: rgba(240, 197, 232, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.guide-title {
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
}

.guide-content {
    padding: 0 10px;
}

.guide-content h3 {
    color: var(--text-color);
    border-bottom: 1px dashed var(--accent-color);
    padding-bottom: 5px;
}

.guide-content p {
    font-size: 0.9rem;
    margin: 5px 0;
}

/* レシピヒント表示 */
.recipe-hints {
    background-color: rgba(181, 230, 230, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.hints-title {
    font-weight: bold;
    color: var(--text-color);
    padding: 5px;
}

.hints-list {
    max-height: 150px;
    overflow-y: auto;
}

.hint-item {
    padding: 8px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 5px;
}

.hint-text {
    color: var(--text-color);
    font-style: italic;
}

.hint-date {
    font-size: 0.8rem;
    color: #888;
    text-align: right;
}

.no-hints {
    font-style: italic;
    color: #888;
    text-align: center;
}

/* メッセージ表示改善 */
#message-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 80%;
    max-width: 600px;
    text-align: center;
}

.message {
    padding: 12px 20px;
    border-radius: 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s, fadeOut 0.5s 2.5s forwards;
    display: inline-block;
}

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

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

.message.error {
    background-color: #ffbaba;
    color: #d8000c;
    border-left: 5px solid #d8000c;
}

.message.success {
    background-color: #DFF2BF;
    color: #4F8A10;
    border-left: 5px solid #4F8A10;
}

.message.info {
    background-color: #BDE5F8;
    color: #00529B;
    border-left: 5px solid #00529B;
}

.message.warning {
    background-color: #FEEFB3;
    color: #9F6000;
    border-left: 5px solid #9F6000;
}

/* プレイヤー情報パネル */
.player-info-panel {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.player-info-panel .alchemy-info,
.player-info-panel .goal-progress {
    flex: 1;
    margin-bottom: 0;
}

/* ヒント表示 */
.recipe-hints {
    background-color: rgba(181, 230, 230, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.hints-title {
    font-weight: bold;
    color: var(--text-color);
    padding: 5px;
    cursor: pointer;
}

.hints-list {
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
}

.hint-item {
    padding: 8px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 5px;
}

.hint-text {
    color: var(--text-color);
    font-style: italic;
}

.hint-date {
    font-size: 0.8rem;
    color: #888;
    text-align: right;
}

.no-hints {
    font-style: italic;
    color: #888;
    text-align: center;
}

/* 遊び方ガイド */
.game-guide {
    background-color: rgba(240, 197, 232, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-top: 30px;
    border: 1px solid var(--border-color);
}

.guide-title {
    font-weight: bold;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
}

.guide-content {
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    margin-top: 10px;
}

.guide-content h3 {
    color: var(--text-color);
    border-bottom: 1px dashed var(--accent-color);
    padding-bottom: 5px;
    margin-top: 15px;
}

.guide-content p {
    font-size: 0.9rem;
    margin: 5px 0;
}

/* 調合履歴のスタイル調整 */
.result-section .history-list {
    max-height: 250px; /* 高さを調整 */
    overflow-y: auto;
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

/* 履歴アイテムのホバー効果を強化 */
.history-item {
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background-color: rgba(240, 197, 232, 0.3);
    transform: translateY(-2px);
}

.recipe-known-not-made {
    background-color: rgba(181, 230, 230, 0.2);
}

.recipe-status.not-made {
    color: #888;
    font-style: italic;
}

.history-exp {
    color: #8e44ad;
    font-weight: bold;
    display: block;
    margin-top: 3px;
}

.story-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.story-content {
    width: 90%;
    max-width: 1536px;
    max-height: 90vh;
    position: relative;
    animation: fadeIn 1s ease-in-out;
}

.story-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(240, 197, 232, 0.5);
}

/* story-text のスタイルを修正 */
.story-text {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    text-align: center; /* すでにあるはず */
    border-radius: 0 0 10px 10px;
    /* 以下を追加 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    max-width: 100%; /* 幅を100%に制限 */
    box-sizing: border-box;
}

/* テキスト内の段落のスタイルも調整 */
.story-text p {
    margin: 8px 0;
    max-width: 90%; /* テキスト幅を調整 */
    text-align: center;
}

.story-button {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    font-size: 1.1rem;
    cursor: pointer;
    font-weight: bold;
    margin-top: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.story-button:hover {
    background-color: #fae6c3;
    transform: translateX(-50%) translateY(-2px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#game-end .game-end-content {
    width: 90%;
    max-width: 1536px;
    position: relative;
    padding: 0;
    background-color: transparent;
    border: none;
    box-shadow: none;
}

.game-end-image {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.game-end-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 0 0 10px 10px;
}

.game-end-title {
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.game-end-text {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.retry-button {
    margin-top: 10px;
    font-size: 1.1rem;
}

.share-buttons {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    gap: 10px;
}

.share-button {
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    transition: transform 0.2s;
}

.share-button:hover {
    transform: translateY(-3px);
}

.twitter-share {
    background-color: #1DA1F2;
}

.facebook-share {
    background-color: #4267B2;
}

.line-share {
    background-color: #06C755;
}


.share-buttons {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    gap: 10px;
}

.share-button {
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    transition: transform 0.2s;
}

.share-button:hover {
    transform: translateY(-3px);
}

.twitter-share {
    background-color: #1DA1F2;
}

.facebook-share {
    background-color: #4267B2;
}

.line-share {
    background-color: #06C755;
}

/* レシピ発見ポップアップ */
.recipe-discovery-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.recipe-discovery-content {
    background-color: white;
    border-radius: 15px;
    padding: 20px;
    width: 80%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: popIn 0.5s;
}

.recipe-discovery-content img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 10px auto;
    display: block;
    border: 3px solid var(--primary-color);
}

.recipe-discovery-content h3 {
    color: var(--text-color);
    margin-top: 0;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* モバイルデバイス向け最適化 */
@media (max-width: 768px) {
    /* コンテナの幅を最大化 */
    .container {
      width: 100%;
      max-width: 100%;
      padding: 10px;
      margin: 0;
      border-radius: 0;
    }
    
    /* ヘッダーのボタン配置を調整 */
    .game-header {
      flex-direction: column;
      gap: 10px;
    }
    
    .game-header > div {
      width: 100%;
      display: flex;
      justify-content: space-between;
    }
    
    /* ボタンサイズを大きくして操作しやすく */
    .gathering-button, .shop-button, .recipe-button, .sleep-button, .save-button, .load-button, .sound-button {
      padding: 12px 15px;
      font-size: 1rem;
      margin: 0 2px;
    }
    
    /* プレイヤー情報パネルをモバイル向けに */
    .player-info-panel {
      flex-direction: column;
    }
    
    /* 素材選択をタップしやすく */
    .ingredient {
      padding: 15px;
    }
    
    .ingredient img {
      width: 60px;
      height: 60px;
    }
    
    /* 選択スロットを大きく */
    .selected-slot {
      width: 80px;
      height: 80px;
    }
    
    /* 調合ボタンを目立たせる */
    .craft-button {
      padding: 15px 30px;
      font-size: 1.2rem;
      margin: 20px auto;
    }
    
    /* ショップ・採取・レシピ画面の調整 */
    .shop-content, .gathering-content, .recipe-content {
      width: 95%;
      max-height: 90vh;
    }
    
    /* 素材とレシピのグリッドを調整 */
    .shop-items, .recipe-list {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    /* 採取場所のグリッドを調整 */
    .gathering-places {
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    /* メッセージ表示を調整 */
    #message-container {
      width: 90%;
    }
    
    /* 調合履歴を縦長に */
    .history-item {
      padding: 12px;
    }
    
    /* ストーリー・ゲームエンド画面の調整 */
    .story-content, .game-end-content {
      width: 95%;
    }
    
    /* 調合結果オーバーレイの調整 */
    .crafting-result-content, .gathering-result-content {
      width: 90%;
    }
  }
  
  /* さらに小さい画面向け */
  @media (max-width: 480px) {
    h1 {
      font-size: 1.5rem;
    }
    
    h2 {
      font-size: 1.2rem;
    }
    
    /* 素材グリッドを2列に */
    .ingredient-list {
      grid-template-columns: repeat(2, 1fr);
    }
    
    /* 採取場所を2列に */
    .gathering-places {
      grid-template-columns: repeat(2, 1fr);
    }
    
    /* ボタンをさらに大きく */
    .gathering-button, .shop-button, .recipe-button, .sleep-button {
      width: 100%;
      margin: 4px 0;
      padding: 15px;
    }
    
    /* ヘッダーのボタンコンテナを調整 */
    .game-header > div:last-child {
      flex-wrap: wrap;
      justify-content: center;
    }
    
    /* サウンド・セーブ・ロードボタンをアイコンのみに */
    .save-button, .load-button, .sound-button {
      width: auto;
      margin: 4px;
    }
  }

.touch-device .ingredient,
.touch-device .gathering-place,
.touch-device .buy-button,
.touch-device .close-button,
.touch-device .craft-button {
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0); /* タップ時のハイライトを消す */
}

.touch-device .selected-slot {
  min-width: 70px;
  min-height: 70px;
}

.touch-device .ingredient-name,
.touch-device .shop-item-name,
.touch-device .recipe-name {
  font-size: 1rem;
}

.touch-device .gold-display,
.touch-device .day-display {
  font-size: 1.1rem;
}

/* 選択領域をより大きく */
.touch-device .shop-item,
.touch-device .history-item,
.touch-device .gathering-place,
.touch-device .recipe-item {
  padding: 15px;
  margin-bottom: 10px;
}

/* ボタンの間隔を開ける */
.touch-device button {
  margin: 10px 5px;
}

/* style.css に追加 */
@media (max-width: 768px) {
    .crafting-area {
      grid-template-columns: 1fr;
    }
    
    .ingredients-section, .result-section {
      margin-bottom: 20px;
    }
    
    /* スクロールできるようにする */
    .ingredient-list {
      max-height: 300px;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch; /* iOSのスムーズスクロール */
    }
    
    .selected-ingredients {
      flex-wrap: wrap;
      justify-content: center;
    }
  }

@media (max-width: 768px) {
    .shop-overlay, .gathering-overlay, .recipe-overlay,
    .crafting-animation, .warning-overlay, .story-popup,
    .recipe-discovery-popup, .game-end-overlay {
      align-items: flex-start;
      padding-top: 10vh;
    }
    
    .shop-content, .gathering-content, .recipe-content {
      max-height: 80vh;
      overflow-y: auto;
    }
    
    /* ポップアップ内の閉じるボタンを大きく */
    .close-button {
      padding: 12px 20px;
      margin-top: 15px;
    }
  }

  /* ストーリー画面とゲームオーバー/クリア画面のモバイル最適化 */
@media (max-width: 768px) {
    /* ストーリーポップアップの調整 */
    .story-popup {
      align-items: center; /* 中央揃えを維持 */
      overflow-y: auto; /* スクロール可能に */
      padding: 10px 0;
    }
    
    .story-content {
      width: 95%;
      max-width: 95%;
      position: relative;
      margin: auto;
    }
    
    /* テキスト領域を画像下部に固定し、スクロール可能に */
    .story-text {
      position: relative; /* 絶対位置から相対位置に変更 */
      bottom: auto;
      margin-top: 10px; /* 画像との間に余白 */
      width: 100%;
      max-height: 200px;
      overflow-y: auto;
      border-radius: 10px; /* 角丸に */
    }
    
    /* 画像を画面に合わせてリサイズ */
    .story-image {
      width: 100%;
      height: auto;
      max-height: 60vh; /* 画面の60%を超えないように */
      object-fit: contain;
    }
    
    /* スタートボタンの位置調整 */
    .story-button {
      position: relative;
      bottom: auto;
      left: auto;
      transform: none;
      margin: 20px auto 10px auto;
      display: block;
    }
    
    /* ゲームエンド画面の調整 */
    #game-end .game-end-content {
      width: 95%;
      display: flex;
      flex-direction: column;
    }
    
    .game-end-image {
      width: 100%;
      height: auto;
      max-height: 50vh;
      object-fit: contain;
    }
    
    .game-end-info {
      position: relative;
      padding: 15px;
      margin-top: 10px;
      border-radius: 10px;
    }
    
    /* テキストサイズの調整 */
    .game-end-title {
      font-size: 1.8rem;
    }
    
    .game-end-text {
      font-size: 1rem;
    }
  }
  
  /* さらに小さい画面向け */
  @media (max-width: 480px) {
    .story-text {
      max-height: 180px;
      padding: 15px;
    }
    
    .story-text p {
      margin: 5px 0;
      font-size: 0.9rem;
    }
    
    .game-end-title {
      font-size: 1.5rem;
    }
    
    .game-end-text {
      font-size: 0.9rem;
    }
    
    .game-end-image {
      max-height: 40vh;
    }
  }/* モバイルでのストーリー画面の問題を修正 */
@media (max-width: 768px) {
    /* ストーリーポップアップの調整 */
    .story-popup {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      overflow: hidden; /* スクロールを防止 */
      touch-action: none; /* タッチイベントによるスクロールを防止 */
    }
    
    .story-content {
      width: 95%;
      max-width: 95%;
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      max-height: 90vh;
      overflow: hidden;
    }
    
    /* 画像を画面に合わせてリサイズ */
    .story-image {
      width: 100%;
      height: auto;
      max-height: 50vh;
      object-fit: contain;
    }
    
    /* テキスト領域をスクロール可能なコンテナに */
    .story-text {
      position: relative;
      bottom: auto;
      margin-top: 10px;
      padding: 15px;
      width: 100%;
      max-height: 30vh;
      overflow-y: auto;
      background-color: rgba(0, 0, 0, 0.7);
      border-radius: 10px;
      scrollbar-width: thin;
      -webkit-overflow-scrolling: touch;
      display: block; /* フレックスではなく通常のブロック要素に */
    }
    
    /* テキスト内の各段落 */
    .story-text p {
      margin: 8px 0;
      text-align: left; /* 左揃えに変更 */
      width: 100%; /* 幅を100%に */
      max-width: 100%;
    }
    
    /* スタートボタンを固定位置に */
    .story-button {
      position: relative;
      margin-top: 15px;
      bottom: auto;
      left: auto;
      transform: none;
      width: 80%;
      max-width: 300px;
    }
    
    /* ゲームエンド画面も同様に修正 */
    #game-end .game-end-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      max-height: 90vh;
      overflow: hidden;
    }
    
    .game-end-info {
      position: relative;
      width: 100%;
      padding: 15px;
      margin-top: 10px;
      max-height: 40vh;
      overflow-y: auto;
      scrollbar-width: thin;
      -webkit-overflow-scrolling: touch;
    }
    
    /* リトライボタンも固定位置に */
    .retry-button {
      margin: 15px auto;
      position: relative;
      width: 80%;
      max-width: 300px;
    }
  }