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

:root {
    --bg-primary: #0d1329;
    --bg-secondary: #1a2140;
    --bg-card: #252b4a;
    --accent-purple: #7c3aed;
    --accent-purple-dark: #5b21b6;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-gray: #6b7280;
    --text-primary: #ffffff;
    --text-secondary: #8892b0;
    --text-placeholder: #5a6380;
    --success: #4ade80;
    --error: #f87171;
    --onboarding-accent: var(--accent-purple);
    --onboarding-accent-dark: var(--accent-purple-dark);
    --onboarding-shadow: rgba(124, 58, 237, 0.3);
    --onboarding-shadow-hover: rgba(124, 58, 237, 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, #0a0f1f 100%);
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: var(--app-height, 100dvh);
    padding: 40px 24px;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

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

.title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
}

.screen-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.screen-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ===================== */
/* Onboarding wolf       */
/* ===================== */
.werewords-animated-onboarding .onboarding-slides {
    align-items: stretch;
    padding-top: 0;
}

.werewords-animated-onboarding .onboarding-slide {
    width: 100%;
    max-width: 360px;
    padding: 4px 4px 0;
}

.werewords-remotion-stage {
    position: relative;
    width: min(100%, 320px);
    height: 244px;
    margin: 0 auto 18px;
    overflow: visible;
    background: transparent;
    box-shadow: none;
    isolation: isolate;
}

.werewords-remotion-stage > div,
.werewords-remotion-fill {
    width: 100%;
    height: 100%;
}

.werewords-remotion-fill {
    position: relative;
}

.werewords-wolf-rig {
    position: absolute;
    inset: 0;
    transform-origin: 170px 230px;
    will-change: transform;
}

.werewords-wolf-part {
    position: absolute;
    display: block;
    height: auto;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    transform-origin: center;
    will-change: transform, opacity;
    filter: drop-shadow(0 15px 18px rgba(0, 0, 0, 0.32));
}

.werewords-wolf-shadow {
    filter: none;
    transform-origin: center;
}

.werewords-wolf-tail {
    transform-origin: 78% 58%;
}

.werewords-animated-onboarding .slide-title {
    font-size: 22px;
    line-height: 1.16;
    max-width: 340px;
    margin-bottom: 12px;
}

.werewords-animated-onboarding .slide-text {
    max-width: 340px;
    min-height: 94px;
    line-height: 1.48;
}

/* Back Button */
.btn-back {
    position: absolute;
    top: calc(40px + env(safe-area-inset-top, 0px));
    left: 24px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
}

/* Players List */
.players-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Bottom Section */
.bottom-section {
    padding: 20px 0;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#players-screen .bottom-section {
    margin-top: 0;
}

/* Play Button */
.btn-play {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-purple-dark) 100%);
    border: none;
    color: white;
    padding: 18px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

@media (hover: hover) {
    .btn-play:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(124, 58, 237, 0.4);
    }
}

.btn-play:active {
    transform: translateY(0);
}

.btn-play:disabled {
    background: var(--bg-card);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    width: 100%;
    background: transparent;
    border: 2px solid var(--text-secondary);
    color: var(--text-primary);
    padding: 16px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .btn-secondary:hover {
        background: var(--bg-card);
        border-color: var(--text-primary);
    }
}

/* ===================== */
/* Cards Screen          */
/* ===================== */
#cards-screen {
    justify-content: center;
    align-items: center;
    padding-top: 60px;
}

.card-container {
    perspective: 1000px;
    width: 300px;
    height: 400px;
    margin: 20px 0;
}

