* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #1f2937;
    background: linear-gradient(135deg, #b2f7ef 0%, #4b0082 100%);
    -webkit-text-size-adjust: 100%;
}

h1,
h2 {
    margin: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Intro (index) */
.intro {
    min-height: 100vh;
    width: 100%;
    padding: 40px 20px;
    background: #4b0082;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 18px;
}

.intro h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 6px;
}

.intro .intro-description {
    margin: 0;
    max-width: 760px;
    line-height: 1.7;
    font-size: clamp(1rem, 2.2vw, 1.1rem);
}

.intro .intro-start-btn {
    border: none;
    border-radius: 999px;
    background: #ffffff;
    color: #4b0082;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 34px;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.intro .intro-start-btn:hover,
.intro .intro-start-btn:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    outline: none;
}

.intro .intro-credit {
    margin: 2px 0 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Main app container */
.container {
    width: min(920px, 100% - 32px);
    max-width: 100%;
    overflow-wrap: anywhere;
    margin: 24px auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    padding: 24px 20px;
    box-shadow: 0 12px 40px rgba(17, 24, 39, 0.16);
    text-align: center;
}

#main-app {
    position: relative;
}

.immersion-toggle {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 1200;
    border: none;
    border-radius: 999px;
    padding: 11px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #ffffff;
    background: rgba(75, 0, 130, 0.92);
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

#main-app.ui-hidden {
    min-height: 76vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(1px);
}

#main-app.ui-hidden > :not(.breathing-circle):not(.immersion-toggle) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

#main-app.ui-hidden .breathing-circle {
    margin: 0 auto;
}

.container > h1 {
    color: #4b0082;
    margin-bottom: 10px;
}

.container > p {
    margin-top: 0;
}

.breathing-circle {
    width: min(220px, 70vw);
    height: min(220px, 70vw);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: breathe 8s infinite;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.instruction {
    font-size: clamp(1.15rem, 2.6vw, 1.45rem);
    font-weight: 700;
    color: #1f2937;
}

@keyframes breathe {
    0%,
    50% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.2);
    }
    75% {
        transform: scale(0.8);
    }
}

.controls {
    margin: 14px 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.controls label {
    font-weight: 600;
}

.controls label,
.controls select,
.controls input[type="range"] {
    min-height: 44px;
}

.controls select,
.controls input[type="range"] {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 10px;
    background: #ffffff;
    max-width: 100%;
}

.controls input[type="range"] {
    width: min(240px, 80vw);
}

.tip,
.disclaimer {
    margin: 14px auto;
    max-width: 760px;
    line-height: 1.6;
}

.disclaimer {
    font-size: 0.92rem;
    color: #4b5563;
}

.calendar-section,
.progress-section,
.badges-section {
    margin-top: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 12px;
}

.calendar-section h2,
.progress-section h2,
.badges-section h2 {
    color: #4b0082;
    margin-bottom: 10px;
}

#badges-showcase {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

#progressChart {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
}

.badge-item {
    background: #ffffff;
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 130px;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.09);
}

/* Buttons */
.voice-button,
.log-button,
.progress-button,
.exercise-button,
.back-button {
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 16px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease;
    margin: 8px 6px;
    white-space: normal;
    line-height: 1.3;
    text-align: center;
}

.voice-button {
    background: #16a34a;
}

.log-button {
    background: #2563eb;
}

.progress-button {
    background: #f59e0b;
}

