:root {
    --bg-color: #fce4ec;
    --clock-bg: #ffffff;
    --clock-border: #f8bbd0;
    --hand-hour: #5c6bc0;
    --hand-minute: #ffb74d;
    --center-dot: #ef5350;
    --text-color: #37474f;
    --number-color: #37474f;
    --primary-btn: #ab47bc;
    --primary-hover: #9c27b0;
    --secondary-btn: #29b6f6;
    --secondary-hover: #039be5;
    --success-btn: #66bb6a;
    --success-hover: #43a047;
    --btn-text: #ffffff;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --input-border: #ce93d8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    font-family: 'Nunito', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: none;
}

.app-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1100px;
    height: 100vh;
    padding: 20px;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

.app-container.teacher-mode {
    display: none !important;
}

/* --- Clock Section --- */
.clock-section {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.mode-indicator {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-btn);
    background: white;
    padding: 8px 25px;
    border-radius: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.clock-frame {
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1 / 1;
    background: var(--clock-border);
    border-radius: 50%;
    padding: 18px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1), inset 0 5px 15px rgba(255, 255, 255, 0.5);
    position: relative;
    pointer-events: none;
}

.clock-face {
    width: 100%;
    height: 100%;
    background: var(--clock-bg);
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
}

.center-dot {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--center-dot);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.hand-container {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    z-index: 5;
    cursor: grab;
    pointer-events: auto;
}

.hand-container:active {
    cursor: grabbing;
}

.hour-container {
    width: 40px;
    height: 30%;
    margin-left: -20px;
}

.minute-container {
    width: 40px;
    height: 42%;
    margin-left: -20px;
}

.hand {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.hour-hand {
    width: 14px;
    height: 100%;
    background: var(--hand-hour);
}

.minute-hand {
    width: 10px;
    height: 100%;
    background: var(--hand-minute);
}

.clock-number {
    position: absolute;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--number-color);
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 50%;
    left: 50%;
    margin-left: -25px;
    margin-top: -25px;
}

.interaction-mode-toggle {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-color);
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

.hidden-element {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

/* --- Controls Section --- */
.controls-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-radius: 25px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.05);
    max-width: 450px;
    overflow: hidden;
    height: 100%;
    max-height: 100%;
}

.tabs {
    display: flex;
    width: 100%;
    background: #e1bee7;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 15px 0;
    border: none;
    background: none;
    font-size: 1.2rem;
    font-weight: 800;
    color: #7b1fa2;
    cursor: pointer;
    transition: background 0.2s;
}

.tab-btn.active {
    background: var(--panel-bg);
    color: var(--primary-btn);
}

.tab-content {
    display: none;
    padding: 20px 15px;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    overflow-y: auto;
}

.tab-content.active-tab {
    display: flex;
}

.section-title {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary-btn);
    text-align: center;
    margin-bottom: 5px;
}

.section-desc {
    font-size: 1rem;
    color: #607d8b;
    text-align: center;
}

/* Buttons */
.action-btn {
    border: none;
    padding: 14px 20px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s, filter 0.2s;
    color: var(--btn-text);
    width: 100%;
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.action-btn.primary {
    background: var(--primary-btn);
}

.action-btn.secondary {
    background: var(--secondary-btn);
}

.action-btn.success {
    background: var(--success-btn);
}

.small-btn {
    padding: 10px 15px;
    font-size: 1.1rem;
}

/* Answer Key */
.answer-key-container {
    width: 100%;
    background: #f3e5f5;
    border: 3px solid #e1bee7;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.3s;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.answer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--hand-hour);
}

.answer-value {
    color: var(--primary-hover);
    font-size: 1.6rem;
    background: white;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* ============================
   EXERCISE LIST STYLES
   ============================ */

#exercise-list-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.level-group {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
}

.level-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #eee;
}

.level-icon {
    font-size: 1.3rem;
}

.level-title {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--text-color);
}

.level-exercises {
    display: flex;
    flex-direction: column;
}

.exercise-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border-bottom: 1px solid #f5f5f5;
}

.exercise-item:last-child {
    border-bottom: none;
}

.exercise-item:hover {
    background: #fce4ec;
}

.exercise-item:active {
    transform: scale(0.98);
    background: #f8bbd0;
}

.ex-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.ex-type-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.ex-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ex-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ex-meta {
    font-size: 0.78rem;
    font-weight: 600;
    color: #90a4ae;
}

