/* Colors reused from the desktop app's palette for continuity */
:root {
    --color-bg: #FFFFFF;
    --color-accent: #F1BF00;
    --color-accent-hover: #FFD84D;
    --color-text: #4A2C17;
    --color-button-text: #7A0F13;
    --color-card: #FFF3CC;
    --color-correct: #1E8449;
    --color-incorrect: #AA151B;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--color-bg);
    font-family: 'Helvetica Neue', Arial, sans-serif;
    color: var(--color-text);
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--color-accent);
}

.navbar .brand {
    font-weight: bold;
    font-size: 1.3rem;
    color: var(--color-button-text);
    text-decoration: none;
}

.nav-links a, .nav-user {
    margin-left: 20px;
    color: var(--color-button-text);
    text-decoration: none;
    font-weight: 600;
}

.nav-links a:hover {
    text-decoration: underline;
}

.flash-messages {
    max-width: 500px;
    margin: 16px auto 0;
}

.flash {
    background: #FDEBD0;
    border-radius: 12px;
    padding: 12px 18px;
    text-align: center;
}

main {
    display: flex;
    justify-content: center;
    padding: 48px 24px;
}

.card {
    text-align: center;
    padding: 40px 56px;
    border-radius: 24px;
    background: var(--color-card);
    max-width: 480px;
    width: 100%;
}

.card.wide {
    max-width: 960px;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header-row h1 {
    margin-bottom: 0;
}

.btn-small {
    font-size: 0.8rem;
    padding: 8px 14px;
    border-radius: 10px;
    white-space: nowrap;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

h2 {
    font-size: 1.3rem;
    margin: 24px 0 8px;
    text-align: left;
}

.hint {
    font-size: 0.9rem;
    opacity: 0.8;
}

form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
    margin-top: 20px;
}

label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    gap: 4px;
}

input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 1rem;
    background: white;
    color: inherit;
}

textarea {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
}

.password-field {
    position: relative;
}

.password-field input {
    width: 100%;
    padding-right: 56px;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    opacity: 0.65;
    cursor: pointer;
    padding: 6px 10px;
}

.password-toggle:hover {
    opacity: 1;
}

.btn {
    background: var(--color-accent);
    color: var(--color-button-text);
    border: none;
    padding: 12px 20px;
    border-radius: 14px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: 8px;
}

.btn:hover {
    background: var(--color-accent-hover);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #e6d8a8;
}

tr.me {
    background: #FFE9A8;
    font-weight: bold;
}

.period-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0 20px;
}

.period-tab {
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: white;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
}

.period-tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

.period-tab--active {
    background: var(--color-accent);
    color: var(--color-button-text);
    border-color: var(--color-accent);
}

.rank-move {
    font-weight: bold;
    white-space: nowrap;
}

.rank-up {
    color: var(--color-correct);
}

.rank-down {
    color: var(--color-incorrect);
}

.rank-same {
    color: var(--color-text);
    opacity: 0.5;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    text-decoration: underline;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.menu-grid--single-column {
    grid-template-columns: 1fr;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.menu-grid--4rows {
    grid-template-columns: none;
    grid-auto-columns: minmax(170px, 1fr);
    grid-template-rows: repeat(4, auto);
    grid-auto-flow: column;
}

.menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--color-accent);
    color: var(--color-button-text);
    border-radius: 14px;
    padding: 16px 12px;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    transition: background 0.15s ease;
}

.menu-btn:hover {
    background: var(--color-accent-hover);
}

.lang-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.lang-row-link {
    flex: 1;
}

.star-form {
    display: flex;
}

.star-btn {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 14px;
    padding: 0 16px;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--color-text);
    cursor: pointer;
}

.star-btn.starred {
    color: #E8A400;
    border-color: #E8A400;
}

.star-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.radio-grid {
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 24px;
}

.radio-tile {
    cursor: pointer;
    user-select: none;
}

.radio-tile input {
    margin-bottom: 4px;
}

.radio-tile:has(input:checked) {
    background: var(--color-correct);
    color: white;
}

/* Compact spacing so the whole Lives + Time Limit form fits on one screen
   without scrolling, without affecting spacing on any other page. */
.settings-card {
    padding-top: 20px;
    padding-bottom: 20px;
}

.settings-card h1 {
    font-size: 1.7rem;
    margin-bottom: 4px;
}

.settings-card h2 {
    font-size: 1.05rem;
    margin: 10px 0 4px;
}

.settings-card .hint {
    margin: 0 0 8px;
    font-size: 0.78rem;
}

.settings-card .radio-grid {
    margin-bottom: 10px;
    gap: 8px;
}