.exercise-button {
    background: linear-gradient(90deg, #4b0082 0%, #00bfff 100%);
}

.back-button {
    background: #ef4444;
}

.voice-button:hover,
.log-button:hover,
.progress-button:hover,
.exercise-button:hover,
.back-button:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

/* Theme classes toggled by JS */
.forest {
    background: url("assets/backgrounds/foret.png") center / cover fixed no-repeat;
}

.ocean {
    background: url("assets/backgrounds/ocean.pg.png") center / cover fixed no-repeat;
}

.rain {
    background: url("assets/backgrounds/pluie.png") center / cover fixed no-repeat;
}

.cheminee {
    background: url("assets/backgrounds/cheminée.png") center / cover fixed no-repeat;
}

.forest .container,
.ocean .container,
.rain .container,
.cheminee .container {
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(2px);
}

.forest .calendar-section,
.forest .progress-section,
.forest .badges-section,
.ocean .calendar-section,
.ocean .progress-section,
.ocean .badges-section,
.rain .calendar-section,
.rain .progress-section,
.rain .badges-section,
.cheminee .calendar-section,
.cheminee .progress-section,
.cheminee .badges-section {
    background: rgba(255, 255, 255, 0.52);
}

/* Exercise page */
header {
    text-align: center;
    padding: 22px 14px 12px;
    color: #ffffff;
}

header h1 {
    margin-bottom: 8px;
}

header nav a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

main {
    width: min(960px, 100% - 24px);
    max-width: 100%;
    margin: 0 auto;
}

.exercise-section {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(17, 24, 39, 0.12);
    margin: 16px auto;
    padding: 24px 20px;
    text-align: center;
}

.exercise-section h2 {
    color: #4b0082;
    margin-bottom: 14px;
}

.exercise-section strong {
    color: #0f172a;
    font-size: 1.1rem;
}

.exercise-section span {
    display: block;
    margin-top: 8px;
    line-height: 1.6;
}

footer {
    width: 100%;
    padding: 8px 0 16px;
}

/* Mobile */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .container {
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        margin: 12px auto;
        padding: 18px 14px;
        border-radius: 14px;
    }

    .immersion-toggle {
        right: 10px;
        bottom: 10px;
        font-size: 0.84rem;
        padding: 10px 13px;
    }

    .intro {
        padding: 30px 16px;
        gap: 14px;
    }

    .intro .intro-description {
        font-size: 0.98rem;
        line-height: 1.65;
        max-width: 100%;
    }

    .intro .intro-start-btn {
        width: min(320px, 92%);
        padding: 13px 20px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .controls label {
        text-align: left;
        width: 100%;
    }

    .controls select,
    .controls input[type="range"] {
        width: 100%;
    }

    .controls input[type="range"] {
        min-width: 0;
    }

    .breathing-circle {
        width: min(180px, 62vw);
        height: min(180px, 62vw);
    }

    .instruction {
        font-size: 1.05rem;
    }

    .calendar-section,
    .progress-section,
    .badges-section,
    .exercise-section {
        padding: 14px 12px;
    }

    header {
        padding: 16px 12px 10px;
    }

    header h1 {
        font-size: 1.45rem;
        line-height: 1.3;
    }

    header nav {
        display: flex;
        gap: 12px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .voice-button,
    .log-button,
    .progress-button,
    .exercise-button,
    .back-button {
        width: 100%;
        max-width: 100%;
        min-height: 46px;
        padding: 12px 12px;
        margin-left: auto;
        margin-right: auto;
        display: block;
    }

    .disclaimer {
        font-size: 0.88rem;
    }
}

@media (min-width: 769px) and (max-width: 1100px) {
    .container {
        width: min(860px, 100% - 28px);
        padding: 22px 18px;
    }

    .controls {
        gap: 8px;
    }

    .voice-button,
    .log-button,
    .progress-button,
    .exercise-button,
    .back-button {
        min-height: 44px;
    }
}

@media (min-width: 1400px) {
    .container {
        width: min(1040px, 100% - 56px);
        padding: 30px 28px;
    }

    .intro .intro-description {
        max-width: 860px;
    }
}

@media (max-width: 420px) {
    .intro {
        padding: 26px 12px;
    }

    .intro h1 {
        font-size: 1.55rem;
    }

    .container {
        width: calc(100% - 14px);
        padding: 14px 10px;
        border-radius: 10px;
    }

    .container > h1 {
        font-size: 1.55rem;
    }

    .container > p,
    .tip,
    .disclaimer,
    .controls label,
    .controls select,
    .controls input[type="range"] {
        font-size: 0.95rem;
    }

    .exercise-section h2,
    .calendar-section h2,
    .progress-section h2,
    .badges-section h2 {
        font-size: 1.2rem;
    }

    .tip,
    .disclaimer {
        text-align: left;
    }
}

@media (max-width: 320px) {
    .intro {
        padding: 20px 10px;
        gap: 10px;
    }

    .intro .intro-start-btn {
        width: 100%;
        padding: 12px 10px;
    }

    .container {
        width: calc(100% - 8px);
        padding: 12px 8px;
    }

    .breathing-circle {
        width: min(150px, 58vw);
        height: min(150px, 58vw);
    }

    .instruction {
        font-size: 0.95rem;
    }

    .immersion-toggle {
        right: 8px;
        bottom: 8px;
        max-width: calc(100% - 16px);
    }
}

@media (max-width: 900px) {
    .forest,
    .ocean,
    .rain,
    .cheminee {
        background-attachment: scroll;
    }
}