.game-card {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.game-card.swiping {
    transition: transform 0.4s ease;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.game-card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.card-front {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border: 2px solid var(--accent-purple);
}

.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    transition: background 0s 0.3s;
}

/* Role-specific card back colors (applied on flip) */
.card-back.role-mayor {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.card-back.role-werewolf {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}
.card-back.role-seer {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}
.card-back.role-villager {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.card-title {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.card-player-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-purple);
    margin-bottom: 30px;
}

.card-hint {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.card-role-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-align: center;
    line-height: 1.4;
    margin-bottom: 16px;
}

.card-role-word {
    font-size: 20px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    line-height: 1.4;
}

.card-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    width: 300px;
}

.btn-show-role, .btn-next-player {
    flex: 1;
    padding: 14px;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-show-role {
    background: var(--accent-purple);
    color: white;
}

.btn-show-role:active {
    transform: scale(0.96);
}

.btn-next-player {
    background: var(--accent-purple);
    color: white;
    display: none;
}

.btn-next-player:active {
    transform: scale(0.96);
}

.swipe-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swipe-hint.visible {
    opacity: 1;
}

/* ===================== */
/* Game Phase Screen     */
/* ===================== */
#game-screen {
    align-items: center;
    padding-top: calc(60px + env(safe-area-inset-top, 0px));
}

.timer-display {
    font-size: 56px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    margin-bottom: 20px;
    transition: color 0.3s;
}

.timer-display.urgent {
    color: var(--accent-red);
    animation: timerPulse 1s ease infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.timer-secondary {
    font-size: 40px;
    margin-bottom: 12px;
}

.timer-label {
    text-align: center;
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 20px;
}

.btn-word-guessed {
    background: linear-gradient(135deg, var(--accent-yellow) 0%, #d97706 100%);
    border: none;
    color: white;
    padding: 16px 40px;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.3);
}

@media (hover: hover) {
    .btn-word-guessed:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(245, 158, 11, 0.4);
    }
}

.btn-word-guessed:active {
    transform: scale(0.96);
}

.game-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.5;
}

.questioner-section {
    text-align: center;
    margin-bottom: 32px;
}

.questioner-label {
    display: block;
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 8px;
}

.questioner-name {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-purple);
    animation: fadeIn 0.3s ease;
}

.mayor-marks-section {
    text-align: center;
    width: 100%;
}

.mayor-marks-label {
    display: block;
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 16px;
}

.mark-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
}

.mark-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 12px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 72px;
}

.mark-btn:active {
    transform: scale(0.93);
}

.mark-icon {
    font-size: 24px;
    color: white;
}

.mark-text {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.mark-yes {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.mark-no {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

.mark-maybe {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.mark-stop {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.mark-btn.hidden {
    display: none;
}

/* ===================== */
/* Seer Hunt Screen      */
/* ===================== */
#seer-hunt-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.seer-hunt-title {
    font-size: 36px;
    color: var(--accent-red);
    margin-bottom: 12px;
}

.bottom-hint {
    margin-top: auto;
    margin-bottom: 12px;
    color: var(--accent-purple);
    font-weight: 500;
}

/* ===================== */
/* Times Up Screen       */
/* ===================== */
#times-up-screen {
    align-items: center;
}

.times-up-title {
    color: var(--accent-red);
}

.word-reveal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px 24px;
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

.word-reveal-label {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 6px;
}

.word-reveal-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-purple);
}

.player-attempts-section {
    width: 100%;
    margin-bottom: 20px;
}

.attempts-label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
}

.player-marks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-mark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 16px;
    animation: slideIn 0.3s ease;
}

.player-mark-name {
    font-size: 16px;
    color: var(--text-primary);
}

.player-mark-symbols {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.player-mark-symbol {
    font-size: 18px;
}

.player-mark-symbol.mark-symbol-yes { color: var(--accent-green); }
.player-mark-symbol.mark-symbol-no { color: var(--accent-red); }
.player-mark-symbol.mark-symbol-maybe { color: var(--accent-yellow); }
.player-mark-symbol.mark-symbol-stop { color: var(--accent-gray); }
.player-mark-symbol.mark-symbol-none { color: var(--text-secondary); }

.find-werewolf-text {
    text-align: center;
    color: var(--accent-purple);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.4;
}

.wolf-vote-section {
    width: 100%;
    margin: 4px 0 12px;
}

.vote-list-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    text-align: center;
}

.wolf-vote-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 210px;
    overflow-y: auto;
    padding: 2px 0;
}

