/* ==========================================================================
   GAME DESIGN SYSTEM & STYLING: TEBAK LANGKAH ROBOT
   Theme: South Sumatran Songket PALI (Maroon, Gold, & Sleek Dark Mode)
   ========================================================================== */

:root {
    /* Color Palette */
    --color-bg-dark: #000B21;
    --color-panel-bg: rgba(10, 25, 49, 0.7);
    --color-panel-border: rgba(255, 255, 255, 0.08);
    
    --color-primary-maroon: #002D8C;
    --color-primary-maroon-hover: #003ECC;
    --color-accent-gold: #00A4FF;
    --color-accent-gold-hover: #47C0FF;
    --color-accent-gold-glow: rgba(0, 164, 255, 0.3);
    
    --color-text-white: #F3F4F6;
    --color-text-gray: #9CA3AF;
    --color-text-muted: #6B7280;
    
    /* Code Command Colors */
    --color-cmd-up: #2563EB;
    --color-cmd-down: #DC2626;
    --color-cmd-left: #EA580C;
    --color-cmd-right: #7C3AED;
    --color-cmd-loop: #10B981;

    /* Grid Tile Colors (Teal Forest/Swamp vibe) */
    --color-tile-even: #081730;
    --color-tile-odd: #0C2143;
    --color-tile-border: #133366;
    
    /* UI Dimensions & Shadows */
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --shadow-gold-glow: 0 0 15px rgba(0, 164, 255, 0.4);
    
    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--color-bg-dark);
    color: var(--color-text-white);
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 45, 140, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 164, 255, 0.1) 0%, transparent 45%);
}

/* App Container Wrapper */
.app-container {
    width: 100%;
    max-width: 1200px;
    height: 100%;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.app-header {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: var(--border-radius-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-premium);
    flex-wrap: wrap;
    gap: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.header-main-row {
    display: contents;
}

.header-right-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-primary-maroon), var(--color-accent-gold));
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 45, 140, 0.4);
    animation: floatLogo 3s ease-in-out infinite alternate;
}

.logo-text h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(90deg, #FFF, var(--color-accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.logo-text p {
    font-size: 12px;
    color: var(--color-text-gray);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
}

.game-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-card {
    background: rgba(9, 13, 22, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    text-align: center;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--color-text-gray);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-accent-gold);
    font-family: 'Fredoka', sans-serif;
}

.lives-card {
    min-width: 110px;
}

