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

html {
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Roboto', 'Helvetica', Arial, sans-serif;
    background-color: #f5f5f0;
    color: #484848;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    /* Add safe area padding for iOS notch and Telegram header */
    padding-top: max(env(safe-area-inset-top), 60px);
}

.container {
    max-width: 800px;
    width: 100%;
    padding: 20px;
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.debug-info {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    font-size: 12px;
    font-family: monospace;
    text-align: left;
    z-index: 9999;
    max-width: 300px;
    word-break: break-all;
}

.course-header {
    display: none;
    background: #f5f5f0;
    margin: -20px -20px 0 -20px;
    padding: 20px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

/*.course-header::before {*/
/*    content: '';*/
/*    position: absolute;*/
/*    top: 0;*/
/*    left: -50%;*/
/*    width: 200%;*/
/*    height: 100%;*/
/*    background:*/
/*        repeating-linear-gradient(*/
/*            90deg,*/
/*            transparent 0px,*/
/*            rgba(151, 49, 46, 0.01) 1px,*/
/*            transparent 2px,*/
/*            transparent 80px*/
/*        );*/
/*    transform: rotate(-2deg);*/
/*}*/


.course-title {
    font-family: 'Helvetica', Arial, sans-serif;
    font-weight: 700;
    color: #97312e;
    font-size: clamp(48px, 8vw, 80px);
    margin: 0;
    letter-spacing: 4px;
    text-transform: uppercase;
    position: relative;
    z-index: 2;
    text-shadow: 1px 1px 3px rgba(151, 49, 46, 0.1);
    transform: rotate(0deg);
    display: inline-block;
}

.header {
    position: relative;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0.5;
}

.title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 300;
    color: #97312e;
    margin-bottom: 20px;
    transform: rotate(0deg);
    display: inline-block;
    padding-top: 40px;
}

.subtitle {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 300;
    color: #484848;
    opacity: 0.8;
    transform: rotate(0.5deg);
    display: inline-block;
}

.main-content {
    position: relative;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0.5;
}

.croissant-container {
    position: relative;
    margin-bottom: 40px;
}

.croissant-button {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 20px;
    border-radius: 50%;
    transition: all 0.3s ease;
    transform-origin: center;
}

.croissant-button:hover {
    transform: scale(1.05) rotate(5deg);
}

.croissant-button:active {
    transform: scale(0.95);
}

.croissant-image {
    width: 250px;
    height: auto;
    max-width: 80vw;
    /*filter: drop-shadow(0 10px 30px rgba(151, 49, 46, 0.2));*/
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.croissant-button.clicked .croissant-image {
    animation: croissantMagic 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.magic-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.croissant-button.clicked .magic-particles {
    opacity: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #97312e;
    border-radius: 50%;
    animation: particleFloat 2s ease-out forwards;
}

.star-particle {
    position: absolute;
    width: 30px;
    height: 30px;
    background: transparent;
    animation: starExplosion 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 10;
}

.star-particle::before {
    content: '★';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    color: var(--star-color, #97312e);
    text-shadow: 0 0 10px currentColor, 0 0 20px currentColor;
}

.star-particle.large::before {
    font-size: 40px;
}

.star-particle.medium::before {
    font-size: 25px;
}

.star-particle.small::before {
    font-size: 20px;
}

@keyframes croissantMagic {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 1;
        filter: drop-shadow(0 10px 30px rgba(151, 49, 46, 0.2));
    }
    30% {
        transform: rotate(1080deg) scale(1.3);
        opacity: 1;
        filter: drop-shadow(0 15px 40px rgba(151, 49, 46, 0.4))
        drop-shadow(0 0 30px rgba(243, 241, 233, 0.9));
    }
    60% {
        transform: rotate(1440deg) scale(0.1);
        opacity: 0.8;
        filter: drop-shadow(0 5px 20px rgba(151, 49, 46, 0.6))
        drop-shadow(0 0 40px rgba(243, 241, 233, 1));
    }
    75% {
        transform: rotate(1440deg) scale(0.05);
        opacity: 0.3;
    }
    100% {
        transform: rotate(1440deg) scale(0);
        opacity: 0;
    }
}

@keyframes starExplosion {
    0% {
        transform: translate(0, 0) scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(var(--x), var(--y)) scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translate(calc(var(--x) * 1.5), calc(var(--y) * 1.5)) scale(0) rotate(360deg);
        opacity: 0;
    }
}


.team-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 40px;
}

.team-reveal.show {
    opacity: 1;
    transform: translateY(0);
}

.team-image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

#mainPageCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    background: #f5f5f0;
}


.team-name {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 400;
    color: #97312e;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(151, 49, 46, 0.1);
    transform: rotate(-0.5deg);
    display: inline-block;
}

.team-description {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 300;
    color: #484848;
    opacity: 0.9;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

.action-buttons {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease 0.5s;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.action-buttons.show {
    opacity: 1;
    transform: translateY(0);
}

.team-link,
.share-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 400;
    text-decoration: none;
    border: 2px solid #97312e;
    border-radius: 30px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: transparent;
    color: #97312e;
    font-family: inherit;
    min-width: 140px;
    transform: rotate(-0.5deg);
}

.team-link:hover,
.share-button:hover {
    background: #97312e;
    color: #f3f1e9;
    transform: rotate(-0.5deg) scale(1.05);
}

.team-link:active,
.share-button:active {
    transform: rotate(-0.5deg) scale(0.95);
}

.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.share-modal.show {
    display: flex;
}

.modal-content {
    background: #f5f5f0;
    border-radius: 15px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    overflow: auto;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #97312e;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(151, 49, 46, 0.1);
    border-radius: 50%;
}

#shareCanvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-actions {
    margin-top: 20px;
    text-align: center;
}

.download-button {
    background: #97312e;
    color: #f3f1e9;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.download-button:hover {
    background: #7a2923;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        margin-bottom: 40px;
    }

    .croissant-image {
        width: 150px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .team-link,
    .share-button {
        width: 100%;
        max-width: 250px;
    }

    .modal-content {
        padding: 20px;
        margin: 20px;
    }
}

/* Portrait orientation - lock scrolling for fullscreen experience */
@media (orientation: portrait) {
    html, body {
        overflow: hidden !important;
    }
}

@media (max-width: 768px) {
    .course-header {
        margin: -15px -15px 10px -15px;
        padding: 40px 15px;
    }


    .course-title {
        font-size: clamp(28px, 7vw, 42px);
        letter-spacing: 3px;
        transform: rotate(-0.5deg);
    }
}

@media (max-width: 480px) {
    .croissant-image {
        width: 120px;
    }

    .course-header {
        padding: 30px 15px 0;
        margin: 20px -15px 10px;
    }


    .course-title {
        font-size: clamp(2.5rem, 5vw, 4rem);
        font-weight: 300;
        color: #97312e;
        margin-bottom: 40px;
        transform: rotate(0deg);
        display: inline-block;
    }

    .title {
        transform: rotate(0deg);
    }

    .subtitle {
        transform: rotate(0deg);
    }

    .team-name {
        transform: rotate(0deg);
    }

    .team-link,
    .share-button {
        transform: rotate(0deg);
    }
}

/* Landscape orientation optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    html {
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body {
        padding-top: max(env(safe-area-inset-top), 40px);
        align-items: flex-start;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto;
        min-height: 100vh;
        max-height: none;
        position: static;
    }

    .container {
        max-width: 600px;
        padding: 5px 20px;
        justify-content: flex-start;
        height: auto;
        min-height: 100vh;
        max-height: none;
        overflow: visible;
    }

    .header {
        flex: 0.35;
        padding-top: 5px;
        min-height: auto;
    }

    .main-content {
        flex: 0.65;
        min-height: auto;
        overflow-y: visible;
        padding-bottom: 10px;
    }

    .croissant-image {
        width: 100px;
    }

    .croissant-container {
        margin-bottom: 15px;
    }

    .course-header {
        padding: 2px 20px 5px 20px;
    }

    .course-title {
        font-size: clamp(24px, 4vw, 36px);
        margin: 0;
        letter-spacing: 2px;
    }

    #mainPageCanvas {
        max-width: 60%;
        max-height: 120px;
        width: auto;
    }

    .title {
        font-size: clamp(1.5rem, 3.5vw, 2rem);
        margin-bottom: 8px;
        padding-top: 20px;
    }

    .subtitle {
        font-size: clamp(0.85rem, 1.8vw, 1rem);
        margin-bottom: 10px;
    }

    .action-buttons {
        margin-top: 8px;
    }

    .team-link {
        padding: 12px 30px;
        font-size: 16px;
    }
}

/* Medium landscape devices (tablets in landscape) */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 800px) {
    .container {
        max-width: 700px;
    }

    .croissant-image {
        width: 180px;
    }

    #mainPageCanvas {
        max-height: 450px;
    }
}