:root {
    --primary-color: #fdb927; /* Corn Yellow */
    --secondary-color: #558b2f; /* Corn Green */
    --text-color: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.6);
}

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

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #000;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    color: var(--text-color);
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none; /* Allow click through by default */
    z-index: 1;
}

.layer.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Background Layer */
#background-layer {
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Default background */
    background-image: url('https://image.pollinations.ai/prompt/corn%20field%20farm%20background%20nature%20sunny?width=1920&height=1080&nologo=true');
    opacity: 1; /* Background is always visible behind other layers */
    transition: background-image 1s ease-in-out;
}

/* Video Layer */
#video-layer {
    background: rgba(0, 0, 0, 0.8);
    z-index: 20;
}

.video-placeholder {
    text-align: center;
    padding: 40px;
    border: 2px solid var(--primary-color);
    border-radius: 20px;
    background: rgba(0,0,0,0.5);
}

.video-placeholder h1 {
    font-size: 4rem;
    color: #d32f2f;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(211, 47, 47, 0.5);
}

.martial-intro {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 20px 0;
    font-weight: bold;
    line-height: 1.8;
}

.sub-text {
    font-size: 1.2rem;
    margin-bottom: 30px;
}

/* Game UI Layer - Split Layout */
#game-ui-layer.split-layout {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    padding: 0;
    z-index: 15;
    height: 100vh; /* Ensure full height */
    overflow: hidden; /* Prevent scrolling */
}

/* Left Info Panel */
.info-panel {
    width: 40%;
    background: linear-gradient(135deg, rgba(255, 248, 220, 0.95) 0%, rgba(253, 245, 230, 0.95) 100%);
    padding: 20px 40px; /* Reduced padding */
    overflow-y: auto; /* Allow scroll only inside panel if needed */
    display: flex;
    flex-direction: column;
    gap: 15px; /* Reduced gap */
}