.heart-container {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.heart {
    font-size: 16px;
    color: var(--color-text-muted);
    transition: var(--transition-smooth);
}

.heart.active {
    color: #EF4444;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.6));
    animation: heartPulse 1.2s infinite ease-in-out;
}

.heart.active:nth-child(2) {
    animation-delay: 0.2s;
}
.heart.active:nth-child(3) {
    animation-delay: 0.4s;
}

/* ==========================================================================
   MAIN WORKSPACE
   ========================================================================== */
.game-workspace {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

/* Grid Board (Left Panel) */
.play-area {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 100%;
    min-height: 0;
}

.difficulty-selector {
    display: flex;
    background: rgba(9, 13, 22, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: var(--border-radius-md);
    width: 100%;
    max-width: 480px;
}

.diff-btn {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--color-text-gray);
    font-family: 'Fredoka', sans-serif;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.diff-btn:hover {
    color: white;
}

.diff-btn.active {
    background: var(--color-primary-maroon);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 45, 140, 0.4);
}

.grid-container-wrapper {
    position: relative;
    width: 100%;
    max-width: min(360px, 36vh);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background: #0d1614;
    border-radius: var(--border-radius-md);
    padding: 10px;
    border: 3px solid var(--color-primary-maroon);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.grid-board {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 4px;
    position: relative;
}

.grid-board.size-easy {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
}

.grid-board.size-medium {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

.grid-board.size-hard {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
}

/* Grid Cell Styles */
.grid-cell {
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.02), 0 1px 2px rgba(0,0,0,0.4);
    transition: var(--transition-smooth);
}

.grid-cell.even {
    background-color: var(--color-tile-even);
}

.grid-cell.odd {
    background-color: var(--color-tile-odd);
}

.grid-cell.highlight-path {
    background-color: rgba(229, 169, 59, 0.15) !important;
    box-shadow: inset 0 0 8px var(--color-accent-gold);
}

/* Absolute robot explorer sizing and styling */
.robot-agent {
    position: absolute;
    z-index: 10;
    transition: left 0.5s cubic-bezier(0.25, 1, 0.5, 1), top 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* Robot agent size is calculated dynamically in JS */

/* Items Inside Cells */
.cell-item {
    width: 82%;
    height: 82%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease;
}

.cell-item svg, .robot-agent svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.cell-item:hover {
    transform: scale(1.08);
}

/* Animations for active cells / options */
.pulse-glow {
    animation: glowPulse 2s infinite ease-in-out;
}

/* Cell Tooltip (Small label under target icons) */
.cell-tooltip {
    display: none;
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 5px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 95%;
    pointer-events: none;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Control & Mascot Panel (Right Panel) */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    min-height: 0;
}

.mascot-card {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 8px 12px;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    flex-shrink: 0;
}

.mascot-svg-container {
    width: 75px;
    height: 75px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mascot-svg-container svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.speech-bubble {
    background: rgba(9, 13, 22, 0.8);
    border: 1px solid var(--color-accent-gold);
    border-radius: var(--border-radius-md);
    padding: 8px 12px;
    color: var(--color-text-white);
    font-size: 13px;
    line-height: 1.4;
    position: relative;
    text-align: center;
    box-shadow: var(--shadow-gold-glow);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-bottom-color: var(--color-accent-gold);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-bottom-color: rgba(9, 13, 22, 0.8);
}

/* Options / Choice buttons */
.options-container {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 10px 14px;
    box-shadow: var(--shadow-premium);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
    min-height: 0;
}

.panel-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 15px;
    color: var(--color-accent-gold);
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    flex: 1;
    min-height: 114px;
    overflow: hidden;
}

.choice-btn {
    background: rgba(9, 13, 22, 0.5);
    border: 2px solid var(--color-panel-border);
    border-radius: var(--border-radius-md);
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: var(--transition-smooth);
    color: white;
    width: 100%;
    height: 100%;
    min-height: 48px;
}

.choice-btn:hover:not(.disabled) {
    background: rgba(0, 45, 140, 0.15);
    border-color: var(--color-primary-maroon);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 45, 140, 0.3);
}

.choice-btn.selected {
    background: rgba(229, 169, 59, 0.12);
    border-color: var(--color-accent-gold);
    box-shadow: var(--shadow-gold-glow);
}

.choice-btn.correct {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10B981 !important;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3) !important;
}

.choice-btn.wrong {
    background: rgba(220, 38, 38, 0.15) !important;
    border-color: #DC2626 !important;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.3) !important;
}

.choice-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-icon {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.choice-label {
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    color: var(--color-text-gray);
    font-family: 'Fredoka', sans-serif;
    flex: 1;
}

.choice-btn:hover .choice-label {
    color: white;
}

/* ==========================================================================
   CODE SEQUENCE PANEL (BOTTOM)
   ========================================================================== */
.code-panel {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.code-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Fredoka', sans-serif;
    color: var(--color-accent-gold);
    font-size: 15px;
}

.mode-toggles {
    display: flex;
    align-items: center;
}

/* Switch styling */
.switch-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.switch-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    background-color: rgba(9, 13, 22, 0.8);
    border: 1px solid var(--color-panel-border);
    border-radius: 34px;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--color-text-gray);
    border-radius: 50%;
    transition: .4s;
}

.switch-container input:checked + .slider {
    background-color: var(--color-primary-maroon);
}

.switch-container input:checked + .slider:before {
    transform: translateX(22px);
    background-color: var(--color-accent-gold);
}

.switch-label {
    font-size: 13px;
    color: var(--color-text-gray);
    user-select: none;
    font-weight: 600;
}

.switch-container input:checked ~ .switch-label {
    color: white;
}

/* Command sequence flow */
.sequence-container {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: rgba(9, 13, 22, 0.6);
    border-radius: var(--border-radius-md);
    min-height: 80px;
    align-items: center;
    overflow-x: auto;
    border: 1px dashed var(--color-panel-border);
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary-maroon) rgba(9, 13, 22, 0.6);
}

.sequence-container::-webkit-scrollbar {
    height: 6px;
}

