:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-heading: 'Inter', 'Noto Sans TC', sans-serif;
    --font-body: 'Inter', 'Noto Sans TC', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    background-attachment: fixed;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

#app {
    width: 100%;
    max-width: 800px;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}
.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typography */
h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
    background: -webkit-linear-gradient(45deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

p {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 2rem;
}

.instruction {
    text-align: left;
    margin-bottom: 1.5rem;
}

/* Buttons */
button {
    font-family: var(--font-body);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}
.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.success-btn {
    background-color: var(--success-color);
    color: white;
}
.success-btn:hover {
    background-color: var(--success-hover);
    transform: translateY(-2px);
}

.header-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}
.header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}
.menu-buttons button {
    padding: 1rem;
    font-size: 1.125rem;
    width: 100%;
}

.option-group {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.select-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
}
.glass-select {
    background: rgba(0,0,0,0.3);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}
.glass-select option {
    background: var(--bg-color);
}

/* Header */
.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

/* Dictation List */
.question-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.question-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.question-item:focus-within {
    border-color: var(--primary-color);
}

.question-num {
    background: var(--primary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

.question-prompt {
    width: 150px;
    font-weight: 500;
    font-size: 1.125rem;
}

.question-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.question-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.actions {
    display: flex;
    justify-content: flex-end;
}

/* Identification Mode */
.identification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 1.5rem;
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.875rem;
}

.timer-container {
    flex: 1;
    margin: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timer-bar {
    height: 8px;
    background: var(--success-color);
    flex: 1;
    border-radius: 4px;
    transition: width 1s linear, background-color 0.5s;
    width: 100%;
}

.timer-bar.warning {
    background: #f59e0b;
}

.timer-bar.danger {
    background: var(--danger-color);
}

#timer-text {
    font-weight: 700;
    font-family: monospace;
    font-size: 1.25rem;
    width: 3ch;
}

.image-container {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    overflow: hidden;
    position: relative;
    padding: 0;
}

#plant-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

#image-placeholder {
    color: #94a3b8;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.2);
}

.options-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1.5rem;
}

.option-btn {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 1rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    outline: none;
}

.option-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.option-btn.selected {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white;
}

/* Results Screen */
.score-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 2rem;
    border: 1px solid var(--primary-color);
}

.score-label {
    display: block;
    font-size: 1.25rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    align-items: center;
}

.result-item.correct {
    border-left: 4px solid var(--success-color);
}

.result-item.incorrect {
    border-left: 4px solid var(--danger-color);
}

.result-prompt {
    font-weight: 500;
    width: 120px;
}

.result-answer {
    flex: 1;
    color: #cbd5e1;
}

.result-answer.wrong {
    text-decoration: line-through;
    color: #ef4444;
    margin-right: 0.5rem;
}

.result-correct-answer {
    color: var(--success-color);
    font-weight: 500;
}

.status-icon {
    font-size: 1.25rem;
}

.result-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 1.5rem;
    flex-shrink: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
.result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center; justify-content: center;
    z-index: 1000;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
}
.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: transparent; color: white;
    font-size: 1.5rem; border: none; cursor: pointer;
    padding: 0 0.5rem;
}
.review-image-container {
    height: 250px;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
    text-align: center;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
.review-image-container img {
    max-width: 100%; max-height: 100%; object-fit: contain;
}
.review-details p {
    color: white;
    text-align: left;
    margin-bottom: 0.5rem;
}
.review-hint-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.15);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    text-align: left;
}
.review-hint-box h4 {
    margin-bottom: 0.5rem;
    color: #60a5fa;
}
.result-item.clickable {
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}
.result-item.clickable:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.15);
}

/* Flashcard Mode */
.flashcard-container {
    background: transparent;
    width: 100%;
    height: 400px;
    perspective: 1000px; /* 3D 視角 */
    margin-bottom: 1.5rem;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1); /* 平滑翻轉 */
    transform-style: preserve-3d;
}

.flashcard-container.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.flashcard-front {
    align-items: center;
    justify-content: center;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--bg-color); /* 翻轉後的背景 */
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto; /* 若字太多可滾動 */
    padding: 2rem;
}

#flashcard-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

#flashcard-placeholder {
    color: #94a3b8;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.flashcard-instruction {
    position: absolute;
    bottom: 1rem;
    background: rgba(0,0,0,0.5);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    color: #cbd5e1;
    font-size: 0.875rem;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.flashcard-name {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
    width: 100%;
    text-align: left;
}

.flashcard-hint-text {
    line-height: 1.6;
    color: #e2e8f0;
    font-size: 1.1rem;
    text-align: left;
}

.flashcard-controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.btn-sm {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    flex: 1;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}
