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

body {
    font-family: 'Noto Sans Telugu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 8px;
    line-height: 1.5;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

@media print {
    body { display: none !important; }
}

.container {
    max-width: 550px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: center;
}

header h1 {
    font-size: 1.3em;
    font-weight: 600;
}

.main-content {
    padding: 15px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Upload */
.upload-section {
    text-align: center;
    margin-bottom: 15px;
}

.upload-btn {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-btn:active {
    background: #764ba2;
    transform: scale(0.97);
}

/* Image Preview */
.image-preview {
    text-align: center;
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.image-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    display: none;
    margin: 0 auto 10px auto;
}

.image-preview img.visible {
    display: block;
}

.no-image {
    color: #999;
    font-size: 0.85em;
    font-style: italic;
}

.no-image.hidden {
    display: none;
}

/* Shape Buttons */
.add-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.add-shape-btn {
    flex: 1;
    min-width: 100px;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Noto Sans Telugu', sans-serif;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    color: white;
}

.circle-btn {
    background: #28a745;
}

.hexadecagon-btn {
    background: #17a2b8;
}

.flower-btn {
    background: #e83e8c;
}

.square-btn {
    background: #fd7e14;
}

.add-shape-btn:active {
    transform: scale(0.95);
}

/* Control Sections */
.control-section {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 10px;
}

.section-label {
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 10px;
    color: #333;
    text-align: center;
}

/* Position Controls */
.position-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.position-btn {
    padding: 10px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.position-btn:active {
    background: #764ba2;
    transform: scale(0.95);
}

.reset-btn {
    grid-column: span 2;
    background: #dc3545;
}

/* Color Picker */
.color-picker-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

input[type="color"] {
    width: 100px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Toggle Container */
.toggle-container {
    display: flex;
    justify-content: center;
    gap: 6px;
    background: #e9ecef;
    padding: 5px;
    border-radius: 8px;
    flex-wrap: wrap;
}

.toggle-btn {
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    color: #666;
    transition: all 0.2s;
    font-family: 'Noto Sans Telugu', sans-serif;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Size Slider */
.size-slider-container {
    margin-top: 10px;
}

.size-slider-container label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    margin-bottom: 8px;
    text-align: center;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

/* Text Section */
.text-section {
    margin: 15px 0;
}

.text-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 0.9em;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.9em;
    font-family: 'Noto Sans Telugu', sans-serif;
    resize: vertical;
    line-height: 1.6;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Preview Section */
.preview-section {
    background: #f8f9fa;
    padding: 15px;
    border-top: 2px solid #e9ecef;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-section h2 {
    color: #333;
    font-size: 1.2em;
    margin: 0;
}

.download-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Noto Sans Telugu', sans-serif;
    transition: all 0.2s;
}

.download-btn:hover {
    background: #218838;
}

.download-btn:active {
    background: #1e7e34;
    transform: scale(0.97);
}

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

.result-container {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    min-height: 200px;
    font-size: 0.85em;
    line-height: 1.7;
    text-align: justify;
    color: #333;
}

.result-container::after {
    content: "";
    display: table;
    clear: both;
}

.placeholder {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 60px 15px;
    font-size: 0.9em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2em;
    margin: 0;
}

.close-modal {
    font-size: 2em;
    line-height: 0.8;
    cursor: pointer;
    color: white;
}

.modal-body {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.size-option-btn {
    background: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 25px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
}

.size-option-btn:hover {
    border-color: #667eea;
    background: #e8f0ff;
}

.size-dimensions {
    font-size: 1.3em;
    color: #667eea;
    font-weight: 700;
}

.auto-size-btn {
    background: #fff3cd;
    border-color: #ffc107;
}

.auto-size-btn .size-dimensions {
    color: #ff6f00;
}

.size-hint {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}

/* Mobile Responsive */
@media (max-width: 360px) {
    .position-controls {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .reset-btn {
        grid-column: span 3;
    }
    
    .color-picker-container {
        gap: 5px;
    }
}