
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    color: #e0e0e0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-top: 2vh;
    margin-bottom: 1vh;
    color: #fff;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.6), 0 2px 4px rgba(0,0,0,0.8);
    text-align: center;
    position: relative;
    z-index: 2;
}

p {
    color: #a0a0c0;
    margin-bottom: 1.5rem;
    text-align: center;
}

.magic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at center, #1a1a2e 0%, #050510 100%);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.magic-ring {
    position: absolute;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.outer-ring {
    width: 85vh;
    height: 85vh;
    border: 2px dashed rgba(168, 85, 247, 0.3);
    box-shadow: 0 0 40px rgba(168, 85, 247, 0.1);
    animation: rotate-cw 60s linear infinite;
}

.inner-ring {
    width: 60vh;
    height: 60vh;
    border: 1px solid rgba(236, 72, 153, 0.4);
    border-top: 1px solid transparent;
    border-bottom: 1px solid transparent;
    box-shadow: 0 0 20px rgba(236, 72, 153, 0.2), inset 0 0 20px rgba(236, 72, 153, 0.1);
    animation: rotate-ccw 40s linear infinite;
}

.inner-ring::after {
    content: '';
    position: absolute;
    top: 10px; left: 10px; right: 10px; bottom: 10px;
    border: 1px dotted rgba(236, 72, 153, 0.3);
    border-radius: 50%;
}

.magic-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40vh;
    height: 40vh;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes rotate-cw {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes rotate-ccw {
    from { transform: translate(-50%, -50%) rotate(360deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); }
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.9; }
}

#app-container {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

#spread-area {
    width: 100%;
    height: 45vh; 
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#question-area {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 1vh 0;
    z-index: 10;
}

.input-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 90%;
    max-width: 600px;
    background: rgba(26, 26, 46, 0.6); /* 半透明背景 */
    padding: 1.2rem;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(168, 85, 247, 0.1);
    backdrop-filter: blur(10px); /* 霧狀玻璃效果 */
}

.input-container label {
    font-size: 0.9rem;
    color: #d8b4fe;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

#question-select, #question-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.4);
    background: rgba(15, 15, 25, 0.8);
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box; /* 確保padding不會撐破寬度 */
}

#question-select option {
    background-color: #1a1a2e;
    color: #fff;
}

#question-select:focus, #question-input:focus {
    border-color: #ec4899; /* 聚焦時變粉色 */
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.3);
    background: rgba(15, 15, 25, 0.95);
}


#controls-area {
    text-align: center;
    padding: 1rem;
    height: auto;
    width: 100%;
}

#draw-btn {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: white;
    font-weight: 600;
    padding: 0.8rem 2.5rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
    position: relative;
    overflow: hidden;
    font-size: 35px;
}

#draw-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 30px rgba(219, 39, 119, 0.7);
}

#draw-btn:active {
    transform: translateY(0);
}

#selection-area {
    width: 100%;
    max-width: 95vw;
    margin: 0 auto;
    height: 30vh;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5vw;
    padding: 0 1rem;
    box-sizing: border-box;
    position: relative;
    transition: padding-top 0.3s ease, height 0.3s ease;
}

.slot {
    width: 14vh;
    height: 23vh;
    border: 2px dashed rgba(106, 106, 142, 0.5) !important;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a0a0c0;
    font-size: 1rem;
    transition: transform 0.3s ease-out;
}

.card {
    width: 13vh;
    height: 22vh;
    position: absolute;
    cursor: pointer;
    border-radius: 12px;
    transition: opacity 0.4s ease, transform 0.7s ease-out, left 0.7s ease-in-out;
    transform-origin: bottom center;
    left: 5%;
    perspective: 1000px;
}


#spread-area .card:not(.is-selected):hover .card-inner {
    transform: translateY(-3vh) scale(1.05);
    z-index: 10;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease; /*移到卡牌上的移動、翻牌效果所需的時間*/
    transform-style: preserve-3d;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
}

.card.is-flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.card-back {
    background-image: url('KatyCard3.png');
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-front {
    transform: rotateY(180deg);
    background-color: #2a2a3a;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    box-sizing: border-box;
    padding: 0.5rem;
    text-align: center;
}

.card-front-name {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin-top: 4px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 15px 5px 8px 5px;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* 卡牌狀態 */
.card.is-selected {
    opacity: 0.2;
    transform: translateY(3vh) scale(0.9);
    pointer-events: none;
}

/* 卡牌飛行動畫 */
.flying-card {
    width: 13vh;
    height: 22vh;
    position: fixed;
    z-index: 1000;
    border-radius: 12px;
    transition: left 1.2s ease-in-out, top 1.2s ease-in-out, transform 1.2s ease-in-out;
    transform-origin: bottom center;
    pointer-events: none;
}

.flying-card .card-inner {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

/* 文字特效 */
.fade-in-text {
    opacity: 0; 
    margin-bottom: 10px; /* 句子間距 */
    font-size: 24px;
    font-weight: bolder;
    line-height: 1.2;
    transform: translateY(10px); 
    animation: textAppear 10s ease-out forwards;
}

@keyframes textAppear {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

#result-text {
    margin: 20px 0;
    text-align: left;
    min-height: 200px;
}