* { box-sizing: border-box; }

/* 🔮 聖なる物語を紡ぐための、流麗な明朝体ベース */
html, body { 
    margin: 0; 
    padding: 0; 
    background: #fffbf8; /* 生成り・ボタニカルなベース */
    font-family: "Times New Roman", "Georgia", "Shippori Mincho", "Hiragino Mincho ProN", serif; 
    height: 100%; 
    height: 100dvh; 
    width: 100%; 
    overflow: hidden; 
    color: #555555; 
    -webkit-font-smoothing: antialiased;
}

#card-screen, #gift-result-screen {
    height: 100%;
    height: 100dvh;
}

/* 🔮 オラクルカード画面 */
#card-screen { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    background: linear-gradient(135deg, #fcf8f4 0%, #fffbf8 100%); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    z-index: 20000; 
    transition: opacity 1s ease; 
}

.oracle-container { width: 260px; height: 380px; perspective: 1000px; }
.oracle-card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.6s ease; cursor: not-allowed; opacity: 0.6; }
.oracle-card.ready { cursor: pointer; opacity: 1; } 
.oracle-card.is-flipped { transform: rotateY(180deg); }

.card-face { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    backface-visibility: hidden; 
    border-radius: 4px; 
    border: 1px solid #eaddca; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    box-shadow: 0 10px 30px rgba(74, 46, 27, 0.05); 
}

.card-back { 
    background: linear-gradient(135deg, #fcf8f4 0%, #eaddca 100%); 
    color: #6b5b4e; 
    font-weight: 500; 
    font-size: 14px; 
    letter-spacing: 4px; 
}

.card-front { background: #fdfbf7; }

.msg-area { 
    padding: 24px; 
    font-size: 15px; 
    color: #555555; 
    text-align: center; 
    line-height: 2.0; 
    height: 100%; 
    overflow-y: auto; 
    white-space: pre-wrap; 
    width: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.status-text { color: #6b5b4e; font-size: 13px; margin-bottom: 20px; letter-spacing: 2px; text-align: center; padding: 0 10px; }
.debug-error-box { display: none; }

#setup-area { margin-top: 25px; opacity: 0; transition: 0.5s; text-align: center; display: none; }
#setup-area.show { opacity: 1; display: block; }

.nickname-input { 
    padding: 12px; 
    border-radius: 4px; 
    border: 1px solid #eaddca; 
    background: #ffffff;
    margin-bottom: 14px; 
    width: 260px; 
    text-align: center; 
    outline: none; 
    font-size: 13px; 
    color: #555555;
    font-family: inherit;
}

.gold-btn { 
    background: linear-gradient(135deg, #d4af37 0%, #c5a059 100%); 
    color: white; 
    border: none; 
    padding: 12px 35px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-weight: 500; 
    font-size: 14px; 
    letter-spacing: 2px;
    box-shadow: 0 4px 15px rgba(197, 160, 89, 0.2);
    font-family: inherit;
}

/* 💬 チャット画面 */
#chat-container { 
    display: none; 
    flex-direction: column; 
    position: fixed; 
    top: 0; 
    bottom: 0; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 100%; 
    max-width: 650px; 
    background: #fffbf8; 
    z-index: 1000; 
    transition: opacity 1s ease; 
}

#chat-header { 
    background: #fffbf8; 
    color: #6b5b4e; 
    padding: 24px 16px 12px 16px; 
    font-weight: 500; 
    text-align: center; 
    flex-shrink: 0; 
    font-size: 16px; 
    letter-spacing: 0.15em;
    border-bottom: 1px solid #f0e6cc;
}

#chat-history { 
    flex-grow: 1; 
    overflow-y: auto; 
    padding: 40px 30px; 
    background: #fffbf8; 
    display: flex; 
    flex-direction: column; 
}

.msg { 
    padding: 0; 
    border-radius: 0 !important; 
    margin-bottom: 45px; 
    width: 100%; 
    max-width: 100% !important; 
    font-size: 15px; 
    line-height: 2.2; 
    letter-spacing: 0.05em;
    word-break: break-word; 
    white-space: pre-wrap; 
    box-shadow: none !important;
    border: none !important;
    text-align: center; 
    animation: textReveal 1.5s ease forwards; 
}

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

.msg.ai { 
    background: transparent !important; 
    color: #2b2b2b; 
    align-self: center; 
}

.msg.ai::before {
    content: "✦";
    display: block;
    color: #d4af37;
    font-size: 12px;
    margin-bottom: 10px;
    letter-spacing: 0;
}

#chat-input-container { 
    display: flex; 
    gap: 12px; 
    padding: 15px 20px 30px 20px; 
    background: #fffbf8; 
    align-items: center; 
    width: 100%;
}

#chat-input { 
    flex: 1; 
    width: 100%;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none !important;
    border: 1px solid #eaddca !important; 
    border-radius: 22px !important; 
    padding: 0 18px !important; 
    height: 42px; 
    font-size: 14px; 
    background: #ffffff !important; 
    color: #4a3c47;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.4s;
}

#chat-input:focus { 
    border-color: #d4af37 !important; 
}

#send-btn { 
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none !important;
    border: none !important;
    background: linear-gradient(135deg, #e0c396 0%, #c2a678 100%) !important; 
    color: #ffffff !important; 
    padding: 0 24px !important; 
    height: 42px; 
    border-radius: 22px !important; 
    font-weight: 500; 
    font-size: 14px;
    letter-spacing: 0.05em;
    cursor: pointer; 
    white-space: nowrap; 
    font-family: inherit;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(194, 166, 120, 0.2); 
    transition: all 0.3s ease;
}

#send-btn:hover { 
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(194, 166, 120, 0.3);
}

#gift-button-container { 
    text-align: center; 
    padding: 15px 30px; 
    background: #fffbf8 !important; 
    border-top: 1px dashed #eaddca !important; 
    display: none; 
    opacity: 0; 
    transition: opacity 1s ease; 
    width: 100%; 
    flex-shrink: 0; 
}

#gift-result-screen {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%;
    background: linear-gradient(135deg, #fcf8f4 0%, #fffbf8 100%);
    z-index: 30000;
    opacity: 0;
    transition: opacity 1.5s ease; 
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.letter-container {
    background: #fdfbf7;
    border: 1px solid #eaddca;
    border-radius: 4px;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    box-sizing: border-box;
    box-shadow: 0 20px 50px rgba(74, 46, 27, 0.05);
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: floatUp 1.2s ease-out;
}

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

.letter-title {
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    color: #6b5b4e;
    margin-bottom: 25px;
    font-weight: 500;
    border-bottom: 1px dashed #eaddca;
    padding-bottom: 12px;
    width: 100%;
    text-align: center;
}

.letter-body {
    font-size: 0.95rem;
    line-height: 2.0;
    color: #555555;
    text-align: justify;
    white-space: pre-wrap;
    overflow-y: auto;
    width: 100%;
    margin-bottom: 30px;
}

.luxury-shop-btn {
    font-family: "Times New Roman", "Shippori Mincho", serif;
    background: linear-gradient(135deg, #d4af37 0%, #c5a059 100%);
    color: #fff !important;
    text-decoration: none !important;
    border: none;
    padding: 15px 35px;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(197, 160, 89, 0.2);
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    display: block;
    box-sizing: border-box;
}

.luxury-shop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(197, 160, 89, 0.3);
}

/* 「大きめ」スイッチ */
#chat-container.is-large-text .msg { font-size: 18px; line-height: 2.4; }
#chat-container.is-large-text #chat-input { font-size: 16px; }
#chat-container.is-large-text .oracle-button-intro { font-size: 1.2rem; }