.settings-card .menu-btn {
    padding: 10px 8px;
    font-size: 0.85rem;
}

.settings-card .back-link {
    margin-bottom: 4px;
}

.menu-btn.topic {
    background: #FFDD88;
}

.word-count {
    font-weight: normal;
    font-size: 0.8rem;
    opacity: 0.8;
}

.menu-btn-progress-track {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.menu-btn-progress-fill {
    height: 100%;
    background: var(--color-correct);
}

.progress-track {
    width: 100%;
    height: 14px;
    background: #EAD9A0;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 16px;
}

.progress-fill {
    height: 100%;
    background: var(--color-correct);
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--color-button-text);
    color: var(--color-button-text);
}

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

.quiz-card {
    text-align: center;
}

.quiz-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    opacity: 0.75;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.reinforcement-badge {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-incorrect);
    background: rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    padding: 4px 14px;
    margin-bottom: 8px;
}

.quiz-instruction {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.quiz-prompt {
    font-size: 2.4rem;
    margin: 4px 0 24px;
}

.flashcard {
    text-align: center;
    margin: 8px 0 24px;
}

.flashcard-answer {
    font-size: 2.6rem;
    font-weight: bold;
    color: var(--color-correct);
    margin: 0 0 20px;
}

.quiz-form input {
    width: 100%;
    text-align: center;
    font-size: 1.2rem;
    padding: 14px;
}

.accent-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 24px 0 0;
}

.accent-btn {
    min-width: 34px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: white;
    color: var(--color-text);
    font-size: 1rem;
    cursor: pointer;
}

.accent-btn:hover {
    background: #f0f0f0;
}

.hint-text {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
    margin: -4px 0 12px;
}

.hint-pattern {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 2px;
}

.button-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: 12px;
}

.button-row-item {
    display: flex;
    flex: 1;
    margin: 0;
}

.button-row-item .btn,
.button-row > .btn {
    width: 100%;
    margin: 0;
}

.button-row-item--small {
    flex: 0.7;
}

.button-row-item--small .btn {
    font-size: 0.85rem;
    padding: 10px 12px;
}

.btn-submit-row {
    flex: 1.4;
    padding: 16px 20px;
    font-size: 1.15rem;
}

.quiz-feedback {
    border-radius: 12px;
    padding: 10px 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.quiz-feedback--correct {
    background: #D5F5E3;
    color: var(--color-correct);
}

.quiz-feedback--incorrect {
    background: #FADBD8;
    color: var(--color-incorrect);
}

.quiz-feedback--skip {
    background: #D6EAF8;
    color: #2471A3;
}

.mc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 24px 0;
}

.mc-grid form {
    margin: 0;
}

.mc-btn {
    position: relative;
    width: 100%;
    min-height: 72px;
    background: var(--color-accent);
    color: var(--color-button-text);
    border: none;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 1.26rem;
    line-height: 1.15;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.mc-btn:hover {
    background: var(--color-accent-hover);
}

.mc-btn--hidden {
    background: transparent;
    cursor: default;
}

.mc-badge {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 0.64rem;
    opacity: 0.7;
}

@media (max-width: 560px) {
    .mc-grid {
        grid-template-columns: 1fr;
    }
}

.hearts {
    text-align: center;
    margin-bottom: 16px;
    color: var(--color-incorrect);
}

.hearts-row {
    text-align: center;
    font-size: 2.4rem;
    line-height: 1.3;
    word-spacing: 6px;
    overflow-wrap: break-word;
}

.hearts--infinite {
    color: var(--color-text);
    font-size: 1.1rem;
}

.timer {
    text-align: center;
    margin-bottom: 16px;
}

.timer-track {
    width: 100%;
    height: 10px;
    background: #EAD9A0;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 6px;
}

.timer-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 1s linear;
}

@keyframes timer-flash-green {
    0% { background: var(--color-correct); }
    100% { background: var(--color-accent); }
}

.timer-fill--flash {
    animation: timer-flash-green 0.6s ease;
}

/* Larger hearts and a thicker timer bar - used by both quiz modes */
.quiz-card--large-hud .hearts-row {
    font-size: 3.4rem;
}

.quiz-card--large-hud .timer-track {
    height: 20px;
}

.btn-exit {
    background: transparent;
    border: none;
    color: var(--color-text);
    opacity: 0.6;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 8px 4px;
}

.btn-exit:hover {
    opacity: 1;
    background: transparent;
}

.btn-delete {
    background: var(--color-incorrect);
    color: white;
}

.btn-delete:hover {
    background: #8a1015;
}