.panel-title {
    font-size: 2rem; /* Slightly smaller */
    color: #d32f2f;
    margin-bottom: 5px;
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.panel-subtitle {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
    flex-shrink: 0;
}

/* Step Cards */
.step-card {
    background: white;
    border-radius: 20px;
    padding: 15px 25px; /* Compact padding */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border: 3px solid #e0e0e0;
    flex: 1; /* Distribute space evenly */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.step-card.active {
    border-color: var(--primary-color);
    box-shadow: 0 6px 20px rgba(253, 185, 39, 0.4);
    transform: scale(1.02);
    z-index: 5;
}

.step-card.completed {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #4CAF50;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.step-number {
    min-width: 70px;
    height: 40px;
    border-radius: 20px;
    background: linear-gradient(135deg, #d32f2f, #f44336);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    padding: 0 15px;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.4);
}

.step-card.completed .step-number {
    background: #4CAF50;
    color: white;
    box-shadow: none;
}

.step-header h3 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

.step-content {
    text-align: center;
}

/* Warrior Demo Container */
.warrior-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.side-icon {
    font-size: 3rem;
    animation: iconFloat 2s ease-in-out infinite;
}

.side-icon.left {
    animation-delay: 0s;
}

.side-icon.right {
    animation-delay: 1s;
    transform: scaleX(-1);
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Stickman Warrior Demo */
.warrior-demo {
    width: 100px; /* Smaller */
    height: 120px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stickman {
    position: relative;
    width: 80px;
    height: 100px;
    transition: all 0.3s ease;
}

/* Stickman parts */
.stickman .head {
    width: 24px;
    height: 24px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.stickman .body {
    width: 4px;
    height: 40px;
    background: #333;
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
}

.stickman .arm {
    width: 4px;
    height: 30px;
    background: #333;
    position: absolute;
    top: 28px;
    transform-origin: top center;
}

.stickman .left-arm {
    left: calc(50% - 15px);
}

.stickman .right-arm {
    right: calc(50% - 15px);
}

.stickman .leg {
    width: 4px;
    height: 35px;
    background: #333;
    position: absolute;
    top: 60px;
    transform-origin: top center;
}

.stickman .left-leg {
    left: calc(50% - 10px);
}

.stickman .right-leg {
    right: calc(50% - 10px);
}

/* Stance Pose - Hands together */
.stance-pose .left-arm.high {
    transform: rotate(-60deg);
}

.stance-pose .right-arm.high {
    transform: rotate(60deg);
}

/* Punch Pose - One arm extended */
.punch-pose .left-arm.extended {
    transform: rotate(-45deg) scaleY(1.3);
}

.punch-pose .right-arm.normal {
    transform: rotate(70deg);
}

/* Kick Pose - One leg raised */
.kick-pose .left-leg.kicked {
    transform: rotate(-60deg) scaleY(1.2);
}

.kick-pose .right-leg.standing {
    transform: rotate(10deg);
}

/* Animation when active */
.step-card.active .stickman {
    animation: stickmanBreathe 2s ease-in-out infinite;
}

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

/* Green glow when action detected */
.warrior-demo.detecting {
    animation: greenGlow 0.5s ease-in-out;
}

@keyframes greenGlow {
    0%, 100% { 
        filter: drop-shadow(0 0 0px #4CAF50);
    }
    50% { 
        filter: drop-shadow(0 0 20px #4CAF50);
    }
}

.warrior-demo.detecting .stickman .head,
.warrior-demo.detecting .stickman .body,
.warrior-demo.detecting .stickman .arm,
.warrior-demo.detecting .stickman .leg {
    background: #4CAF50;
    box-shadow: 0 0 10px #4CAF50;
}

.step-instruction {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 10px;
    font-weight: bold;
}

.step-poem {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    line-height: 1.6;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 235, 59, 0.1);
    border-left: 3px solid var(--primary-color);
    border-radius: 5px;
}

.counter-display {
    display: flex;
    justify-content: space-around;
    margin-top: 10px;
    font-size: 1.1rem;
    color: #333;
}

.counter-display b {
    color: #d32f2f;
    font-size: 1.3rem;
}

.step-progress {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 15px;
}

.step-progress .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.3s ease-out;
}

/* Right Camera Container */
.camera-container {
    width: 60%;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-container canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Changed from cover to contain to show full person */
}

#camera-feed-canvas {
    z-index: 1;
}

#ar-overlay-canvas {
    z-index: 2;
    pointer-events: none;
}

.status-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1rem;
    z-index: 3;
}

.distance-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(253, 185, 39, 0.9);
    color: #000;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 3;
    box-shadow: 0 4px 15px rgba(253, 185, 39, 0.5);
    animation: hintPulse 2s ease-in-out infinite;
}

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

/* Debug Layer - Overlaid on video area */
#camera-layer {
    position: absolute;
    top: 70px; /* Below status indicator */
    right: 20px;
    width: 240px;
    height: 180px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: #000;
    z-index: 4; /* Above AR overlay */
    box-shadow: 0 4px 15px rgba(0,0,0,0.7);
    opacity: 0.85;
    transition: opacity 0.3s;
}

#camera-layer:hover {
    opacity: 1;
    transform: scale(1.05);
}

#debug-canvas {
    width: 100%;
    height: calc(100% - 25px); /* Leave space for debug text */
}

#camera-layer .debug-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #0f0;
    padding: 5px;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Congrats Layer */
#congrats-layer {
    background: rgba(0,0,0,0.9);
    z-index: 30;
}

.congrats-content {
    text-align: center;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.congrats-content h1 {
    font-size: 5rem;
    margin-bottom: 20px;
    color: #d32f2f;
    text-shadow: 0 0 20px rgba(211, 47, 47, 0.5);
}

.congrats-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    font-weight: bold;
}

.congrats-poem {
    font-size: 1.5rem;
    line-height: 2;
    margin: 30px 0;
    color: #fff;
    font-style: italic;
}

.badge {
    display: inline-block;
    font-size: 2rem;
    padding: 15px 40px;
    background: linear-gradient(135deg, var(--primary-color), #FFD700);
    color: #000;
    border-radius: 50px;
    margin: 20px 0;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
    animation: badgeShine 2s ease-in-out infinite;
}

@keyframes badgeShine {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6); }
    50% { transform: scale(1.05); box-shadow: 0 6px 30px rgba(255, 215, 0, 0.9); }
}

/* Buttons */
button {
    padding: 15px 40px;
    font-size: 1.5rem;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 20px;
}

.primary-btn {
    background: var(--primary-color);
    color: #000;
    font-weight: bold;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(253, 185, 39, 0.6);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.secondary-btn:hover {
    background: rgba(253, 185, 39, 0.1);
}

@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