.sequence-container::-webkit-scrollbar-thumb {
    background-color: var(--color-primary-maroon);
    border-radius: 3px;
}

/* Command Blocks */
.cmd-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    height: 54px;
    border-radius: var(--border-radius-sm);
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: relative;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(255,255,255,0.15);
}

.cmd-block.active-exec {
    transform: scale(1.12);
    box-shadow: 0 0 15px currentColor;
    z-index: 5;
}

.cmd-block.completed-exec {
    opacity: 0.5;
}

.cmd-block i {
    font-size: 20px;
}

/* Command Specific Themes */
.cmd-block.cmd-up { background-color: var(--color-cmd-up); }
.cmd-block.cmd-down { background-color: var(--color-cmd-down); }
.cmd-block.cmd-left { background-color: var(--color-cmd-left); }
.cmd-block.cmd-right { background-color: var(--color-cmd-right); }

/* Loop / Repeat Modifiers */
.cmd-block .loop-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    background-color: var(--color-cmd-loop);
    border: 1px solid white;
    color: white;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 10px;
    font-family: 'Fredoka', sans-serif;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* Control Actions at Bottom */
.action-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 4px;
}

/* Copyright Bar (Centered between buttons) */
.copyright-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    flex: 1;
    text-align: center;
}

.copyright-bar span {
    font-size: 9px;
    color: var(--color-text-gray);
    opacity: 0.5;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.3px;
}

.copyright-bar .copyright-sub {
    font-size: 8px;
    opacity: 0.35;
}

.copyright-bar a {
    color: var(--color-accent-gold);
    text-decoration: none;
    opacity: 1;
    transition: var(--transition-smooth);
}

.copyright-bar a:hover {
    text-decoration: underline;
    opacity: 1;
}

.action-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.primary-btn {
    background: linear-gradient(135deg, var(--color-primary-maroon), #003ECC);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 45, 140, 0.4);
}

.primary-btn:hover:not(.disabled) {
    background: linear-gradient(135deg, var(--color-primary-maroon-hover), #004CE6);
    box-shadow: 0 6px 20px rgba(0, 45, 140, 0.5);
    transform: translateY(-2px);
}

.secondary-btn {
    background: rgba(9, 13, 22, 0.8);
    border: 1px solid var(--color-panel-border);
    color: var(--color-text-gray);
}

.secondary-btn:hover {
    color: white;
    background: rgba(9, 13, 22, 1);
    border-color: var(--color-text-muted);
}

.success-btn {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.success-btn:hover:not(.disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
    transform: translateY(-2px);
}

.action-btn.disabled, .action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

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

/* ==========================================================================
   MODALS SECTION
   ========================================================================== */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(4, 6, 10, 0.85);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.glass-card {
    background: linear-gradient(145deg, rgba(21, 30, 54, 0.9), rgba(12, 18, 33, 0.95));
    border: 1.5px solid rgba(229, 169, 59, 0.2);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(229, 169, 59, 0.1);
    color: white;
    width: 100%;
    max-width: 520px;
    position: relative;
    padding: 30px;
    outline: none;
}

.close-btn {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.close-btn:hover {
    color: white;
}

.modal-header {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-header h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 24px;
    color: var(--color-accent-gold);
}

.badge {
    align-self: flex-start;
    background: var(--color-primary-maroon);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.modal-image-container {
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(9, 13, 22, 0.6);
    border-radius: var(--border-radius-md);
    padding: 10px;
    border: 1px solid var(--color-panel-border);
}

.modal-description p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-gray);
    text-align: justify;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 16px;
}

/* Game Over Modal specifics */
.text-center {
    text-align: center;
}

.justify-center {
    justify-content: center;
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.warning-icon {
    color: #DC2626;
    animation: heartPulse 1s infinite alternate;
}

.final-score-box {
    background: rgba(9, 13, 22, 0.8);
    border: 1px solid var(--color-accent-gold);
    border-radius: var(--border-radius-md);
    padding: 16px 28px;
    margin: 15px auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-gold-glow);
}

.final-score-box .label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-text-gray);
}

.final-score-box .value {
    font-size: 32px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    color: var(--color-accent-gold);
}

.motivational-text {
    font-style: italic;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* ==========================================================================
   ANIMATIONS & TRANSITIONS
   ========================================================================== */

/* Zoom effect for modal */
.animate-zoom {
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Floating effect for logo icon */
@keyframes floatLogo {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

/* Heart pulsing */
@keyframes heartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* speech bubble bounce */
@keyframes speechBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

/* Pulse Glow */
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(229, 169, 59, 0.2); }
    50% { box-shadow: 0 0 20px rgba(229, 169, 59, 0.5); }
}

/* Win confetti particles overlay */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 99;
    pointer-events: none;
    animation: fall linear forwards;
}

@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(300px) rotate(360deg); opacity: 0; }
}

