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

body {
    font-family: 'Microsoft JhengHei', '微軟正黑體', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

header h1 {
    font-size: 2.2em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

main {
    padding: 40px 30px;
}

.step {
    animation: fadeIn 0.5s ease-in;
}

.step.hidden {
    display: none;
}

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

h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.hint {
    color: #666;
    margin-bottom: 25px;
    font-style: italic;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: inline-block;
    width: 150px;
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.dropdown {
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.dropdown:hover {
    border-color: #667eea;
}

.dropdown:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.palace-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(72px, 1fr));
    grid-auto-rows: 64px;
    gap: 10px;
    margin: 30px auto;
    max-width: 520px;
}

.palace-cell {
    width: 100%;
    height: 100%;
    border: 2px solid #ddd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    background: #f8f9fa;
}

.palace-cell:hover {
    border-color: #667eea;
    background: #e8ecff;
}

.palace-cell.selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: scale(1.05);
}

.center-text {
    grid-column: 2 / span 2;
    grid-row: 2 / span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #667eea;
    border: 2px dashed #c9d2ff;
    border-radius: 8px;
    background: #f5f7ff;
}

.selected-palace {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.selected-palace label {
    font-weight: 600;
    color: #333;
    margin-right: 10px;
}

.selected-palace span {
    font-weight: 600;
    color: #667eea;
}

.btn-primary,
.btn-secondary {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.question-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.question-section h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    cursor: pointer;
}

#results {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.result-item {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.result-item h3 {
    color: #28a745;
    margin-bottom: 10px;
}

.result-item .main-result {
    color: #333;
    line-height: 1.6;
    font-size: 1.2em;
    font-weight: 600;
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 8px;
    margin: 15px 0;
}

.result-item p {
    color: #333;
    line-height: 1.6;
}

.warning {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.warning p {
    color: #856404;
    margin: 0;
}

@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
    }

    header h1 {
        font-size: 1.8em;
    }

    .form-group label {
        display: block;
        margin-bottom: 5px;
    }

    .dropdown {
        width: 100%;
    }

    .palace-cell {
        font-size: 14px;
    }

    .palace-grid {
        grid-template-columns: repeat(4, minmax(60px, 1fr));
        grid-auto-rows: 50px;
        font-size: 14px;
    }

    .center-text { font-size: 14px; }
}
