@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700;800&family=Nunito:wght@700;800;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Fredoka', 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1e293b;
    color: #1e293b;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#canvas-container canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Base Screen Layouts */
.game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.game-screen.hidden {
    display: none !important;
}

/* Modal Overlay */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.modal-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
}

/* UI Card Styles (Nintendo Rounded Style) */
.ui-card {
    background: #ffffff;
    border-radius: 28px;
    padding: 32px 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35), 0 0 0 8px #f1f5f9;
    max-width: 900px;
    width: 90%;
    text-align: center;
    position: relative;
    border: 4px solid #e2e8f0;
}

/* Main Menu */
.menu-panel {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border: 6px solid #22c55e;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 0 0 10px #bbf7d0;
    max-width: 580px;
}

.game-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.logo-badge {
    background: #eab308;
    color: #713f12;
    padding: 6px 18px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
    box-shadow: 0 4px 10px rgba(234, 179, 8, 0.4);
}

.game-title {
    font-size: 42px;
    font-weight: 800;
    color: #166534;
    line-height: 1.1;
    text-shadow: 0 3px 0 #bbf7d0;
    margin-bottom: 6px;
}

.game-subtitle {
    font-size: 18px;
    color: #64748b;
    font-weight: 600;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(180deg, #4ade80, #22c55e);
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 16px 28px;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 0 #15803d, 0 12px 20px rgba(34, 197, 94, 0.35);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 11px 0 #15803d, 0 16px 25px rgba(34, 197, 94, 0.45);
}

.btn-primary:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #15803d;
}

.btn-secondary {
    background: linear-gradient(180deg, #60a5fa, #3b82f6);
    color: #ffffff;
    border: none;
    border-radius: 18px;
    padding: 14px 24px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 #1d4ed8, 0 10px 18px rgba(59, 130, 246, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #1d4ed8;
}

.btn-secondary:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #1d4ed8;
}

.btn-outline {
    background: #f1f5f9;
    color: #475569;
    border: 3px solid #cbd5e1;
    border-radius: 18px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-outline:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #1e293b;
}

/* Breed Selection Screen */
.breed-select-panel {
    max-width: 960px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
}

.panel-title {
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 18px;
}

.breed-selection-layout {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    text-align: left;
}