/* Obstacle shake animation */
.shake {
    animation: shakeEffect 0.5s ease-in-out;
}

@keyframes shakeEffect {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* SVG Object Animators */
.animate-pump {
    transform-origin: 20px 70px;
    animation: pumpjack 2s infinite ease-in-out;
}

@keyframes pumpjack {
    0%, 100% { transform: rotate(-8deg); }
    50% { transform: rotate(12deg); }
}

.animate-swim {
    animation: fishSwim 1.5s infinite ease-in-out alternate;
}

@keyframes fishSwim {
    0% { transform: translate(-2px, 0) rotate(-2deg); }
    100% { transform: translate(2px, 0) rotate(2deg); }
}

.animate-boat {
    animation: boatBob 2s infinite ease-in-out alternate;
}

@keyframes boatBob {
    0% { transform: translateY(-1px) rotate(-1deg); }
    100% { transform: translateY(1.5px) rotate(1.5deg); }
}

/* ==========================================================================
   RESPONSIVE STYLING (Breakpoints)
   ========================================================================== */

/* Legacy breakpoints removed to prevent layout conflicts */

/* Custom Robot Skin Modal & Gallery Modal */
.gallery-modal-content {
    max-width: 820px;
    width: 90%;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    width: 100%;
    margin-top: 10px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary-maroon) rgba(9, 13, 22, 0.6);
}

.gallery-grid::-webkit-scrollbar {
    width: 6px;
}

.gallery-grid::-webkit-scrollbar-thumb {
    background-color: var(--color-primary-maroon);
    border-radius: 3px;
}

