/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Main container - responsive height */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh; /* For standalone browser */
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    max-width: 250px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Header styles */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.info-icon {
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.info-icon:hover {
    background-color: rgba(0,0,0,0.1);
}

.score-display {
    font-weight: bold;
    color: #495057;
    font-size: 16px;
}

/* Main game area layout */
.game-area {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 10px;
    padding: 10px;
    height: calc(100% - 60px);
}

/* Shape panel styles */
.shape-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.shape-panel h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #495057;
}

.shape-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.shape-btn {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 12px;
    font-weight: 500;
}

.shape-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.shape-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.dims-info {
    display: none;
    background: white;
    padding: 8px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid #dee2e6;
}

.dims-info.active {
    display: block;
}

/* Shape display area */
.shape-display {
    position: relative;
    background: white;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#shape-container {
    position: relative;
    z-index: 1;
}

.shape {
    position: relative;
}

.rectangle {
    background: #e3f2fd;
    border: 2px solid #2196f3;
    border-radius: 4px;
}

.square {
    background: #f3e5f5;
    border: 2px solid #9c27b0;
    border-radius: 4px;
}

.triangle {
    width: 0;
    height: 0;
    background: transparent;
}

/* Sticker slots */
.sticker-slots {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sticker-slot {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px dashed #ccc;
    border-radius: 50%;
    pointer-events: all;
    transition: all 0.3s;
}

.sticker-slot.highlight {
    border-color: #007bff;
    background: rgba(0,123,255,0.1);
    transform: scale(1.1);
}

.sticker-slot.filled {
    border: none;
    transform: scale(1);
}

/* Control panel */
.control-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-panel h4 {
    font-size: 13px;
    margin-bottom: 6px;
    color: #495057;
}

.calculator-section {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.formula-hint {
    background: #fff3cd;
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    margin-bottom: 8px;
    border: 1px solid #ffeaa7;
    color: #856404;
}

#perimeter-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 14px;
}

.action-btn {
    width: 100%;
    padding: 8px 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s;
}

.action-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.action-btn.secondary {
    background: #6c757d;
}

.action-btn.secondary:hover {
    background: #545b62;
}

.sticker-counter {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    text-align: center;
}

.sticker-count {
    font-size: 18px;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 4px;
}

.sticker-placed {
    font-size: 12px;
    color: #6c757d;
}

.sticker-bank {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.stickers-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    min-height: 40px;
}

.sticker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: grab;
    transition: all 0.3s;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sticker:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.sticker.dragging {
    cursor: grabbing;
    transform: scale(1.2);
    z-index: 1000;
    opacity: 0.8;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons .action-btn {
    flex: 1;
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 300px;
    animation: modalAppear 0.5s ease-out;
}

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

.modal-content h2 {
    color: #28a745;
    margin-bottom: 15px;
}

.modal-content p {
    margin-bottom: 20px;
    color: #495057;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .game-area {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        gap: 8px;
        padding: 8px;
    }
    
    .shape-buttons {
        flex-direction: row;
    }
    
    .shape-btn {
        flex: 1;
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .control-panel {
        padding: 10px;
        gap: 10px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .stickers-container {
        min-height: 30px;
    }
    
    .sticker {
        width: 14px;
        height: 14px;
    }
}

/* Animation classes */
.success-animation {
    animation: successPulse 0.6s ease-out;
}

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

.sticker-place-animation {
    animation: stickerPlace 0.4s ease-out;
}

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