.ex-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ex-stars {
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.ex-score {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--success-btn);
    background: #e8f5e9;
    padding: 3px 8px;
    border-radius: 10px;
}

.ex-not-done {
    font-size: 0.78rem;
    font-weight: 700;
    color: #bdbdbd;
    font-style: italic;
}

/* ============================
   QUIZ / TEST AREA STYLES
   ============================ */

.progress-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.progress-bar-track {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-btn), #2196f3);
    border-radius: 10px;
    transition: width 0.4s ease;
    width: 0%;
}

.question-counter-text {
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-btn);
    text-align: center;
}

.progress-stars {
    font-size: 0.9rem;
    text-align: center;
    letter-spacing: 2px;
    min-height: 20px;
    cursor: pointer;
}

.styled-select {
    width: 100%;
    padding: 10px;
    font-size: 1.1rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background: #fff;
    outline: none;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-color);
}

.text-center {
    text-align: center;
    text-align-last: center;
}

.question-container {
    width: 100%;
    background: #fff;
    border: 4px dashed var(--secondary-btn);
    border-radius: 20px;
    padding: 20px 10px;
    text-align: center;
    margin-bottom: 15px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--secondary-hover);
    line-height: 1.3;
}

.read-inputs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.read-inputs .custom-select-wrapper {
    width: auto;
    min-width: 80px;
    flex: 1;
    max-width: 140px;
}
.read-inputs .custom-select-btn {
    justify-content: center;
}

.colon {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-color);
}

.action-buttons {
    width: 100%;
}

.feedback-msg {
    width: 100%;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 900;
    min-height: 35px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: scale(0.9);
    margin-top: 10px;
}

.feedback-msg.show {
    opacity: 1;
    transform: scale(1);
}

.feedback-msg.correct {
    color: var(--success-btn);
}

.feedback-msg.wrong {
    color: #ef5350;
}

/* Shake animation */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0) scale(1);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-4px) scale(1);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(4px) scale(1);
    }
}

.shake {
    animation: shake 0.5s ease;
}

/* ============================
   RESULT OVERLAY
   ============================ */

#result-overlay {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.result-card {
    width: 100%;
    background: linear-gradient(145deg, #ffffff 0%, #fce4ec 100%);
    border-radius: 24px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    animation: resultSlideIn 0.5s ease;
}

@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.result-emoji {
    font-size: 3.5rem;
    margin-bottom: 8px;
    animation: resultBounce 0.6s ease 0.3s both;
}

@keyframes resultBounce {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

.result-title {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-btn);
    margin-bottom: 10px;
}

.result-stars {
    font-size: 2rem;
    letter-spacing: 6px;
    margin-bottom: 12px;
}

.result-score {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--success-btn);
    margin-bottom: 10px;
}

.result-details {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #607d8b;
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    gap: 10px;
}

.result-actions .action-btn {
    flex: 1;
    padding: 12px 10px;
    font-size: 1rem;
}

/* ============================
   RESPONSIVE — MOBILE PORTRAIT
   ============================ */

@media screen and (max-width: 768px) {
    body {
        align-items: stretch;
        overflow-y: auto;
        padding: 0 10px 10px;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 50px);
        padding: 0;
        padding-top: 58px;
        gap: 15px;
        justify-content: flex-start;
    }

    .clock-section {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        gap: 10px;
        padding-top: 10px;
    }

    .clock-frame {
        max-width: 320px;
        padding: 12px;
    }

    .clock-number {
        font-size: 1.8rem;
        width: 40px;
        height: 40px;
        margin-left: -20px;
        margin-top: -20px;
    }

    .mode-indicator {
        font-size: 1.3rem;
        padding: 6px 20px;
    }

    .controls-section {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
    }

    .tab-content {
        padding: 15px 12px;
    }

    .exercise-item {
        padding: 10px 12px;
    }

    .ex-name {
        font-size: 0.88rem;
    }

    .level-header {
        padding: 10px 12px;
    }

    .level-title {
        font-size: 0.95rem;
    }

    .question-text {
        font-size: 1.3rem;
    }

    .result-card {
        padding: 20px 15px;
    }

    .result-title {
        font-size: 1.5rem;
    }

    .result-score {
        font-size: 1.3rem;
    }

    .result-actions {
        flex-direction: column;
    }
}