.gallery-card {
    background: rgba(9, 13, 22, 0.5);
    border: 1.5px solid var(--color-panel-border);
    border-radius: var(--border-radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.gallery-card:hover {
    background: rgba(0, 45, 140, 0.15);
    border-color: var(--color-primary-maroon);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 45, 140, 0.3);
}

.gallery-card-icon {
    width: 64px;
    height: 64px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gallery-card-name {
    font-size: 11px;
    font-weight: 600;
    color: white;
    font-family: 'Fredoka', sans-serif;
}

.gallery-card:hover .gallery-card-name {
    color: var(--color-accent-gold);
}

/* Skins Grid */
.skins-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

.skin-card {
    background: rgba(9, 13, 22, 0.5);
    border: 2px solid var(--color-panel-border);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.skin-card:hover {
    background: rgba(229, 169, 59, 0.05);
    border-color: var(--color-accent-gold);
    transform: translateY(-3px);
}

.skin-card.active {
    background: rgba(229, 169, 59, 0.1);
    border-color: var(--color-accent-gold);
    box-shadow: var(--shadow-gold-glow);
}

.skin-card-svg {
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.skin-card-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: white;
}

.skin-card-desc {
    font-size: 11px;
    color: var(--color-text-gray);
    line-height: 1.4;
}
/* Header Actions & Hamburger (Desktop Styles) */
.hamburger-btn {
    display: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#btn-theme span {
    display: none;
}
.small-btn {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: var(--border-radius-sm);
    margin-top: 4px;
}

@media (max-width: 480px) {
    .skins-grid {
        grid-template-columns: 1fr;
    }
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Level Map Modal Winding Path Layout */
.map-modal-content {
    max-width: 800px;
    width: 95%;
}

.map-scroll-container {
    width: 100%;
    height: 480px;
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 20px 10px;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary-maroon) rgba(9, 13, 22, 0.6);
    background: radial-gradient(circle, rgba(24, 48, 46, 0.5) 0%, rgba(9, 13, 22, 0.9) 100%);
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.map-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.map-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--color-primary-maroon);
    border-radius: 3px;
}

.pali-map-path {
    position: relative;
    width: 100%;
    height: 2420px;
    padding: 0;
    margin: 0;
}

.map-node-wrapper {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    width: 60px;
    height: 60px;
}

.map-node {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #1F2937;
    border: 3px solid var(--color-text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-muted);
    cursor: not-allowed;
    transition: var(--transition-smooth);
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    user-select: none;
}

.map-node-wrapper.unlocked .map-node {
    background: #1E3A37;
    border-color: #10B981;
    color: white;
    cursor: pointer;
}

.map-node-wrapper.unlocked .map-node:hover {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
    background: #10B981;
}

.map-node-wrapper.current .map-node {
    background: var(--color-primary-maroon);
    border-color: var(--color-accent-gold);
    color: white;
    cursor: pointer;
    box-shadow: var(--shadow-gold-glow);
    animation: mapNodePulse 1.5s infinite ease-in-out;
}

.map-node-wrapper.current .map-node:hover {
    transform: scale(1.15);
    background: var(--color-primary-maroon-hover);
}

.map-node-info {
    position: absolute;
    background: rgba(9, 13, 22, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 11px;
    width: 180px;
    box-shadow: var(--shadow-premium);
    pointer-events: none;
    transition: var(--transition-smooth);
    opacity: 0.7;
}

.map-node-wrapper.unlocked .map-node-info,
.map-node-wrapper.current .map-node-info {
    opacity: 1;
    border-color: rgba(229, 169, 59, 0.3);
}

.map-node-info-name {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    color: var(--color-accent-gold);
    margin-bottom: 2px;
}

.map-node-info-region {
    color: var(--color-text-gray);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Winding Offsets - Handled dynamically in Javascript */

/* Pulse Animation for current node */
@keyframes mapNodePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px var(--color-accent-gold-glow); }
    50% { transform: scale(1.08); box-shadow: 0 0 20px var(--color-accent-gold); }
}

@media (max-width: 600px) {
    .map-node-info {
        display: none; /* Hide descriptions on small mobile paths to prevent overlapping */
    }
}

/* ==========================================================================
   LIGHT MODE OVERRIDES
   ========================================================================== */
:root.light-theme {
    --color-bg-dark: #F3F4F6;
    --color-panel-bg: rgba(255, 255, 255, 0.85);
    --color-panel-border: rgba(0, 0, 0, 0.06);
    
    --color-primary-maroon: #002D8C;
    --color-primary-maroon-hover: #003ECC;
    --color-accent-gold: #0084CC;
    --color-accent-gold-hover: #00A4FF;
    --color-accent-gold-glow: rgba(0, 164, 255, 0.15);
    
    --color-text-white: #1F2937;
    --color-text-gray: #4B5563;
    --color-text-muted: #9CA3AF;
    
    --color-tile-even: #E6F4F1;
    --color-tile-odd: #F0FAF8;
    --color-tile-border: #CBECE6;
    
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --shadow-gold-glow: 0 0 12px rgba(0, 164, 255, 0.2);
}

.light-theme body {
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 45, 140, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 164, 255, 0.04) 0%, transparent 45%);
}

.light-theme .glass-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(245, 247, 250, 0.98));
    border-color: rgba(0, 164, 255, 0.25);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1), 0 0 30px rgba(0, 164, 255, 0.05);
    color: #1F2937;
}

.light-theme .speech-bubble {
    background: rgba(255, 255, 255, 0.98);
    color: #1F2937;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04), var(--shadow-gold-glow);
}

.light-theme .speech-bubble::after {
    border-bottom-color: rgba(255, 255, 255, 0.98);
}

@media (max-width: 768px) {
    .light-theme .speech-bubble::after {
        border-bottom-color: transparent;
        border-right-color: rgba(255, 255, 255, 0.98);
    }
}

.light-theme .choice-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    color: #1F2937;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.light-theme .choice-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--color-accent-gold);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05), var(--shadow-gold-glow);
}

.light-theme .stat-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.light-theme .map-scroll-container {
    background: radial-gradient(circle, rgba(230, 244, 241, 0.7) 0%, rgba(243, 244, 246, 0.98) 100%);
    border-color: rgba(0, 0, 0, 0.06);
}

.light-theme .map-node {
    background: #E5E7EB;
    border-color: #D1D5DB;
    color: #9CA3AF;
}

