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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #2d5a7b 0%, #1a3a4f 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Forward transition - screen exits to left, new screen enters from left */
.screen.transition-exit-forward {
    opacity: 0;
    transform: translateX(-80px);
}

.screen.transition-enter-forward {
    transform: translateX(-80px);
}

/* Backward transition - screen exits to right, new screen enters from right */
.screen.transition-exit-backward {
    opacity: 0;
    transform: translateX(80px);
}

.screen.transition-enter-backward {
    transform: translateX(80px);
}

/* Logo */
.logo {
    width: 280px;
    height: auto;
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.3));
}

/* Settings button */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    transition: transform 0.2s;
}

.settings-btn img {
    width: 32px;
    height: 32px;
}

.settings-btn:hover {
    transform: scale(1.1);
}

/* Menu buttons container */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 350px;
    padding: 0 20px;
}

/* Main menu buttons - glassmorphism style */
.menu-btn {
    display: flex;
    align-items: stretch;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding: 0;
    text-align: left;
}

.menu-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.2);
}

.menu-btn:active {
    transform: scale(0.98);
}

.menu-btn-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 24px;
}

.menu-btn-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    margin-bottom: 4px;
}

.menu-btn-subtitle {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

.menu-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-btn-icon img {
    width: 11em;
    height: 11em;
}

/* Secondary buttons (difficulty, back) */
.difficulty-btn, .back-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 16px 48px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    margin: 10px;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-btn:hover, .back-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.25);
}

.difficulty-btn:active, .back-btn:active {
    transform: scale(0.98);
}

/* Action buttons (Start Game, Play Again, Back, etc.) */
.action-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    margin: 8px;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.action-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.25);
}

.action-btn:active {
    transform: scale(0.98);
}

.action-btn.primary {
    background: rgba(255, 255, 255, 0.25);
}

.action-btn.primary:hover {
    background: rgba(255, 255, 255, 0.35);
}

.setup-section {
    margin: 20px 0;
    width: 100%;
    max-width: 350px;
}

.setup-section label {
    display: block;
    color: white;
    font-size: 1.1rem;
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.option-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.option-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.option-btn.selected {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.5);
}

#players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 10px 10px 15px;
    border-radius: 12px;
}

.player-row input {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    min-height: 30px;
    box-sizing: border-box;
}

.player-row select {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    min-height: 30px;
    box-sizing: border-box;
}

.player-row .remove-player {
    background: rgba(255, 100, 100, 0.8);
    border: none;
    color: white;
    min-width: 30px;
    min-height: 30px;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.player-row .remove-player:hover {
    background: rgba(255, 50, 50, 1);
}

.small-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    font-size: 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

#game-screen {
    padding: 10px;
}

/* Tutorial layout - keeps canvas centered while other elements float around it */
#game-screen.tutorial-mode {
    position: relative;
    justify-content: center;
    gap: 0;
}

#game-screen.tutorial-mode #tutorial-text {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
}

#game-screen.tutorial-mode #end-states-container {
    position: absolute;
    bottom: calc(50% + 100px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
}

#game-screen.tutorial-mode #tutorial-next-btn {
    position: absolute;
    top: calc(50% + 110px);
    left: 50%;
    transform: translateX(-50%);
}

#game-screen.tutorial-mode #tutorial-next-btn.hidden {
    visibility: hidden;
    display: block;
}

#game-canvas {
    touch-action: none;
    border-radius: 10px;
    cursor: pointer;
}

#flying-pieces-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#end-states-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    width: 100%;
}

.end-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    transition: opacity 0.3s, transform 0.3s;
}

.end-state.current-turn {
    transform: scale(1.05);
}

.end-state.not-turn {
    opacity: 0.5;
}

.end-state-name {
    color: white;
    font-size: 1rem;
    margin-bottom: 8px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.end-state-canvas {
    border-radius: 8px;
}

.end-state-score {
    color: white;
    font-size: 1.5rem;
    margin-top: 8px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    min-height: 30px;
    transition: transform 0.1s ease-out;
}

.end-state-score.score-pop {
    animation: scorePop 0.2s ease-out;
}

@keyframes scorePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.end-state-crown {
    width: 40px;
    height: 40px;
    opacity: 0;
    transform: scale(0);
}

.end-state-crown.visible {
    animation: crownShow 0.3s ease-out forwards;
}

@keyframes crownShow {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    70% {
        opacity: 1;
        transform: scale(1.3);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

#tutorial-text {
    color: white;
    font-size: 1.3rem;
    text-align: center;
    padding: 20px;
    margin-bottom: 15px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
    line-height: 1.5;
    max-width: 400px;
}

#tutorial-next-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 40px;
    font-size: 1.1rem;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s, opacity 0.3s, background 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#tutorial-next-btn:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.3);
}

#tutorial-next-btn.hidden {
    display: none;
}

#game-over-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

#game-over-panel.hidden {
    display: none;
}

#game-result {
    font-size: 2rem;
    color: white;
    margin-bottom: 15px;
}

#score-display {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 25px;
}

.hidden {
    display: none !important;
}

h2 {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

/* Background color animation */
body {
    transition: background 0.5s ease;
}

body.color-0 { background: linear-gradient(180deg, #2d5a7b 0%, #1a3a4f 100%); }
body.color-1 { background: linear-gradient(180deg, #5a2d7b 0%, #3a1a4f 100%); }
body.color-2 { background: linear-gradient(180deg, #2d7b5a 0%, #1a4f3a 100%); }
body.color-3 { background: linear-gradient(180deg, #7b5a2d 0%, #4f3a1a 100%); }
body.color-4 { background: linear-gradient(180deg, #7b2d5a 0%, #4f1a3a 100%); }

/* Responsive adjustments */
@media (max-height: 700px) {
    .logo {
        width: 200px;
    }

    #tutorial-text {
        font-size: 1.1rem;
        padding: 15px;
    }

    .end-state-name {
        font-size: 0.9rem;
    }
}
