/* Global Styles */
:root {
    --primary-color: #ff4d4d;
    --secondary-color: #4a4a4a;
    --accent-color: #ffd700;
    --background-color: #121212;
    --text-color: #ffffff;
    --success-color: #4caf50;
    --danger-color: #f44336;
}

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

body {
    font-family: 'Russo One', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    background-image: url('ninja-bg.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    min-height: 100vh;
}

/* Button Styles */
.btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    padding: 12px 24px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-family: 'Russo One', sans-serif;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.secondary-btn {
    background-color: var(--secondary-color);
    margin-top: 10px;
}

.debug-active {
    background-color: var(--accent-color);
    color: var(--secondary-color);
}

/* Screen Styles */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80vh;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    margin: 20px auto;
}

.screen.active {
    display: flex;
}

/* Welcome Screen */
.game-title {
    font-size: 4rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
    font-family: 'Permanent Marker', cursive;
    letter-spacing: 2px;
}

.ninja-logo {
    margin: 20px 0;
}

.logo-img {
    max-width: 150px;
    height: auto;
}

.game-description {
    font-size: 1.5rem;
    margin-bottom: 30px;
    max-width: 600px;
}

.input-container {
    margin-bottom: 30px;
    width: 100%;
    max-width: 400px;
}

#username-input {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    border: 2px solid var(--secondary-color);
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    margin-bottom: 15px;
    font-family: 'Russo One', sans-serif;
}

#username-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.instructions {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    max-width: 600px;
}

.instructions h3 {
    color: var(--accent-color);
    margin-bottom: 10px;
}

.instructions ul {
    text-align: left;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
}

.level-indicator, .player-name {
    font-size: 1.5rem;
}

.timer-container {
    width: 200px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background-color: var(--primary-color);
    transition: width 0.1s linear;
}

.game-content {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 30px;
}

.target-pose, .camera-feed, .match-container {
    flex: 1;
    max-width: 30%;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    text-align: center;
}

.target-pose h3, .camera-feed h3, .match-container h3 {
    margin-bottom: 15px;
    color: var(--accent-color);
}

.match-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.match-bar-container {
    width: 50px;
    height: 200px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin: 15px 0;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--secondary-color);
    transform: rotate(180deg); /* Flip so it fills from bottom to top */
}

#match-bar {
    width: 100%;
    height: 0%;
    background-color: var(--primary-color);
    position: absolute;
    bottom: 0;
    transition: height 0.2s ease-out, background-color 0.3s ease;
}

#match-percentage {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-top: 10px;
}

.target-image-container {
    width: 100%;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#target-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#video-element {
    width: 100%;
    height: auto;
    border-radius: 10px;
    background-color: #000;
}

#canvas-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    display: none; /* Hidden by default, shown in debug mode */
}

.game-controls {
    margin-top: 20px;
}

/* Game Over Screen */
.game-over-title {
    font-size: 3.5rem;
    color: var(--danger-color);
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

.game-over-message {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.game-stats {
    margin: 10px 0;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    font-size: 1rem;
}

.game-stats p {
    margin: 3px 0;
    font-size: 0.95rem;
}

.game-stats span {
    color: var(--accent-color);
    font-weight: bold;
}

/* Victory Screen */
.victory-title {
    font-size: 3.5rem;
    color: var(--success-color);
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.victory-message {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

/* Leaderboard Screen */
.leaderboard-title {
    font-size: 36px;
    margin-bottom: 30px;
    text-align: center;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.leaderboard-container {
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-color);
}

#leaderboard-table th, #leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard-table th {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--accent-color);
    font-size: 18px;
}

#leaderboard-table tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.user-hash {
    font-size: 0.7em;
    color: #aaa;
    font-weight: normal;
    margin-left: 5px;
    opacity: 0.7;
}

/* Calibration Screen Styles */
#calibration-screen {
    background-color: #121212;
    color: #fff;
    text-align: center;
    padding: 20px;
}

#calibration-screen h1 {
    color: #ff9800;
    font-family: 'Russo One', sans-serif;
    text-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
    margin-bottom: 20px;
}

.calibration-container {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
}

.target-container, .camera-container {
    width: 48%;
    background-color: #1e1e1e;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.target-container h2, .camera-container h2 {
    color: #4caf50;
    margin-bottom: 10px;
}

#calibration-image {
    max-width: 100%;
    max-height: 300px;
    border: 2px solid #333;
    border-radius: 5px;
    margin: 10px 0;
}

#calibration-video-container {
    position: relative;
    width: 100%;
    height: 300px;
    overflow: hidden;
    border-radius: 5px;
    background-color: #000;
}

#calibration-video-container video, 
#calibration-video-container canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress-container {
    margin: 20px 0;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background-color: #333;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: #4caf50;
    text-align: center;
    line-height: 20px;
    color: white;
    font-weight: bold;
    transition: width 0.3s ease;
}

#calibration-status {
    margin: 20px 0;
    padding: 10px;
    background-color: #1e1e1e;
    border-radius: 5px;
    font-weight: bold;
}

#calibration-screen .button-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

#capture-pose-btn {
    background-color: #4caf50;
}

#next-pose-btn {
    background-color: #2196f3;
}

#finish-calibration-btn {
    background-color: #ff9800;
}

#calibration-btn {
    margin-top: 15px;
    background-color: #673ab7;
}

/* Social Links */
.social-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.social-btn {
    display: inline-block;
    background-color: var(--secondary-color);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.social-btn:hover {
    background-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 3rem;
    }
    
    .game-content {
        flex-direction: column;
        align-items: center;
    }
    
    .target-pose, .camera-feed, .match-container {
        max-width: 100%;
        margin-bottom: 20px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .timer-container {
        width: 100%;
    }
}
