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

body {
    font-family: "Georgia", serif;
    background: #f5f0e8;
    color: #2c2c2c;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
}

header h1 {
    font-size: 2rem;
    color: #3a3226;
    margin-bottom: 0.25rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: #6b5e50;
    text-decoration: none;
    font-size: 0.95rem;
}

.back-link:hover {
    color: #3a3226;
}

.subtitle {
    font-size: 1rem;
    color: #6b5e50;
    font-style: italic;
}

main {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* --- Settings Panel --- */

.settings-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    background: white;
    border-radius: 10px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    align-items: flex-end;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 140px;
}

.setting-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: #5a4630;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.settings-panel select {
    padding: 0.5rem 0.6rem;
    border: 2px solid #d9d0c3;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
    color: #2c2c2c;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b5e50' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    cursor: pointer;
}

.settings-panel select:focus {
    outline: none;
    border-color: #c4a96a;
    box-shadow: 0 0 0 3px rgba(196, 169, 106, 0.2);
}

.settings-panel select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Mode Selector --- */

.mode-selector-group {
    flex-basis: 100%;
}

.mode-selector {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.mode-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mode-group-label {
    font-size: 0.7rem;
    color: #6b5e50;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mode-buttons {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #d9d0c3;
}

.mode-button {
    padding: 0.4rem 0.75rem;
    border: none;
    border-right: 1px solid #d9d0c3;
    background: white;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    color: #6b5e50;
    transition: background 0.2s, color 0.2s;
}

.mode-button:last-child {
    border-right: none;
}

.mode-button.active {
    background: #5a4630;
    color: white;
}

.mode-button:hover:not(.active):not(:disabled) {
    background: #f0ebe3;
}

.mode-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Toggle Buttons (Difficulty) --- */

.toggle-buttons {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #d9d0c3;
}

.toggle-button {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: white;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    color: #6b5e50;
    transition: background 0.2s, color 0.2s;
}

.toggle-button:first-child {
    border-right: 1px solid #d9d0c3;
}

.toggle-button.active {
    background: #5a4630;
    color: white;
}

.toggle-button:hover:not(.active):not(:disabled) {
    background: #f0ebe3;
}

.toggle-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Start Button --- */

.start-button {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    background: #c4a96a;
    color: white;
    transition: background 0.2s, transform 0.1s;
    align-self: flex-end;
}

.start-button:hover:not(:disabled) {
    background: #b09555;
}

.start-button:active:not(:disabled) {
    transform: scale(0.98);
}

.start-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.start-button.secondary {
    background: white;
    color: #5a4630;
    border: 2px solid #d9d0c3;
}

.start-button.secondary:hover:not(:disabled) {
    background: #f0ebe3;
}

/* --- Score Bar --- */

.score-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    background: white;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    font-size: 0.95rem;
    flex-wrap: wrap;
}

.score-bar strong {
    color: #5a4630;
}

#timer-display strong {
    font-variant-numeric: tabular-nums;
    min-width: 3.5rem;
    display: inline-block;
    text-align: center;
}

/* --- Form --- */

.form-row select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f0ebe3;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #6b5e50;
    font-style: italic;
}

.hidden {
    display: none !important;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.verse-text {
    background: white;
    border-left: 4px solid #c4a96a;
    border-radius: 0 10px 10px 0;
    padding: 1.5rem 1.75rem;
    font-size: 1.1rem;
    line-height: 1.7;
    color: #3a3226;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    font-style: italic;
}

.guess-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-row label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #5a4630;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-row select {
    padding: 0.65rem 0.75rem;
    border: 2px solid #d9d0c3;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: #2c2c2c;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b5e50' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
}

.form-row select:focus {
    outline: none;
    border-color: #c4a96a;
    box-shadow: 0 0 0 3px rgba(196, 169, 106, 0.2);
}

.submit-button,
.next-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.submit-button {
    background: #5a4630;
    color: white;
}

.submit-button:hover:not(:disabled) {
    background: #3a3226;
}

.submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.submit-button:active:not(:disabled) {
    transform: scale(0.98);
}

/* --- Result --- */

.result {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.points-display {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.round-bonus {
    font-size: 0.95rem;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.bonus-positive {
    color: #2e7d32;
}

.bonus-negative {
    color: #d32f2f;
}

.result p {
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

.result-reference {
    font-weight: bold;
    color: #5a4630;
    font-size: 1.1rem !important;
}

.next-button {
    margin-top: 1rem;
    background: #c4a96a;
    color: white;
}

.next-button:hover {
    background: #b09555;
}

.next-button:active {
    transform: scale(0.98);
}

/* --- End Screen --- */

.end-screen {
    background: white;
    border-radius: 10px;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.end-screen h2 {
    margin-bottom: 1.5rem;
    color: #3a3226;
    font-size: 1.6rem;
}

.end-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.end-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.end-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6b5e50;
    letter-spacing: 0.05em;
}

.end-stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #5a4630;
}

.high-score-banner {
    background: #c4a96a;
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: bold;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    animation: pulse 1s ease-in-out 3;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.end-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* --- Countdown Overlay --- */

.countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.countdown-number {
    font-size: 6rem;
    font-weight: bold;
    color: white;
    font-family: "Georgia", serif;
    animation: countPulse 1s ease-in-out infinite;
}

@keyframes countPulse {
    0% { transform: scale(1.3); opacity: 0.6; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.3); opacity: 0.6; }
}

/* --- Milestone Toasts --- */

.milestone-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.milestone-toast {
    background: #5a4630;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: bold;
    font-family: "Georgia", serif;
    animation: slideInOut 2.5s ease-in-out forwards;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

@keyframes slideInOut {
    0% { opacity: 0; transform: translateX(100%); }
    15% { opacity: 1; transform: translateX(0); }
    75% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(100%); }
}
