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

html, body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    position: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    color: #000;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    padding-bottom: calc(2.5rem * 4 + 0.4rem + 3rem + 0.3rem * 4 + 1rem + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
}

.hamburger {
    position: fixed;
    top: 1rem;
    left: 1rem;
    cursor: pointer;
    z-index: 1000;
    width: 28px;
    height: 28px;
}

.hamburger input {
    display: none;
}

.hamburger-icon {
    width: 28px;
    height: 28px;
    stroke: #000;
}

.hamburger-icon .line {
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-icon .line1 {
    transform: translateY(-6px);
}

.hamburger-icon .line3 {
    transform: translateY(6px);
}

.hamburger input:checked ~ .hamburger-icon .line1 {
    transform: translateY(0) rotate(45deg);
}

.hamburger input:checked ~ .hamburger-icon .line2 {
    opacity: 0;
}

.hamburger input:checked ~ .hamburger-icon .line3 {
    transform: translateY(0) rotate(-45deg);
}

/* Menu hamburger */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    padding-top: 4rem;
}

.menu.active {
    left: 0;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    border-bottom: 1px solid #e0e0e0;
}

.menu-item-highlight {
    background: #fff9c4;
}

.menu-link-highlight {
    background: #fff9c4;
    font-weight: 600;
}

.menu-link-highlight:hover {
    background: #fff176;
}

.menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    color: #000;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    cursor: pointer;
}

.menu-link:hover {
    background: #f5f5f5;
}

.menu-icon {
    flex-shrink: 0;
    color: #000;
}

.menu-link span {
    flex: 1;
}

.menu-link svg {
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Modale pour les images */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
    padding: 1rem;
}

.image-modal.active {
    opacity: 1;
    visibility: visible;
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.image-modal-content img {
    width: 100%;
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
}

.image-modal-close {
    position: absolute;
    top: -2.5rem;
    right: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
    padding-top: 1.5rem;
    padding-bottom: 0;
    overflow: visible;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    justify-content: flex-start;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.logo {
    max-width: 100%;
    width: clamp(130px, 45vw, 180px);
    height: auto;
    display: block;
    margin: 0 auto;
}

.ratios {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    width: 100%;
    border: none;
}

.ratio {
    flex: 1;
    min-width: 0;
    padding: clamp(0.5rem, 1.5vh, 0.75rem);
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 600;
    border: 2px solid #ccc;
    border-bottom: 2px solid #000;
    background: #f5f5f5;
    color: #999;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.ratio:not(:last-child) {
    border-right: none;
}

.ratio.active {
    background: #000;
    color: #fff;
    border: 2px solid #000;
    z-index: 1;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.inputs {
    display: flex;
    flex-direction: column;
    gap: clamp(0.4rem, 1vh, 0.6rem);
    width: 100%;
    flex: 0 0 auto;
}

.input-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: clamp(0.4rem, 1vh, 0.6rem) clamp(0.6rem, 1.5vw, 0.9rem);
    background: #fff;
    transition: all 0.2s;
}

.input-row:focus-within {
    border: 3px solid #000;
    border-color: #000;
    box-shadow: 0 0 0 1px #000;
    padding: calc(clamp(0.4rem, 1vh, 0.6rem) - 1px) calc(clamp(0.6rem, 1.5vw, 0.9rem) - 1px);
}

.field {
    flex: 1;
    min-width: 0;
    padding: 0;
}

.field.total {
    font-weight: 600;
}

.field label {
    display: block;
    font-weight: 600;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    color: #666;
}

.field-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.75rem;
    font-weight: 400;
    text-align: right;
    background: transparent;
    min-width: 0;
    color: #999;
    transition: color 0.2s, font-weight 0.2s;
}

.input-row.active-row .field input {
    color: #000;
    font-weight: 700;
}

.field input:focus::placeholder {
    color: transparent;
}

.field input:focus[value="0"] {
    color: transparent;
    text-shadow: 0 0 0 #000;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.field .unit {
    font-size: 1.75rem;
    font-weight: 400;
    color: #999;
    flex-shrink: 0;
    transition: color 0.2s, font-weight 0.2s;
}

.input-row.active-row .field .unit {
    color: #000;
    font-weight: 700;
}

.clear-btn {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.clear-btn svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
}

.clear-btn:hover {
    background-color: #f5f5f5;
}

.clear-btn:active {
    transform: scale(0.9);
}

/* Clavier personnalisé */
.custom-keyboard {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-top: 2px solid #000;
    padding: 0.4rem;
    padding-top: 0.5rem;
    padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
    display: grid;
    gap: 0.3rem;
    z-index: 999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    flex-shrink: 0;
}

.custom-keyboard.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.keyboard-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
}

.key {
    background: #f5f5f5;
    border: 2px solid #000;
    border-radius: 6px;
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.5rem;
    cursor: pointer;
    transition: all 0.1s;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.key:active {
    transform: scale(0.95);
    background: #e0e0e0;
}

.key-delete {
    background: #000;
    color: #fff;
    border-color: #000;
}

.key-delete:active {
    background: #333;
}

.key-delete svg {
    width: 1.3rem;
    height: 1.3rem;
}

.field input {
    cursor: pointer;
    user-select: none;
}

.field input.active {
    color: #000;
    font-weight: 900;
}

/* Conteneur de la promo */
.promo-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0;
}

.promo-box {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px dotted #cc0000;
    border-radius: 5px;
    background: #fff5f5;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.promo-box:hover {
    border-color: #990000;
}

