:root {
    --primary-color: #3e4a59;
    --secondary-color: #8b2b2b;
    --bg-color: #f4f1ea;
    --text-color: #1a1a1a;
    --border-color: #a69e8b;
    --modal-bg: rgba(0, 0, 0, 0.6);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Serif TC', serif;
    background-color: var(--bg-color);
    background-image: url('bg.png'); /* 水墨畫背景 */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(244, 241, 234, 0.7);
    z-index: -1;
}

.container {
    width: 90%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 4rem;
    color: var(--secondary-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    margin: 10px 0;
    letter-spacing: 5px;
}

.subtitle {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}

.wheel-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto 40px;
}

canvas {
    width: 100%;
    height: auto;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    transition: transform 5s cubic-bezier(0.25, 0.1, 0.15, 1);
    background: #fff;
    border: 5px solid #d6c5b3;
}

.pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    color: var(--secondary-color);
    z-index: 10;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#spin-btn {
    margin-top: -30px;
    z-index: 10;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 2rem;
    padding: 10px 40px;
    border: none;
    border-radius: 30px;
    background-color: var(--secondary-color);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

#spin-btn:hover {
    background-color: #a83232;
    transform: scale(1.05);
}

#spin-btn:disabled {
    background-color: #666;
    cursor: not-allowed;
    transform: none;
}

/* 歷史紀錄區塊 */
.history-section {
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.history-section h3 {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    color: var(--primary-color);
    margin-top: 0;
}

#history-list {
    list-style: none;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

#history-list li {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 1.1rem;
    animation: fadeIn 0.5s;
}

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

footer {
    text-align: center;
    padding: 20px;
    width: 100%;
    background: rgba(244, 241, 234, 0.9);
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-top: 15px;
}

#admin-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

#admin-btn:hover {
    background: var(--primary-color);
    color: white;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.hint {
    color: #666;
    font-size: 0.9rem;
}

textarea {
    width: 100%;
    padding: 10px;
    font-family: inherit;
    border: 1px solid #ccc;
    border-radius: 5px;
    resize: vertical;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
}

.primary-btn { background: var(--primary-color); color: white; }
.secondary-btn { background: #ccc; color: black; }
.danger-btn { background: var(--secondary-color); color: white; }

#result-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 15px;
    border: 2px solid var(--secondary-color);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    text-align: center;
    z-index: 100;
    min-width: 300px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#result-display.hidden {
    display: none;
}

#result-display h2 {
    color: var(--secondary-color);
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 2.5rem;
    margin-top: 0;
}

#result-text {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 20px 0;
    line-height: 1.5;
}

#close-result-btn {
    background: var(--primary-color);
    color: white;
    font-size: 1.2rem;
    padding: 10px 30px;
}

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

@media (max-width: 600px) {
    h1 { font-size: 2.5rem; }
    canvas { width: 100%; height: auto; }
}
