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

body {
    font-family: Arial, sans-serif;
    background-color: var(--tg-theme-bg-color, #f0f2f5);
    color: var(--tg-theme-text-color, #222);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10px;
    height: 100vh;
    overflow: hidden;
    touch-action: none; /* Блокирует системные жесты браузера */
}


.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 10px;
}

.top-bar {
    width: min(85vw, 380px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 0 20px;
    margin-bottom: 8px;
}

#word-counter {
    font-size: 24px;
    font-weight: bold;
    color: var(--tg-theme-text-color, #222);
}

.exit-btn {
    width: 50px;
    height: 50px;
    background: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    flex-shrink: 0;
    position: relative;
}

.exit-btn::before,
.exit-btn::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 3px;
    background-color: #aaa;
    border-radius: 2px;
}

.exit-btn::before { transform: rotate(45deg); }
.exit-btn::after  { transform: rotate(-45deg); }

.card-container {
    width: min(85vw, 380px);
    height: 65vh;
    position: relative;
    margin-bottom: 10px;
}

/* Стили самой карточки */
.card {
    width: 100%;
    height: 100%;
    position: absolute;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1vh;
    background-color: var(--tg-theme-bg-color, #fff);
    padding: 10px 20px 14px;
    text-align: center;
    border: 2px solid #e0e0e0;
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform;
}

/* Класс для момента, когда мы тянем карточку пальцем */
.card.dragging {
    transition: none;
    cursor: grabbing;
}

.image-wrapper {
    flex: 1;
    min-height: 0;
    width: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#card-image {
    width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    display: block;
    pointer-events: none;
}

.audio-btn {
    background: #f0f0f0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    padding: 8px 18px;
    line-height: 1;
    flex-shrink: 0;
    align-self: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.audio-btn.playing {
    background: rgba(0, 200, 100, 0.15);
    box-shadow: 0 0 10px 3px rgba(0, 200, 100, 0.5);
}

.audio-btn.playing svg {
    fill: #00b864;
}

.transcription-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.transcription-row #word-transcription {
    margin-bottom: 0;
}

.audio-btn:active {
    transform: scale(0.9);
    transition: transform 0.1s ease;
}

#word-text {
    font-size: clamp(16px, 7vw, 26px);
    margin-bottom: 4px;
    color: var(--tg-theme-text-color, #000);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

#word-transcription {
    font-size: clamp(14px, 4.5vw, 20px);
    color: #666;
}

#word-translation {
    font-size: clamp(14px, 5vw, 20px);
    color: var(--tg-theme-text-color, #333);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.word-example {
    font-size: clamp(14px, 4.5vw, 20px);
    font-style: italic;
    color: #000;
    background-color: #ffffff;
    border-radius: 20px;
    padding: 10px 16px;
    width: min(85vw, 380px);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.4;
    word-wrap: break-word;
}

.swipe-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.1s ease;
}

.label-learn {
    background-color: rgba(0, 170, 100, 0.55);
    color: #fff;
}

.label-know {
    background-color: rgba(180, 180, 180, 0.55);
    color: #fff;
}

#start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 40px;
    padding: 20px;
}

.start-title {
    font-size: clamp(20px, 6vw, 28px);
    text-align: center;
    color: var(--tg-theme-text-color, #222);
    line-height: 1.4;
}

.limit-buttons {
    display: flex;
    gap: 16px;
}

.limit-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #222);
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    transition: background 0.15s, transform 0.1s;
}

.limit-btn:active {
    transform: scale(0.92);
    background: rgba(0, 170, 100, 0.12);
}


