@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* Palette
   hsl(30, 100%, 98%)  #FFFAF5  warm cream — background
   hsl(163, 46%, 25%)  #225D4A  dark emerald — primary
   hsl(161, 39%, 46%)  #478C72  medium emerald — buttons
   hsl(161, 50%, 55%)  #4DB88A  bright emerald — sidebar
   hsl(45,  38%, 91%)  #EDE8D5  warm cream — muted
   hsl(163, 20%, 80%)  #B5CEBC  soft border
   hsl(163, 30%, 35%)  #3E6E57  muted text
*/

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

html { scroll-behavior: smooth; height: 100%; }

body {
    font-family: 'Nunito', sans-serif;
    background-color: hsl(30, 100%, 98%);
    display: flex;
    height: 100%;
    min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────────── */
#sidebar {
    width: 400px;
    min-width: 400px;
    background: hsl(161, 50%, 55%);
    display: flex;
    flex-direction: column;
    padding: 24px 12px 24px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

#main-content {
    margin-left: 400px;
    flex: 1;
    padding: 2rem 2.5rem 4rem;
    width: 100%;
    min-width: 0;
}

.content-inner {
    max-width: 1100px;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar-title {
    color: #ffffff;
    font-family: 'Nunito', sans-serif;
    font-size: 30px;
    font-weight: 900;
    margin-bottom: 10px;
    padding: 0 6px;
}

.sidebar-icon {
    display: block;
    margin: 0 auto 16px;
    width: 56px;
    height: 56px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}

.nav-link {
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    color: #ffffff;
    font-family: 'Nunito', sans-serif;
    font-size: 20px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
}

.nav-link:hover { background: rgba(255,255,255,0.22); }
.nav-link.active { background: rgba(255,255,255,0.32); }

.lang-toggle {
    margin-top: auto;
    display: flex;
    gap: 6px;
    padding-top: 20px;
}

.lang-btn {
    flex: 1;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 8px;
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 800;
    padding: 10px 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.lang-btn:hover { background: rgba(255,255,255,0.35); }
.lang-btn.active { background: rgba(255,255,255,0.45); border-color: #fff; }

/* ─── Typography ─────────────────────────────────────────────── */
.title_header {
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    font-size: 44px;
    text-align: center;
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1.15;
    margin-bottom: 4px;
}

.title_subheader {
    font-size: 22px;
    color: hsl(163, 46%, 25%);
    text-align: center;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    margin: 24px 0 10px;
}

/* ─── Page Hero ──────────────────────────────────────────────── */
.page-hero {
    background: hsl(163, 46%, 25%);
    border-radius: 20px;
    border-bottom: 4px solid hsl(163, 46%, 18%);
    padding: 44px 36px 32px;
    text-align: center;
    margin-bottom: 32px;
}

.page-hero .title_header { color: #ffffff; }

.page-hero p {
    color: rgba(255,255,255,0.82);
    font-family: 'Nunito', sans-serif;
    font-size: 17px;
    margin-top: 6px;
    font-weight: 600;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: #ffffff;
    border-radius: 16px;
    padding: 26px 28px;
    border: 2px solid hsl(163, 20%, 80%);
    box-shadow: 0 4px 0 hsl(163, 20%, 80%);
    margin-bottom: 16px;
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.card:hover {
    border-color: hsl(161, 39%, 46%);
    box-shadow: 0 4px 0 hsl(163, 46%, 25%);
    transform: translateY(-2px);
}

.card-title {
    font-size: 18px;
    font-weight: 800;
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    margin-bottom: 8px;
}

.card-body {
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    line-height: 1.7;
    font-size: 15.5px;
    font-weight: 600;
}

.card-body a {
    color: hsl(161, 39%, 46%);
    font-weight: 700;
    text-decoration: none;
}

.card-body a:hover {
    color: hsl(163, 46%, 25%);
    text-decoration: underline;
}

/* ─── Step Cards ─────────────────────────────────────────────── */
.step-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: #ffffff;
    border-radius: 16px;
    padding: 18px 22px;
    margin-bottom: 10px;
    border: 2px solid hsl(163, 20%, 80%);
    box-shadow: 0 4px 0 hsl(163, 20%, 80%);
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.step-card:hover {
    border-color: hsl(161, 39%, 46%);
    box-shadow: 0 4px 0 hsl(163, 46%, 25%);
    transform: translateY(-2px);
}

.step-number {
    background: hsl(161, 39%, 46%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
    font-family: 'Nunito', sans-serif;
    min-width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-bottom: 3px solid hsl(163, 46%, 25%);
}

.step-text {
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    line-height: 1.7;
    font-size: 15px;
    font-weight: 600;
    padding-top: 7px;
}

/* ─── Game ───────────────────────────────────────────────────── */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.level-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 22px 14px 16px;
    text-align: center;
    border: 2px solid hsl(163, 20%, 80%);
    box-shadow: 0 4px 0 hsl(163, 20%, 80%);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.level-card:hover {
    border-color: hsl(161, 39%, 46%);
    box-shadow: 0 4px 0 hsl(163, 46%, 25%);
    transform: translateY(-2px);
}

.level-name {
    font-size: 17px;
    font-weight: 800;
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    margin-bottom: 6px;
}

.level-desc {
    font-size: 13px;
    color: hsl(163, 30%, 35%);
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 14px;
}

.word-display {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0 8px;
}

.word-letter {
    width: 52px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 26px;
    font-weight: 900;
    font-family: 'Nunito', sans-serif;
    border: 2px solid hsl(163, 20%, 80%);
    background: #ffffff;
    color: hsl(163, 46%, 25%);
    transition: background 0.2s, border-color 0.2s;
}

.word-letter.correct {
    background: hsl(142, 55%, 88%);
    border-color: hsl(142, 50%, 52%);
    color: hsl(142, 50%, 22%);
}

.word-letter.current {
    background: hsl(45, 90%, 88%);
    border-color: hsl(45, 70%, 52%);
    color: hsl(30, 80%, 28%);
    box-shadow: 0 0 0 3px hsl(45, 80%, 72%);
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 16px;
}

.camera-container {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid hsl(163, 20%, 80%);
    aspect-ratio: 4/3;
}

#game-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scaleX(-1);
}

.camera-label {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-stat {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px 20px;
    border: 2px solid hsl(163, 20%, 80%);
    box-shadow: 0 4px 0 hsl(163, 20%, 80%);
}

.game-stat-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: hsl(163, 30%, 35%);
    font-family: 'Nunito', sans-serif;
    margin-bottom: 6px;
}

.game-stat-value {
    font-size: 56px;
    font-weight: 900;
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    line-height: 1.1;
    letter-spacing: 2px;
}

.game-stat-value.wrong { color: hsl(0, 60%, 50%); }

.progress-bar-wrap {
    background: hsl(163, 20%, 80%);
    border-radius: 8px;
    height: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: hsl(161, 39%, 46%);
    border-radius: 8px;
    transition: width 0.1s linear;
    width: 0%;
}

.win-area {
    text-align: center;
    padding: 24px 0;
}

.win-area img { width: 220px; margin: 0 auto; display: block; }

.win-message {
    font-size: 22px;
    font-weight: 800;
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    margin-top: 16px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    background: hsl(161, 39%, 46%);
    border: none;
    border-bottom: 4px solid hsl(163, 46%, 25%);
    color: #ffffff;
    border-radius: 12px;
    padding: 13px 28px;
    font-size: 15px;
    text-align: center;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    transition: transform 0.1s, border-bottom 0.1s, background 0.1s;
    display: inline-block;
}

.btn:hover {
    background: hsl(161, 50%, 55%);
    transform: translateY(-1px);
}

.btn:active {
    border-bottom: 2px solid hsl(163, 46%, 25%);
    transform: translateY(2px);
}

.btn-full { width: 100%; }

/* ─── Partner Cards ──────────────────────────────────────────── */
.partner-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 22px 26px;
    margin-bottom: 16px;
    border: 2px solid hsl(163, 20%, 80%);
    box-shadow: 0 4px 0 hsl(163, 20%, 80%);
    display: flex;
    align-items: flex-start;
    gap: 24px;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.partner-card:hover {
    border-color: hsl(161, 39%, 46%);
    box-shadow: 0 4px 0 hsl(163, 46%, 25%);
    transform: translateY(-2px);
}

.partner-card img {
    width: 110px;
    border-radius: 12px;
    flex-shrink: 0;
    object-fit: contain;
}

.partner-name {
    font-size: 18px;
    font-weight: 800;
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    margin-bottom: 8px;
}

.partner-body {
    color: hsl(163, 46%, 25%);
    font-family: 'Nunito', sans-serif;
    line-height: 1.7;
    font-size: 15px;
    font-weight: 600;
}

/* ─── Section Tag ────────────────────────────────────────────── */
.section-tag {
    display: inline-block;
    background: hsl(161, 39%, 46%);
    color: #ffffff;
    border-radius: 8px;
    border-bottom: 3px solid hsl(163, 46%, 25%);
    padding: 5px 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* ─── Letter Badge ───────────────────────────────────────────── */
.letter-badge {
    display: block;
    background: hsl(161, 39%, 46%);
    color: #ffffff;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 900;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    line-height: 43px;
    text-align: center;
    margin: 8px auto 4px;
    border-bottom: 3px solid hsl(163, 46%, 25%);
}

/* ─── Divider ────────────────────────────────────────────────── */
.divider {
    height: 2px;
    background: hsl(163, 20%, 80%);
    border-radius: 2px;
    margin: 28px 0;
}

/* ─── Video grid (learning) ──────────────────────────────────── */
.video-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 12px;
}

.video-item iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    border: none;
}

/* ─── Banner image ───────────────────────────────────────────── */
.banner-img {
    display: block;
    max-width: 560px;
    width: 100%;
    margin: 0 auto 28px;
}

/* ─── Inline images (rules) ──────────────────────────────────── */
.rule-img-pair {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 12px 0 16px;
}

.rule-img-pair img { width: 200px; border-radius: 12px; }

.rule-img-center {
    display: flex;
    justify-content: center;
    margin: 12px 0 16px;
}

.rule-img-center img { width: 260px; border-radius: 12px; }

/* ─── Sign-off ───────────────────────────────────────────────── */
.sign-off {
    text-align: center;
    margin-top: 28px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: hsl(163, 30%, 35%);
}

/* ─── Loading overlay ────────────────────────────────────────── */
#model-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,250,245,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    font-family: 'Nunito', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: hsl(163, 46%, 25%);
    flex-direction: column;
    gap: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid hsl(163, 20%, 80%);
    border-top-color: hsl(161, 39%, 46%);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Camera permission note ─────────────────────────────────── */
.camera-note {
    background: hsl(45, 38%, 91%);
    border: 2px solid hsl(45, 50%, 75%);
    border-radius: 12px;
    padding: 14px 18px;
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: hsl(30, 60%, 30%);
    margin-bottom: 16px;
}

/* ─── Detected letter highlight ──────────────────────────────── */
.detected-box {
    background: hsl(45, 90%, 88%);
    border: 2px solid hsl(45, 70%, 52%);
    border-radius: 12px;
    padding: 10px 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: hsl(30, 80%, 28%);
    margin-top: 8px;
    text-align: center;
}

/* ─── Hamburger button (mobile only) ────────────────────────── */
#hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: hsl(161, 50%, 55%);
    border: none;
    border-radius: 10px;
    width: 44px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

#hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: #fff;
    border-radius: 2px;
}

/* ─── Backdrop ───────────────────────────────────────────────── */
#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 99;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 740px) {
    #hamburger { display: flex; }

    #sidebar-backdrop.open { display: block; }

    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 280px;
        min-width: 280px;
    }

    #sidebar.open { transform: translateX(0); }

    #main-content { margin-left: 0; padding: 1rem; padding-top: 70px; }
    .level-grid { grid-template-columns: 1fr; }
    .game-area { grid-template-columns: 1fr; }
    .video-grid { grid-template-columns: 1fr; }
}