.breed-left-column {
    flex: 1.1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.breed-card-btn {
    background: #f8fafc;
    border: 3px solid #e2e8f0;
    border-radius: 18px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.breed-card-btn:hover {
    border-color: #38bdf8;
    background: #f0f9ff;
    transform: translateX(4px);
}

.breed-card-btn.active {
    border-color: #22c55e;
    background: #f0fdf4;
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.25);
}

.breed-icon {
    font-size: 28px;
    width: 46px;
    height: 46px;
    background: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.breed-btn-info h4 {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
}

.breed-btn-info p {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.breed-right-column {
    flex: 1.3;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8fafc;
    border-radius: 20px;
    padding: 18px;
    border: 2px solid #e2e8f0;
}

#breed-preview-3d {
    width: 100%;
    height: 170px;
    border-radius: 16px;
    background: linear-gradient(180deg, #dbeafe, #eff6ff);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
}

.breed-details-box h3 {
    font-size: 24px;
    font-weight: 800;
    color: #0f172a;
}

.breed-details-box .badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    margin: 4px 0 10px 0;
}

.breed-details-box .desc {
    font-size: 14px;
    color: #475569;
    line-height: 1.4;
    margin-bottom: 14px;
}

.stat-bars-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.stat-bar-bg {
    width: 60%;
    height: 12px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #22c55e);
    border-radius: 10px;
    width: 50%;
    transition: width 0.3s ease;
}

.panel-nav-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

/* Level Select Screen */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.level-card-btn {
    background: linear-gradient(145deg, #f8fafc, #ffffff);
    border: 3px solid #cbd5e1;
    border-radius: 20px;
    padding: 20px 16px;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 6px 12px rgba(0,0,0,0.06);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-card-btn:hover {
    border-color: #22c55e;
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(34, 197, 94, 0.25);
}

.lvl-number {
    font-size: 12px;
    font-weight: 800;
    background: #dcfce7;
    color: #15803d;
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
}

.lvl-title {
    font-size: 17px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 4px;
}

.lvl-sub {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 10px;
}

.lvl-sheep {
    font-size: 13px;
    color: #0369a1;
    font-weight: 700;
    margin-bottom: 8px;
}

.lvl-stars {
    font-size: 18px;
    margin-bottom: 4px;
}

.star-icon {
    filter: grayscale(100%);
    opacity: 0.35;
}

.star-icon.active {
    filter: none;
    opacity: 1;
}

.lvl-best-time {
    font-size: 12px;
    color: #10b981;
    font-weight: 700;
}

/* In-Game HUD */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

#game-hud.hidden {
    display: none !important;
}

.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.hud-sheep-badge {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 3px solid #22c55e;
    border-radius: 20px;
    padding: 10px 18px;
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
    pointer-events: auto;
}

.hud-level-label {
    font-size: 13px;
    font-weight: 800;
    color: #15803d;
    text-transform: uppercase;
}

.hud-sheep-stat {
    font-size: 24px;
    font-weight: 900;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-timer-badge {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border-radius: 18px;
    padding: 8px 20px;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.hud-top-actions {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.hud-btn-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.1s;
}

.hud-btn-circle:hover {
    transform: scale(1.08);
}

.hud-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
}

.hud-stamina-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 18px;
    padding: 12px 18px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 8px 18px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 220px;
}

.hud-stamina-label {
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

.hud-stamina-bar-bg {
    width: 100%;
    height: 14px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.hud-stamina-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    width: 100%;
    border-radius: 10px;
    transition: width 0.1s ease-out;
}

.hud-controls-hint {
    font-size: 11px;
    color: #64748b;
    font-weight: 700;
}

/* Radar Minimap */
.hud-radar-box {
    position: relative;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    border: 4px solid #ffffff;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.85);
}

#radar-canvas {
    width: 100%;
    height: 100%;
}

.compass-container {
    position: absolute;
    top: 6px;
    left: 6px;
    pointer-events: none;
    font-size: 14px;
}

#compass-arrow {
    display: inline-block;
    font-size: 18px;
    color: #facc15;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    transform-origin: center;
}

/* Mobile Virtual Touch Controls */
.mobile-touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 24px;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 60;
}

.touch-stick-zone {
    width: 120px;
    height: 120px;
    position: relative;
    pointer-events: auto;
}

.joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.joystick-knob {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    position: absolute;
}

.touch-actions-zone {
    display: flex;
    gap: 16px;
    pointer-events: auto;
}

.btn-mobile-act {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px rgba(0,0,0,0.3);
    cursor: pointer;
}

.btn-mobile-bark {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}

.btn-mobile-sprint {
    background: linear-gradient(180deg, #3b82f6, #1d4ed8);
}

/* Victory Screen Stars Animation */
.victory-stars-row {
    font-size: 48px;
    margin: 16px 0;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.victory-star {
    opacity: 0.25;
    filter: grayscale(100%);
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-star.active {
    opacity: 1;
    filter: none;
    transform: scale(1.2);
}

.victory-stats-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #334155;
}

/* Instructions Modal */
.instructions-list {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 8px;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
}

.instruction-icon {
    font-size: 26px;
}

.instruction-item h5 {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 2px;
}

.instruction-item p {
    font-size: 13px;
    color: #475569;
    line-height: 1.4;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .ui-card {
        padding: 24px 20px;
    }
    .game-title {
        font-size: 30px;
    }
    .breed-selection-layout {
        flex-direction: column;
    }
    .level-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .mobile-touch-controls {
        display: flex;
    }
    .hud-stamina-container {
        width: 150px;
    }
}