.vote-player-option {
    width: 100%;
    min-height: 54px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 26px;
    align-items: center;
    gap: 10px;
    background: rgba(37, 43, 74, 0.82);
    border: 2px solid transparent;
    border-radius: 14px;
    color: var(--text-primary);
    padding: 10px 14px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.vote-player-option.selected {
    background: rgba(124, 58, 237, 0.24);
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.18);
}

@media (hover: hover) {
    .vote-player-option:hover {
        transform: translateY(-1px);
        border-color: rgba(124, 58, 237, 0.55);
    }
}

.vote-player-emoji {
    font-size: 22px;
}

.vote-player-name {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 16px;
    font-weight: 600;
}

.vote-player-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-purple);
    color: white;
    font-size: 14px;
    font-weight: 800;
    opacity: 0;
    transform: scale(0.72);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.vote-player-option.selected .vote-player-check {
    opacity: 1;
    transform: scale(1);
}

/* ===================== */
/* Results Screen        */
/* ===================== */
#results-screen {
    align-items: center;
}

.roles-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    flex: 1;
    overflow-y: auto;
}

.role-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 14px 18px;
    animation: slideIn 0.3s ease;
}

.role-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-emoji {
    font-size: 24px;
}

.role-player-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.role-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.role-badge.badge-mayor { background: var(--accent-green); }
.role-badge.badge-werewolf { background: var(--accent-red); }
.role-badge.badge-seer { background: var(--accent-blue); }
.role-badge.badge-villager { background: var(--accent-gray); }

/* ===================== */
/* Mobile Responsive     */
/* ===================== */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 20px 12px;
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .title {
        font-size: 22px;
        margin-bottom: 16px;
    }

    .btn-play {
        padding: 16px;
        font-size: 16px;
    }

    .card-container {
        width: 240px;
        height: 320px;
    }

    .card-buttons {
        width: 240px;
    }

    .card-player-name {
        font-size: 22px;
        margin-bottom: 20px;
    }

    .card-role-title {
        font-size: 20px;
    }

    .card-role-word {
        font-size: 17px;
    }

    .card-hint {
        font-size: 13px;
    }

    .swipe-hint {
        font-size: 12px;
        margin-top: 12px;
    }

    .timer-display {
        font-size: 44px;
    }

    .timer-secondary {
        font-size: 32px;
    }

    .btn-word-guessed {
        padding: 14px 32px;
        font-size: 16px;
    }

    .questioner-name {
        font-size: 24px;
    }

    .mark-btn {
        padding: 14px 10px;
        min-height: 64px;
    }

    .mark-icon {
        font-size: 20px;
    }

    .mark-text {
        font-size: 12px;
    }

    .seer-hunt-title {
        font-size: 28px;
    }

    .word-reveal-value {
        font-size: 24px;
    }

    .werewords-remotion-stage {
        width: min(100%, 294px);
        height: 224px;
        margin-bottom: 14px;
    }
}

/* Responsive Height */
@media (max-height: 700px) {
    .screen {
        padding: 20px;
    }

    .title {
        font-size: 24px;
        margin-bottom: 16px;
    }

    .card-container {
        width: 260px;
        height: 340px;
    }

    .card-player-name {
        font-size: 24px;
    }

    .card-role-title {
        font-size: 22px;
    }

    .timer-display {
        font-size: 44px;
        margin-bottom: 12px;
    }

    .werewords-remotion-stage {
        width: min(100%, 284px);
        height: 216px;
        margin-bottom: 10px;
    }

    .werewords-animated-onboarding .slide-title {
        font-size: 19px;
        margin-bottom: 8px;
    }

    .werewords-animated-onboarding .slide-text {
        min-height: 78px;
        font-size: 14px;
        line-height: 1.36;
    }

}

/* Tablet and larger */
@media (min-width: 768px) {
    .app {
        max-width: 100%;
    }

    .screen {
        padding: 50px 40px;
    }

    .title {
        font-size: 32px;
        margin-bottom: 30px;
    }

    .card-container {
        width: 320px;
        height: 420px;
    }

    .card-player-name {
        font-size: 32px;
    }

    .card-role-title {
        font-size: 28px;
    }
}