/* ============================
   MOBILE: Small Phones
   ============================ */
@media screen and (max-width: 480px) {
    /* Tabs scroll instead of wrap */
    .tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
        padding-bottom: 2px;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.85rem;
        padding: 6px 14px;
    }
}

/* ============================
   MOBILE LANDSCAPE
   ============================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .app-container {
        flex-direction: row;
        align-items: flex-start;
        padding-top: 55px;
        height: auto;
        min-height: 100vh;
    }

    .clock-section {
        flex: 0 0 auto;
        width: 45vw;
        max-width: 280px;
        position: sticky;
        top: 55px;
    }

    .clock-frame {
        max-width: 240px;
    }

    .controls-section {
        flex: 1;
        overflow-y: auto;
        max-height: calc(100vh - 55px);
    }

    .mode-indicator {
        font-size: 1.1rem;
        padding: 5px 14px;
    }
}

@media screen and (max-width: 380px) {
    .clock-frame {
        max-width: 260px;
    }

}

/* ============================
   TOP NAVIGATION
   ============================ */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 50px;
    background: var(--primary-btn);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 14px;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Sol: kullanıcı adı + alt başlık */
.nav-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
}

.nav-user-name {
    font-weight: 800;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.nav-user-sub {
    font-size: 0.72rem;
    opacity: 0.82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* Sağ: ikon butonlar */
.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nav-icon-btn {
    background: rgba(255,255,255,0.18);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    padding: 5px 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    line-height: 1;
}

.nav-icon-btn:active { background: rgba(255,255,255,0.32); }

.nav-logout-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.22);
}

/* Adjust app-container to account for top nav */
.app-container {
    padding-top: 68px;
}

/* Teacher dashboard: also push below top-nav */
#teacher-dashboard {
    padding-top: 60px !important;
}

/* ============================
   AUTH OVERLAY & ROLE SELECTION
   ============================ */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    transition: opacity 0.3s;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.auth-card h2 {
    color: var(--primary-hover);
    margin-bottom: 10px;
    font-size: 2rem;
}

.auth-card p {
    color: #607d8b;
    margin-bottom: 25px;
}

.role-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.styled-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s;
}

.styled-input:focus {
    border-color: var(--primary-btn);
}

/* ============================
   TEACHER DASHBOARD
   ============================ */
.teacher-mode .clock-section,
.teacher-mode .controls-section {
    display: none !important;
    /* Hide old UI in teacher mode */
}

#teacher-dashboard {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.dashboard-header h2 {
    color: var(--primary-btn);
    font-size: 1.8rem;
}

.code-box {
    background: #fff3e0;
    border: 2px dashed #ffb74d;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 1.2rem;
    color: #e65100;
    display: flex;
    align-items: center;
    gap: 10px;
}

.code-box strong {
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.teacher-table {
    width: 100%;
    border-collapse: collapse;
}

.teacher-table th {
    background: #f5f5f5;
    padding: 12px;
    text-align: left;
    color: #607d8b;
    font-weight: 800;
}

.teacher-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.student-row {
    cursor: pointer;
    transition: background 0.2s;
}

.student-row:hover {
    background: #f9fbe7;
}

.score-pct {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--success-btn);
}

.score-raw {
    font-size: 0.85rem;
    color: #90a4ae;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #90a4ae;
    font-size: 1.1rem;
    font-style: italic;
}

.loading {
    text-align: center;
    padding: 20px;
    color: var(--secondary-btn);
    font-weight: 800;
}

.error {
    text-align: center;
    padding: 20px;
    color: #e53935;
    background: #ffebee;
    border-radius: 8px;
}

/* ============================
   TEXT QUESTION MODE
   ============================ */
/* When question type is 'text', show both the text prompt and the answer inputs stacked */
.question-container.text-mode {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.question-container.text-mode .question-text {
    font-size: 1.7rem;
    border-bottom: 2px dashed var(--secondary-btn);
    padding-bottom: 10px;
}

.question-container.text-mode .read-inputs {
    justify-content: center;
}


/* ============================
   RESPONSIVE — TABLET (769-1024px)
   ============================ */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .app-container {
        gap: 20px;
        padding: 70px 15px 15px;
        max-width: 100%;
    }

    .clock-frame {
        max-width: 360px;
    }

    .clock-number {
        font-size: 1.9rem;
        width: 44px;
        height: 44px;
        margin-left: -22px;
        margin-top: -22px;
    }

    .controls-section {
        max-width: 380px;
    }

    #teacher-dashboard {
        padding: 70px 15px 20px !important;
    }
}

