/* General Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #fff9e6 100%);
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Check if in iframe or standalone */
body.in-iframe {
    height: 450px;
}

body.standalone {
    height: 90vh;
}

/* Hint Bar */
.hint-bar {
    background: #fff3cd;
    color: #856404;
    padding: 8px 15px;
    text-align: center;
    font-size: 13px;
    border-bottom: 2px solid #ffc107;
    font-weight: 600;
}

/* Progress Container */
.progress-container {
    background: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 2px solid #ddd;
    position: relative;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #81c784 0%, #66bb6a 100%);
    transition: width 0.5s ease;
}

.progress-text {
    font-weight: bold;
    color: #333;
    font-size: 16px;
    white-space: nowrap;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    gap: 15px;
    padding: 15px;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Question Card */
.question-card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.question-header {
    font-size: 14px;
    color: #7b68ee;
    font-weight: bold;
    margin-bottom: 8px;
}

.question-text {
    font-size: 20px;
    color: #333;
    font-weight: bold;
}

/* Table Container */
.table-container {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.table-title {
    font-size: 16px;
    font-weight: bold;
    color: #555;
    margin-bottom: 10px;
    text-align: center;
}

/* ADDED: Info message styling */
.table-info {
    background: #e3f2fd;
    color: #1976d2;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
    text-align: center;
    border: 1px solid #90caf9;
}

.mult-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.mult-table td {
    padding: 8px;
    text-align: center;
    border: 2px solid #ddd;
}

.corner-cell {
    background: #f0f0f0;
    font-weight: bold;
    color: #666;
    width: 60px;
}

.header-cell {
    background: #e3f2fd;
    width: 120px;
}

.product-cell {
    background: #fff9e6;
}

.header-input, .product-input {
    width: 100%;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 6px;
    font-size: 16px;
    text-align: center;
    font-family: 'Courier New', monospace;
    background: white;
    transition: all 0.3s ease;
}

.header-input:focus, .product-input:focus {
    outline: none;
    border-color: #7b68ee;
    box-shadow: 0 0 8px rgba(123, 104, 238, 0.3);
}

.header-input.correct, .product-input.correct {
    background: #c8e6c9;
    border-color: #4caf50;
}

.header-input.incorrect, .product-input.incorrect {
    background: #ffcdd2;
    border-color: #f44336;
}

.header-input:disabled, .product-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.table-message {
    font-size: 13px;
    color: #d32f2f;
    text-align: center;
    min-height: 20px;
    font-weight: 600;
}

/* Answer Container */
.answer-container {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.answer-label {
    font-size: 16px;
    font-weight: bold;
    color: #555;
    margin-bottom: 8px;
}

.answer-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.answer-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #7b68ee;
    box-shadow: 0 0 8px rgba(123, 104, 238, 0.3);
}

.answer-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-power {
    padding: 12px 20px;
    background: #7b68ee;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-power:hover:not(:disabled) {
    background: #6a5acd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-power:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: fit-content;
}

.btn-check {
    background: #66bb6a;
    color: white;
}

.btn-check:hover:not(:disabled) {
    background: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-reset {
    background: #ffa726;
    color: white;
}

.btn-reset:hover {
    background: #ff9800;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-next {
    background: #42a5f5;
    color: white;
}

.btn-next:hover {
    background: #2196f3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

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

.feedback-message {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    min-height: 25px;
    padding: 5px;
    border-radius: 6px;
}

.feedback-message.correct {
    color: #2e7d32;
    background: #c8e6c9;
}

.feedback-message.incorrect {
    color: #c62828;
    background: #ffcdd2;
}

/* Right Panel - Town Map */
.right-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 10px;
    overflow: hidden;
}

#townMap {
    width: 100%;
    height: 100%;
}

/* Building Animations */
@keyframes buildingRise {
    0% {
        transform: translateY(50px);
        opacity: 0;
    }
    60% {
        transform: translateY(-10px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.building-animate {
    animation: buildingRise 0.8s ease-out;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.celebration-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

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

.modal-content h2 {
    color: #7b68ee;
    margin-bottom: 15px;
    font-size: 28px;
}

.modal-content p {
    color: #555;
    font-size: 18px;
    margin-bottom: 25px;
}

/* MODIFIED: Styling for the new celebration town SVG */
#celebrationTown {
    margin: 20px auto;
    display: block;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-retry, .btn-close {
    padding: 12px 30px;
    font-size: 16px;
}

.btn-retry {
    background: #66bb6a;
    color: white;
}

.btn-close {
    background: #42a5f5;
    color: white;
}

/* Confetti */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f44336;
    top: -10px;
    animation: confettiFall 3s linear;
}

@keyframes confettiFall {
    to {
        transform: translateY(600px) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
    }
    
    .right-panel {
        min-height: 250px;
    }
}

/* Scrollbar Styling */
.left-panel::-webkit-scrollbar {
    width: 8px;
}

.left-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.left-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.left-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}