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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c1810 0%, #4a2c1a 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    background: linear-gradient(135deg, #8b5a3c 0%, #6d4c3a 100%);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 
                inset 0 2px 4px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    border: 4px solid #5c3d2e;
}

/* Header Styles */
.game-header {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: white;
    padding: 15px 20px;
    text-align: center;
}

.game-header h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-header p {
    font-size: 1em;
    margin-bottom: 10px;
    opacity: 0.9;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.attempts {
    font-size: 1.1em;
    font-weight: bold;
}

/* Button Styles */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#new-game-btn {
    background: white;
    color: #ff6b6b;
}

.submit-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    margin-right: 10px;
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.undo-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    margin-right: 10px;
}

.undo-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.clear-btn {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

/* Main Game Layout */
.game-main {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 20px;
    padding: 20px;
    min-height: 700px;
}

/* Game Board - Left Panel */
.game-board {
    background: linear-gradient(135deg, #6d4c3a 0%, #5c3d2e 100%);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3),
                0 2px 4px rgba(255, 255, 255, 0.1);
    border: 3px solid #4a2c1a;
}

/* Game Area with Feedback and Attempts */
.game-area {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

/* Feedback Panels - Left side of game rows */
.feedback-panels {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    padding-top: 0; /* Ensure no extra top padding */
}

/* Individual Feedback Square */
.feedback-square {
    width: 75px;
    height: 65px;
    background: linear-gradient(135deg, #3d2817, #2c1810);
    border: 3px solid #1a0f08;
    border-radius: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 3px;
    padding: 6px;
    box-sizing: border-box;
    margin: 0;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.feedback-square.active {
    border-color: #5c3d2e;
    background: linear-gradient(135deg, #4a2c1a, #3d2817);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5),
                0 0 8px rgba(139, 90, 60, 0.5);
}

.feedback-square.filled {
    border-color: #5c3d2e;
    background: linear-gradient(135deg, #4a2c1a, #3d2817);
}

/* Feedback Holes */
.feedback-hole {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #4a2c1a;
    background: radial-gradient(circle, #d4a574 0%, #a0724d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.3);
}

.feedback-hole .feedback-peg {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #333;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Game Rows Container */
.game-rows {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 0; /* Ensure no extra top padding */
}

/* Control Panel - Right Panel */
.control-panel {
    background: linear-gradient(135deg, #6d4c3a 0%, #5c3d2e 100%);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    justify-content: flex-start;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3),
                0 2px 4px rgba(255, 255, 255, 0.1);
    border: 3px solid #4a2c1a;
}

.secret-code {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: linear-gradient(135deg, #4a2c1a 0%, #3d2817 100%);
    border-radius: 10px;
    border: 2px solid #2c1810;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.secret-code h3 {
    margin-bottom: 15px;
    color: #d4a574;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Peg Styles - Larger for better visibility */
.peg {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 3px solid #333;
    display: inline-block;
    margin: 4px;
    position: relative;
    transition: all 0.3s ease;
    cursor: grab;
}

.peg:active {
    cursor: grabbing;
}

.peg:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.peg.empty {
    background: #f0f0f0;
    border-style: dashed;
    border-color: #ccc;
}

.peg.secret {
    background: #333;
    animation: pulse 2s infinite;
}

/* Color Classes */
.peg.red, .color-peg.red {
    background-color: #ff4444;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(255, 68, 68, 0.4);
}

.peg.blue, .color-peg.blue {
    background-color: #4444ff;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(68, 68, 255, 0.4);
}

.peg.yellow, .color-peg.yellow {
    background-color: #ffdd44;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(255, 221, 68, 0.4);
}

.peg.green, .color-peg.green {
    background-color: #44ff44;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(68, 255, 68, 0.4);
}

.peg.cyan, .color-peg.cyan {
    background-color: #00dddd;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 221, 221, 0.4);
}

.peg.purple, .color-peg.purple {
    background-color: #aa44ff;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(170, 68, 255, 0.4);
}

/* Code Rows */
.code-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    position: relative;
}

.game-row {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 10px 10px;
    background: linear-gradient(135deg, #8b5a3c 0%, #6d4c3a 100%);
    border-radius: 12px;
    border: 3px solid #4a2c1a;
    height: 65px; /* Match feedback square height exactly */
    justify-content: space-between;
    box-sizing: border-box;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    gap: 8px;
}

.game-row.empty {
    background: linear-gradient(135deg, #6d4c3a, #5c3d2e);
    border-color: #3d2817;
    opacity: 0.7;
}

.game-row.filled {
    background: linear-gradient(135deg, #8b5a3c, #6d4c3a);
    border-color: #5c3d2e;
    opacity: 1;
}

.game-row.active {
    background: linear-gradient(135deg, #a0724d, #8b5a3c);
    border-color: #d4a574;
    border-width: 3px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3),
                0 0 12px rgba(212, 165, 116, 0.5);
    transform: scale(1.02);
}

/* Row buttons */
.row-undo-btn,
.row-submit-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #333;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    display: none; /* Hidden by default, shown by JS */
}

.row-undo-btn {
    background: linear-gradient(135deg, #ff9a56, #ff6b6b);
    color: white;
}

.row-undo-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffaa66, #ff7b7b);
    transform: scale(1.1);
}

.row-undo-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.row-submit-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.row-submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #38b755, #30d9a7);
    transform: scale(1.1);
}

.row-submit-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.guess-pegs {
    display: flex;
    gap: 5px;
    justify-content: center;
    flex: 1;
}

.feedback-peg {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid #333;
}

.feedback-peg.black {
    background-color: #333;
}

.feedback-peg.white {
    background-color: #fff;
}

/* Remove current-guess styles - no longer needed */

/* Color Palette - Right Panel */
.color-palette {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #4a2c1a 0%, #3d2817 100%);
    border-radius: 10px;
    width: 100%;
    border: 2px solid #2c1810;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.color-palette h3 {
    margin-bottom: 15px;
    color: #d4a574;
    font-size: 1.1em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.colors {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    justify-items: center;
}

.color-peg {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 4px solid #333;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
}

.color-peg:active {
    cursor: grabbing;
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.game-controls .btn {
    width: 100%;
    justify-self: stretch;
}

/* Feedback Legend */
.feedback-legend {
    background: linear-gradient(135deg, #4a2c1a 0%, #3d2817 100%);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #2c1810;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.feedback-legend h3 {
    color: #d4a574;
    margin-bottom: 15px;
    font-size: 1.1em;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(92, 61, 46, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-pegs {
    display: flex;
    margin-right: 12px;
    min-width: 25px;
}

.legend-text {
    flex: 1;
    font-size: 0.9em;
    line-height: 1.3;
    color: #d4a574;
}

.legend-text strong {
    color: #f5e6d3;
    font-size: 0.95em;
}

/* Example Section */
.legend-example {
    margin-top: 15px;
    padding: 12px;
    background: rgba(92, 61, 46, 0.6);
    border-radius: 8px;
    border: 1px solid #ddd;
}

.legend-example h4 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1em;
    text-align: center;
}

.example-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.example-guess {
    display: flex;
    gap: 3px;
}

.example-guess .peg {
    width: 20px;
    height: 20px;
    margin: 1px;
}

.example-feedback {
    display: flex;
    gap: 2px;
}

.example-text {
    font-size: 0.8em;
    text-align: center;
    color: #666;
    font-style: italic;
}

.color-peg:hover {
    transform: scale(1.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.color-peg:active {
    transform: scale(1.1);
}

/* Game Status */
.game-status {
    padding: 20px 30px;
    text-align: center;
}

#status-message {
    font-size: 1.2em;
    font-weight: bold;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    animation: fadeIn 0.5s ease;
}

.status-win {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.status-lose {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

.status-info {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

/* Instructions - Now in right panel */
.instructions {
    padding: 15px;
    background: linear-gradient(135deg, #fff8dc, #f0f8ff);
    border-radius: 10px;
    border: 1px solid #ddd;
    margin-top: 10px;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1em;
    text-align: center;
}

.instructions ul {
    list-style: none;
    padding-left: 0;
}

.instructions li {
    margin: 6px 0;
    padding: 4px 0;
    font-size: 0.85em;
    line-height: 1.3;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translate3d(0, 0, 0); }
    40%, 43% { transform: translate3d(0, -10px, 0); }
    70% { transform: translate3d(0, -5px, 0); }
    90% { transform: translate3d(0, -2px, 0); }
}

.bounce {
    animation: bounce 1s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .game-header {
        padding: 12px 15px;
    }
    
    .game-header h1 {
        font-size: 1.6em;
    }
    
    .game-main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        padding: 15px;
        gap: 15px;
        min-height: 500px;
    }
    
    .game-area {
        gap: 8px;
    }
    
    .feedback-square {
        width: 45px;
        height: 40px;
    }
    
    .game-row {
        height: 40px; /* Match mobile feedback square height */
        padding: 6px 12px;
    }
    
    .feedback-hole .feedback-peg {
        width: 10px;
        height: 10px;
    }
    
    .control-panel {
        order: -1;
        flex-direction: column;
        max-height: none;
    }
    
    .color-palette {
        margin-bottom: 10px;
    }
    
    .colors {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .color-peg {
        width: 40px;
        height: 40px;
    }
    
    .feedback-legend {
        margin: 10px 0;
        padding: 10px;
    }
    
    .instructions {
        padding: 10px;
        margin-top: 8px;
    }
    
    .instructions li {
        margin: 4px 0;
        padding: 3px 0;
        font-size: 0.75em;
    }
    
    .legend-text {
        font-size: 0.8em;
    }
    
    .game-controls {
        flex-direction: row;
        gap: 10px;
    }
    
    .peg {
        width: 30px;
        height: 30px;
        margin: 2px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .peg {
        width: 35px;
        height: 35px;
    }
    
    .color-peg {
        width: 45px;
        height: 45px;
    }
    
    .game-header h1 {
        font-size: 1.8em;
    }
}

/* Color Picker Popup */
.color-picker-popup {
    position: absolute;
    background: white;
    border: 3px solid #333;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 180px;
    animation: popupAppear 0.2s ease;
}

@keyframes popupAppear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.picker-option {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 3px solid #333;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.picker-option:hover {
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.picker-option.clear-option {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    font-weight: bold;
    font-size: 0.9em;
    width: 100%;
    border-radius: 8px;
    height: 35px;
}

/* Apply same color styles to picker options */
.picker-option.red {
    background-color: #ff4444;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.picker-option.blue {
    background-color: #4444ff;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.picker-option.yellow {
    background-color: #ffdd44;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.picker-option.green {
    background-color: #44ff44;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.picker-option.cyan {
    background-color: #00dddd;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

.picker-option.purple {
    background-color: #aa44ff;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.2);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    margin: 5% auto;
    padding: 30px;
    border: 3px solid #333;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.4s ease;
    position: relative;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
}

.help-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.help-content h3 {
    color: #ff6b6b;
    margin-top: 20px;
    margin-bottom: 10px;
}

.help-content ul {
    list-style: none;
    padding-left: 0;
}

.help-content li {
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.help-content li strong {
    color: #333;
}

.help-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

/* Celebration Modal */
.celebration-modal .modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    max-width: 500px;
}

.celebration-content {
    position: relative;
    overflow: hidden;
}

.fireworks-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.firework {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: scale(0) translate(0, 0);
        opacity: 1;
    }
    100% {
        transform: scale(3) translate(var(--tx, 0), var(--ty, 0));
        opacity: 0;
    }
}

.celebration-message {
    position: relative;
    z-index: 2;
    padding: 20px;
}

.celebration-message h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: bounce 1s ease infinite;
}

.celebration-message p {
    font-size: 1.3em;
    margin-bottom: 30px;
}

#play-again-btn {
    font-size: 1.2em;
    padding: 15px 40px;
}