/* ============================
   RESPONSIVE — MOBILE PORTRAIT (≤768px)
   Better overrides
   ============================ */
@media screen and (max-width: 768px) {
    /* Teacher dashboard mobile */
    #teacher-dashboard {
        padding: 65px 10px 20px !important;
        border-radius: 0;
        box-shadow: none;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding-bottom: 15px;
        margin-bottom: 15px;
    }

    .dashboard-header h2 {
        font-size: 1.4rem;
    }

    .code-box {
        font-size: 1rem;
        padding: 8px 14px;
        width: 100%;
        justify-content: space-between;
    }

    .code-box strong {
        font-size: 1.2rem;
    }

    .dashboard-content {
        padding: 0;
    }

    /* Teacher table horizontal scroll on mobile */
    .teacher-table-wrapper,
    #td-student-list,
    #td-assignments-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .teacher-table {
        min-width: 480px;
    }

    .teacher-table th,
    .teacher-table td {
        padding: 10px 8px;
        font-size: 0.88rem;
    }

    /* Question container text mode on mobile */
    .question-container.text-mode .question-text {
        font-size: 1.4rem;
    }

    /* Larger tap targets for action buttons */
    .action-btn {
        padding: 16px 20px;
        font-size: 1.1rem;
    }

    .styled-select {
        padding: 12px 8px;
        font-size: 1rem;
    }
}

/* ============================
   MOBILE: Small Phones (≤480px)
   ============================ */
@media screen and (max-width: 480px) {
    body {
        padding: 0;
    }

    .app-container {
        gap: 10px;
        padding-top: 58px;
    }

    .clock-section {
        padding-top: 0;
        gap: 8px;
    }

    .clock-frame {
        max-width: 270px;
        padding: 10px;
    }

    .clock-number {
        font-size: 1.6rem;
        width: 36px;
        height: 36px;
        margin-left: -18px;
        margin-top: -18px;
    }

    .mode-indicator {
        font-size: 1.1rem;
        padding: 5px 16px;
    }

    .controls-section {
        border-radius: 16px 16px 0 0;
    }

    .tab-content {
        padding: 12px 10px;
        gap: 10px;
    }

    .section-title {
        font-size: 1.6rem;
    }

    .question-text {
        font-size: 1.2rem;
    }

    .question-container.text-mode .question-text {
        font-size: 1.15rem;
    }

    .action-btn {
        padding: 14px 16px;
        font-size: 1rem;
        border-radius: 40px;
    }

    .styled-select {
        padding: 10px 6px;
        font-size: 0.95rem;
    }

    .feedback-msg {
        font-size: 1.2rem;
    }

    /* Progress stars bigger touch area */
    .progress-stars {
        font-size: 1rem;
        letter-spacing: 3px;
        min-height: 28px;
        line-height: 28px;
    }

    /* Teacher dashboard on small phones */
    #teacher-dashboard {
        padding: 60px 8px 15px !important;
    }

    .dashboard-header h2 {
        font-size: 1.2rem;
    }
}

/* ============================
   MOBILE LANDSCAPE (short screens)
   ============================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .app-container {
        padding-top: 52px;
        gap: 12px;
    }

    .clock-frame {
        max-width: 200px;
        padding: 8px;
    }

    .clock-number {
        font-size: 1.4rem;
        width: 32px;
        height: 32px;
        margin-left: -16px;
        margin-top: -16px;
    }

    .mode-indicator {
        font-size: 0.9rem;
        padding: 4px 12px;
    }

    .question-container {
        min-height: 70px;
        padding: 12px 8px;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .action-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .tab-content {
        padding: 10px 8px;
        gap: 8px;
    }

    .section-title {
        font-size: 1.3rem;
    }
}

/* ============================
   ANDROID TABLET PORTRAIT (601-768px)
   ============================ */
@media screen and (min-width: 601px) and (max-width: 768px) and (orientation: portrait) {
    .app-container {
        flex-direction: row;
        align-items: center;
        height: 100vh;
        padding: 65px 15px 15px;
        gap: 20px;
    }

    .clock-section {
        flex: 0 0 auto;
        width: 280px;
        padding-top: 0;
    }

    .clock-frame {
        max-width: 280px;
    }

    .controls-section {
        flex: 1;
        max-width: none;
        height: calc(100vh - 90px);
        border-radius: 20px;
    }
}

