* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Helvetica Neue", Helvetica, Arial, "PingFang TC", "微軟正黑體", sans-serif;
    background-color: #f4f4f9;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center; 
    height: 100dvh; 
    overflow: hidden; 
    padding: 10px 10px 0 10px; 
}

.container {
    background-color: #ffffff;
    width: 100%;
    max-width: 400px;
    max-height: calc(100dvh - 85px); 
    margin-bottom: 60px; 
    overflow-y: auto; 
    padding: 20px 20px 0 20px; 
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
    -ms-overflow-style: none; 
    scrollbar-width: none; 
}

.container::-webkit-scrollbar {
    display: none;
}

/* ⭐️ 替換：中國風廟宇紅頂部導覽列 */
.temple-header {
    background: linear-gradient(135deg, #c62828 0%, #8e0000 100%); /* 深紅/暗紅漸層 */
    color: #ffffff;
    margin: -20px -20px 20px -20px; 
    padding: 18px 20px;
    border-radius: 12px 12px 24px 24px; /* 上方對齊外框，下方做圓弧 */
    display: flex;
    align-items: center; 
    flex-wrap: wrap; 
    gap: 6px 12px;
    box-shadow: 0 6px 12px rgba(183, 28, 28, 0.25); /* 紅色系陰影 */
    text-align: left;
    border-bottom: 3px solid #ffd54f; /* 底部加入金色飾條增添中國風 */
}

.temple-title-text {
    font-size: 23px;
    font-weight: 900;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 2px;
    color: #ffd54f; /* 主標題改為廟宇金 */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3); /* 增加立體感 */
}

.temple-subtitle {
    font-size: 11px;
    color: #ffecb3; /* 淺金色調 */
    font-weight: 500;
    letter-spacing: 1px;
    margin-top: 4px; 
}

.prayer-card {
    text-align: left;
    background-color: #fafafa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eeeeee;
    margin-bottom: 20px;
}

.step-box {
    margin-bottom: 15px;
}

.step-box:last-child {
    margin-bottom: 0;
}

.step-box label {
    font-size: 15px;
    font-weight: bold;
    color: #b71c1c; 
    display: block; 
    margin-bottom: 8px; 
}

.step-box input, 
.step-box select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    background-color: #ffffff;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.step-box input:focus, 
.step-box select:focus {
    border-color: #b71c1c;
    box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.1); 
}

.prayer-script-box {
    background-color: #fffaf0; 
    border-left: 5px solid #ff9800;
    padding: 15px 20px;
    margin-bottom: 25px; 
    border-radius: 6px;
    text-align: left;
}

.script-title {
    font-size: 14px;
    color: #555; 
    font-weight: bold;
    margin-bottom: 8px;
}

#prayerScript {
    color: #d84315; 
    font-weight: bold;
    line-height: 1.6;
    font-size: 16px;
}

button#drawBtn {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    background-color: #d32f2f; 
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.3);
}

button#drawBtn:hover:not(:disabled) {
    background-color: #b71c1c; 
    transform: translateY(-2px); 
}

button#drawBtn:disabled {
    background-color: #cccccc;
    color: #888888;
    cursor: not-allowed;
    box-shadow: none;
}

.download-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #2e7d32; 
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 6px rgba(46, 125, 50, 0.3);
}

.download-btn:hover:not(:disabled) {
    background-color: #1b5e20;
}

.card {
    margin-top: 15px;
    padding: 15px 15px; 
    background-color: #fffaf0; 
    border: 2px solid #b71c1c; 
    position: relative;
    border-radius: 6px;
    transition: opacity 0.5s ease;
}

.card::before {
    content: "";
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px solid #b71c1c;
    pointer-events: none;
    border-radius: 4px;
}

.result-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 12px;
}

#resultGrade {
    color: #d84315;
    font-size: 28px;
    font-weight: 900;
    margin: 0;
}

.stick-number {
    background-color: transparent;
    color: #c62828;
    border: 2px solid #c62828;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
}

.stick-name {
    font-size: 18px;
    font-weight: bold;
    color: #555;
}

.main-text {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.5;
    letter-spacing: 2px;
}

.explanation-box {
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    padding: 10px 15px;
    margin-top: 10px;
    text-align: left;
    border-left: 4px solid #b71c1c;
}

.explanation-box strong {
    color: #b71c1c;
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
}

#resultExplanation {
    font-size: 15px;
    line-height: 1.6;
    color: #444;
}

.card-footer {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #d32f2f; 
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #b71c1c;
    opacity: 0.7; 
}

footer {
    width: 100%; 
    margin-top: 30px; 
    padding: 25px 0; 
    border-top: 1px solid #eee;
    text-align: center; 
    font-size: 12px; 
    color: #777; 
    background-color: #fff;
}

.footer-copyright {
    padding: 0 15px;
    line-height: 1.6; 
}

.footer-copyright a {
    color: #b71c1c;
    text-decoration: none;
    font-weight: bold;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-bottom: 15px;
    padding: 0 10px;
}

.footer-nav button {
    background: #f4f4f9;
    color: #555;
    border: 1px solid #ddd;
    padding: 8px 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    flex: 1;
    white-space: nowrap;
    transition: all 0.2s;
}

.footer-nav button.share-btn {
    background-color: #b71c1c;
    color: #fff;
    border-color: #b71c1c;
}

.footer-nav button:hover {
    background-color: #e0e0e0;
}

.footer-nav button.share-btn:hover {
    background-color: #8e0000;
}

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

.bottom-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #777; 
    font-size: 11px;
    font-weight: 600;
    gap: 4px;
    transition: color 0.2s;
    flex: 1;
}

.bottom-bar a:hover {
    color: #b71c1c; 
}

.bottom-bar .icon {
    font-size: 22px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: #fffaf0;
    max-width: 340px;
    width: 90%;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    border: 2px solid #b71c1c;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eebb99;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #b71c1c;
    color: white;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #fff;
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    line-height: 1.6;
    color: #333;
    font-size: 15px;
    text-align: left;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shaking {
    animation: shake 0.5s infinite;
    background-color: #f57c00 !important;
    color: #fff;
    box-shadow: none !important;
}

.fade-in {
    animation: fadeIn 0.8s ease-in-out;
}

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

.hidden {
    display: none !important;
}