.light-theme .map-node-wrapper.unlocked .map-node {
    background: #D1FAE5;
    border-color: #10B981;
    color: #065F46;
}

.light-theme .map-node-info {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.06);
    color: #4B5563;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.light-theme .map-node-wrapper.unlocked .map-node-info,
.light-theme .map-node-wrapper.current .map-node-info {
    border-color: rgba(217, 119, 6, 0.2);
}

.light-theme .skin-card {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.06);
}

.light-theme .skin-card:hover {
    background: rgba(255, 255, 255, 0.9);
}

.light-theme .skin-card-title {
    color: #1F2937;
}

.light-theme .gallery-card {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.06);
}

.light-theme .gallery-card:hover {
    background: rgba(255, 255, 255, 0.9);
}

.light-theme .gallery-card-name {
    color: #1F2937;
}

.light-theme .gallery-card:hover .gallery-card-name {
    color: var(--color-primary-maroon);
}

.light-theme .step-label {
    color: #4B5563;
}

.light-theme .cell-tooltip {
    color: rgba(0, 0, 0, 0.75);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.light-theme .copyright-bar a {
    color: var(--color-primary-maroon);
}

.light-theme .modal-header p {
    color: #4B5563;
}

/* Additional Light Mode Contrast & Visibility Fixes */
:root.light-theme .logo-text h1 {
    background: linear-gradient(90deg, var(--color-primary-maroon), var(--color-accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root.light-theme .difficulty-selector {
    background: #E5E7EB;
    border-color: rgba(0, 0, 0, 0.08);
}

:root.light-theme .diff-btn {
    color: #4B5563;
}

:root.light-theme .diff-btn:hover {
    color: #000;
}

:root.light-theme .diff-btn.active {
    background: var(--color-primary-maroon);
    color: white;
}

:root.light-theme .secondary-btn {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.15);
    color: #1F2937;
}

:root.light-theme .secondary-btn:hover:not(:disabled) {
    background: #F3F4F6;
    color: #000;
}

:root.light-theme .switch-container input:checked ~ .switch-label {
    color: #1F2937;
}

:root.light-theme .choice-btn:hover .choice-label {
    color: #002D8C;
}

:root.light-theme .sequence-container {
    background: #E5E7EB;
    border-color: rgba(0, 0, 0, 0.1);
}

:root.light-theme .code-panel-header {
    border-color: rgba(0, 0, 0, 0.08);
}

/* Viewport-fitting (no-scroll) Layout for Mobile and Tablet (max-width: 768px) */
@media (max-width: 768px) {
    body {
        padding: 6px;
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .app-container {
        height: auto;
        max-height: none;
        gap: 6px;
        padding-bottom: 24px;
    }
    
    .app-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 6px 12px;
        gap: 6px;
    }
    
    .header-main-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .header-right-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    #btn-theme span {
        display: none !important;
    }
    
    .dropdown-menu.header-actions {
        top: 48px;
        right: 12px;
    }
    
    .stat-card.highscore-card {
        display: none !important; /* Hide to save height */
    }
    
    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .logo-text h1 {
        font-size: 15px;
    }
    
    .logo-text p {
        font-size: 8px;
        letter-spacing: 0.5px;
        margin-top: 1px;
    }
    
    .game-stats {
        gap: 4px;
    }
    
    .stat-card {
        padding: 2px 6px;
    }
    
    .stat-label {
        font-size: 8px;
    }
    
    .stat-value {
        font-size: 11px;
    }
    
    .game-workspace {
        display: flex;
        flex-direction: column;
        gap: 6px;
        flex: 1;
        min-height: 0;
    }
    
    .play-area {
        flex: 1.2;
        min-height: 0;
        padding: 6px;
        gap: 4px;
    }
    
    .difficulty-selector {
        max-width: 100%;
    }
    
    .diff-btn {
        padding: 4px 6px;
        font-size: 10px;
    }
    
    .grid-container-wrapper {
        max-width: min(340px, 46vh);
    }
    
    .control-panel {
        display: none !important;
    }
    
    /* Show tooltip labels on mobile */
    .cell-tooltip {
        display: block;
    }
    
    /* Copyright bar mobile */
    .copyright-bar span {
        font-size: 7px;
    }
    
    .copyright-bar .copyright-sub {
        display: none;
    }
    
    .panel-title {
        font-size: 11px;
        padding-bottom: 2px;
        margin-bottom: 1px;
    }
    
    .choices-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
    
    .choice-btn {
        padding: 4px 8px;
        font-size: 10px;
        gap: 6px;
        min-height: 36px;
    }
    
    .choice-icon {
        width: 24px;
        height: 24px;
    }
    
    .choice-icon svg {
        width: 100%;
        height: 100%;
    }
    
    .choice-label {
        font-size: 9px;
    }
    
    .code-panel {
        padding: 6px 10px;
        gap: 6px;
    }
    
    .code-panel-header {
        padding-bottom: 2px;
    }
    
    .panel-info {
        font-size: 11px;
    }
    
    .switch-label {
        font-size: 10px;
    }
    
    .sequence-container {
        min-height: 44px;
        height: 44px;
        gap: 4px;
        padding: 2px;
    }
    
    .cmd-block {
        min-width: 36px;
        height: 36px;
        font-size: 11px;
    }
    
    .cmd-block i {
        font-size: 12px;
    }
    
    .action-buttons {
        gap: 6px;
    }
    
    .action-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    /* --- App Header Main Row & Hamburger Menu (Mobile Only) --- */
    .header-main-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .hamburger-btn {
        display: flex;
        background: rgba(9, 13, 22, 0.7);
        border: 1.5px solid var(--color-panel-border);
        color: white;
        font-size: 18px;
        width: 38px;
        height: 38px;
        border-radius: var(--border-radius-md);
        cursor: pointer;
        justify-content: center;
        align-items: center;
        transition: var(--transition-smooth);
    }
    
    .hamburger-btn:hover {
        background: rgba(229, 169, 59, 0.15);
        border-color: var(--color-accent-gold);
        color: var(--color-accent-gold);
    }
    
    .light-theme .hamburger-btn {
        background: white;
        color: var(--color-primary-navy);
        border-color: var(--color-panel-border);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }
    
    .light-theme .hamburger-btn:hover {
        background: var(--color-accent-blue-light);
        color: var(--color-primary-navy);
    }
    
    /* Dropdown Menu actions (Mobile Only) */
    .dropdown-menu.header-actions {
        position: absolute;
        top: 48px;
        right: 12px;
        background: rgba(9, 13, 22, 0.95);
        border: 2px solid var(--color-panel-border);
        border-radius: var(--border-radius-md);
        padding: 8px;
        display: flex;
        flex-direction: column;
        gap: 6px;
        z-index: 1000;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
        transform: translateY(-10px);
        opacity: 0;
        pointer-events: none;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .dropdown-menu.header-actions.show {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
    
    .light-theme .dropdown-menu.header-actions {
        background: white;
        box-shadow: 0 10px 25px rgba(0, 45, 140, 0.12);
        border-color: #CBECE6;
    }
    
    .dropdown-menu.header-actions .action-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 8px 14px;
        font-size: 12px;
        gap: 8px;
        display: flex;
        align-items: center;
        border-radius: var(--border-radius-sm);
        margin: 0;
    }
    
    .dropdown-menu.header-actions .action-btn span {
        display: inline !important;
    }
}

/* --- Target Cell Selections on Grid (Global) --- */
.grid-cell.selected-target-cell {
    border: 3.5px solid var(--color-accent-gold) !important;
    box-sizing: border-box;
    box-shadow: 0 0 14px var(--color-accent-gold) !important;
}

.grid-cell.correct-target-cell {
    border: 3.5px solid #10B981 !important;
    box-sizing: border-box;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.6) !important;
    background-color: rgba(16, 185, 129, 0.15) !important;
}

.grid-cell.wrong-target-cell {
    border: 3.5px solid #DC2626 !important;
    box-sizing: border-box;
    box-shadow: 0 0 16px rgba(220, 38, 38, 0.6) !important;
    background-color: rgba(220, 38, 38, 0.15) !important;
}

/* Clickable Target hover effect (Global) --- */
.grid-cell.clickable-target {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.grid-cell.clickable-target:hover {
    transform: scale(1.04);
    z-index: 5;
    border: 2.5px solid var(--color-accent-gold) !important;
    box-shadow: 0 0 10px rgba(229, 169, 59, 0.4) !important;
}

.grid-cell.clickable-target:active {
    transform: scale(0.98);
}