/* ============================
   ANDROID TABLET LANDSCAPE (769-1024px landscape)
   ============================ */
@media screen and (min-width: 769px) and (max-width: 1100px) and (orientation: landscape) {
    .app-container {
        padding: 65px 20px 15px;
        gap: 25px;
    }

    .clock-frame {
        max-width: 340px;
    }

    .controls-section {
        max-width: 420px;
    }
}
/* ============================
   ÖĞLEDEN ÖNCE / SONRA BUTONLARI
   ============================ */
.ampm-answer-area {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 12px;
}

.ampm-btn {
    flex: 1;
    padding: 16px 8px;
    border-radius: 20px;
    border: 3px solid transparent;
    font-size: 1rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    line-height: 1.4;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.ampm-btn:active:not(:disabled) {
    transform: scale(0.94);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.ampm-btn-am {
    background: linear-gradient(135deg, #fff9c4, #ffe082);
    border-color: #ffc107;
    color: #e65100;
}

.ampm-btn-pm {
    background: linear-gradient(135deg, #e8eaf6, #c5cae9);
    border-color: #5c6bc0;
    color: #1a237e;
}

.ampm-btn:disabled {
    cursor: not-allowed;
    transform: none;
}

/* ============================
   SENKRONIZASYON GÖSTERGESİ
   ============================ */
.sync-btn {
    position: relative;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sync-btn:active { background: rgba(255,255,255,0.3); }

.sync-icon {
    font-size: 16px;
    color: white;
    line-height: 1;
}

.sync-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    font-size: 7px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 1.5px solid rgba(255,255,255,0.6);
}

.sync-dot.ok      { background: #4caf50; }
.sync-dot.pending { background: #ff9800; min-width: 14px; width: auto; border-radius: 7px; padding: 0 2px; }
.sync-dot.offline { background: #f44336; }

/* Canlı Saat toggle */
.live-clock-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.live-clock-toggle input[type="checkbox"] {
    display: none;
}
.live-clock-track {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    background: #ccc;
    border-radius: 11px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.live-clock-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.live-clock-toggle input:checked ~ .live-clock-track {
    background: var(--primary-btn);
}
.live-clock-toggle input:checked ~ .live-clock-track::after {
    transform: translateX(16px);
}
.live-clock-label {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-color);
    white-space: nowrap;
}
.live-clock-toggle input:checked ~ .live-clock-label {
    color: var(--primary-btn);
}

/* ───────── Custom Select (picker) ───────── */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-btn {
    width: 100%;
    padding: 10px 36px 10px 14px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-color);
    cursor: pointer;
    text-align: left;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}
.custom-select-btn:hover {
    border-color: var(--primary-btn);
    background: #fce4ec22;
}
.custom-select-btn.placeholder {
    color: #aaa;
    font-weight: 600;
}
.custom-select-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.csel-arrow {
    flex-shrink: 0;
    font-size: 1rem;
    color: #aaa;
    line-height: 1;
}

/* Picker modal overlay */
.picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    touch-action: auto;
}
.picker-sheet {
    background: #fff;
    border-radius: 20px;
    padding: 8px;
    width: 100%;
    max-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.22);
    touch-action: pan-y;
}
.picker-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.picker-item {
    width: 100%;
    padding: 13px 18px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-color);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.picker-item:hover {
    background: #fce4ec;
}
.picker-item.selected {
    background: var(--primary-btn);
    color: #fff;
}

/* Çevrimdışı banner — ödev listesi üstünde */
.offline-banner {
    background: #fff3e0;
    border: 1.5px solid #ff9800;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #e65100;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* ============================
   DERS KARTI (Öğren sekmesi)
   ============================ */
.lesson-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.lesson-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: white;
    border-radius: 16px;
    padding: 14px 16px;
    cursor: pointer;
    border: 2.5px solid var(--lc, #ab47bc);
    box-shadow: 0 3px 10px rgba(0,0,0,0.07);
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.lesson-card:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.lesson-card-emoji {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.lesson-card-info {
    flex: 1;
    min-width: 0;
}
.lesson-card-title {
    font-size: 1rem;
    font-weight: 900;
    color: var(--lc, #ab47bc);
    margin-bottom: 2px;
}
.lesson-card-desc {
    font-size: 0.8rem;
    color: #777;
}
.lesson-card-arrow {
    font-size: 1.8rem;
    color: var(--lc, #ab47bc);
    font-weight: 900;
    flex-shrink: 0;
}

/* ============================
   DERS OVERLAY (Tam Ekran)
   ============================ */
.lesson-overlay {
    position: fixed;
    inset: 0;
    background: #fce4ec;
    z-index: 600;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lesson-overlay.hidden { display: none; }

.lesson-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--lesson-color, #ab47bc);
    color: white;
    flex-shrink: 0;
}
.lesson-close-btn {
    background: rgba(255,255,255,0.22);
    border: none;
    color: white;
    font-size: 1.1rem;
    font-weight: 900;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.lesson-title-text {
    flex: 1;
    font-weight: 900;
    font-size: 1rem;
}
.lesson-progress-text {
    font-size: 0.82rem;
    opacity: 0.85;
    flex-shrink: 0;
}

.lesson-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 24px;
}

/* Sayaç (5 dk, 10 dk…) */
.lesson-counter {
    font-size: 2.4rem;
    font-weight: 900;
    color: #ab47bc;
    min-height: 3rem;
    line-height: 1;
    text-align: center;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.22s, transform 0.22s;
}
.lesson-counter.counter-show {
    opacity: 1;
    transform: scale(1);
}

/* Canvas wrap */
.lesson-clock-wrap {
    display: flex;
    justify-content: center;
    width: 100%;
}
.lesson-clock-wrap canvas {
    border-radius: 50%;
    max-width: 300px;
    width: 80vw;
    height: auto;
}

/* Açıklama */
.lesson-explain-box {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    text-align: center;
}
.lesson-text {
    font-size: 1.15rem;
    font-weight: 800;
    color: #37474f;
    margin: 0 0 6px;
    line-height: 1.4;
}
.lesson-sub {
    font-size: 0.9rem;
    color: #78909c;
    margin: 0;
    line-height: 1.4;
}

/* Test */
.lesson-quiz-box {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lesson-quiz-box.hidden { display: none; }

.lesson-quiz-q {
    font-size: 1.1rem;
    font-weight: 800;
    color: #37474f;
    text-align: center;
    margin: 0;
    background: white;
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.lesson-quiz-opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.lesson-opt-btn {
    background: white;
    border: 2.5px solid #e0e0e0;
    border-radius: 14px;
    padding: 14px 10px;
    font-size: 1rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    color: #37474f;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.lesson-opt-btn:active:not(:disabled) {
    background: #f3e5f5;
    border-color: #ab47bc;
}
.lesson-opt-btn.opt-correct {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #2e7d32;
}
.lesson-opt-btn.opt-wrong {
    background: #ffebee;
    border-color: #ef5350;
    color: #c62828;
}
.lesson-quiz-feedback {
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
    min-height: 24px;
}
.lesson-quiz-feedback.fb-ok {
    background: #e8f5e9;
    color: #2e7d32;
}
.lesson-quiz-feedback.fb-fail {
    background: #fff3e0;
    color: #e65100;
}

/* İleri butonu */
.lesson-next-btn {
    background: var(--lesson-color, #ab47bc);
    color: white;
    border: none;
    border-radius: 28px;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 900;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    transition: opacity 0.15s, transform 0.15s;
    margin-top: 4px;
}
.lesson-next-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.lesson-next-btn:active:not(:disabled) {
    transform: scale(0.96);
}

/* Tebrik ekranı */
.lesson-finish {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
}
.finish-emoji { font-size: 5rem; }
.lesson-finish h2 { color: var(--lesson-color, #ab47bc); margin: 0; }
.finish-text { font-size: 1.1rem; color: #37474f; }

/* ============================
   GİRİŞ HATASI
   ============================ */
.auth-error-msg {
    background: #ffebee;
    color: #c62828;
    border: 1.5px solid #ef9a9a;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
    line-height: 1.4;
}
.auth-error-msg.hidden { display: none; }

.input-error {
    border-color: #ef5350 !important;
    background: #fff8f8 !important;
}

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-5px); }
    80%      { transform: translateX(5px); }
}
.shake { animation: shake 0.35s ease; }