.promo-box:active {
    transform: scale(0.98);
}

.promo-text {
    color: #cc0000;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
}

/* Media queries desktop - réduction du clavier */
@media (min-width: 768px) {
    .container,
    .custom-keyboard {
        max-width: 320px;
    }
    
    .custom-keyboard {
        padding: 0.3rem;
        padding-bottom: calc(0.3rem + env(safe-area-inset-bottom, 0px));
        gap: 0.25rem;
    }
    
    .keyboard-row {
        gap: 0.25rem;
    }
    
    .key {
        font-size: 1rem;
        padding: 0.35rem;
        min-height: 1.8rem;
        border-width: 1.5px;
    }
    
    .key-delete svg {
        width: 1rem;
        height: 1rem;
    }
}

/* Media query pour petits écrans */
@media (max-height: 700px) {
    header {
        margin-bottom: 0.3rem;
    }
    
    .logo {
        width: clamp(90px, 30vw, 130px);
    }
    
    .ratios {
        margin-bottom: 0.3rem;
    }
    
    .ratio {
        padding: 0.35rem;
        font-size: 0.8rem;
    }
    
    .inputs {
        gap: 0.3rem;
    }
    
    .input-row {
        padding: 0.35rem 0.6rem;
    }
    
    .field input {
        font-size: 1.5rem;
    }
    
    .field .unit {
        font-size: 1.5rem;
    }
    
    .promo-wrapper {
        padding-top: 0.3rem;
    }
    
    .promo-box {
        padding: 0.5rem 0.75rem;
    }
    
    .promo-text {
        font-size: 0.75rem;
    }
    
    .key {
        min-height: 2.2rem;
        font-size: 1.1rem;
    }
}

/* Media query pour très petits écrans */
@media (max-height: 600px) {
    header {
        margin-bottom: 0.2rem;
    }
    
    .logo {
        width: clamp(80px, 28vw, 110px);
    }
    
    .ratios {
        margin-bottom: 0.2rem;
    }
    
    .ratio {
        padding: 0.3rem;
        font-size: 0.75rem;
    }
    
    .inputs {
        gap: 0.25rem;
    }
    
    .input-row {
        padding: 0.3rem 0.5rem;
    }
    
    .field label {
        font-size: 0.65rem;
        margin-bottom: 0.1rem;
    }
    
    .field input {
        font-size: 1.3rem;
    }
    
    .field .unit {
        font-size: 1.3rem;
    }
    
    .clear-btn {
        width: 2rem;
        height: 2rem;
        min-width: 2rem;
    }
    
    .clear-btn svg {
        width: 1.2rem;
        height: 1.2rem;
    }
    
    .promo-wrapper {
        padding-top: 0.2rem;
    }
    
    .promo-box {
        padding: 0.4rem 0.6rem;
    }
    
    .promo-text {
        font-size: 0.7rem;
    }
    
    .key {
        min-height: 2rem;
        font-size: 1rem;
        padding: 0.3rem;
    }
    
    .custom-keyboard {
        padding: 0.25rem;
        gap: 0.2rem;
    }
    
    .keyboard-row {
        gap: 0.2rem;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    body {
        align-items: flex-start;
    }
    
    .container {
        padding: 1rem;
    }
    
    header {
        margin-bottom: 1rem;
    }
    
    .inputs {
        margin-bottom: 1rem;
    }
}
/* Install Prompt Styles */
.install-prompt {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.install-prompt.active {
    opacity: 1;
    visibility: visible;
}

.install-prompt-content {
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    max-width: 90%;
    width: 350px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-prompt-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 0;
    line-height: 1;
}

.install-prompt-close:hover {
    color: #000;
}

.install-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.install-prompt-content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #000;
}

.install-prompt-content p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.install-button {
    background: #000;
    color: #fff;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    max-width: 250px;
}

.install-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.install-free-badge {
    display: inline-block;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    margin-bottom: 1.5rem;
}

/* Badge bulle en haut à droite */
.install-badge {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    background: #000;
    color: #fff;
    padding: 0.4rem 0.7rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    z-index: 1500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.install-badge.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.install-badge:active {
    transform: scale(0.95);
}

.install-badge-icon {
    font-size: 0.9rem;
}

.install-badge-text {
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Browser Choice Modal Styles */
.browser-choice-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.browser-choice-modal.active {
    opacity: 1;
    visibility: visible;
}

.browser-choice-content {
    background: #fff;
    border-radius: 20px;
    padding: 2rem;
    max-width: 90%;
    width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.4s ease;
}

.browser-choice-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 0;
    line-height: 1;
}

.browser-choice-close:hover {
    color: #000;
}

.browser-choice-content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #000;
}

.browser-choice-content p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.5;
}

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

.browser-btn {
    flex: 1;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.browser-btn:hover {
    background: #fff;
    border-color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.browser-btn:active {
    transform: scale(0.95);
}

.browser-btn svg {
    width: 48px;
    height: 48px;
}

.browser-btn span {
    font-size: 1rem;
    font-weight: 600;
    color: #000;
}

/* Video View inside Browser Choice Modal */
.video-view {
    width: 100%;
    margin-top: 1rem;
}

#tutorial-video {
    width: 100%;
    max-height: 60vh;
    border-radius: 10px;
    background: #000;
}

.video-close-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 600;
    color: #000;
}

.video-close-btn:hover {
    background: #e0e0e0;
}

.video-close-btn svg {
    width: 20px;
    height: 20px;
}