* {
    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%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

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

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
}

.pixel-grid-container {
    flex: 1;
    min-width: 600px;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.toolbar button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #e9ecef;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.toolbar button:hover {
    background: #dee2e6;
    transform: translateY(-2px);
}

.toolbar button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.pixel-grid {
    width: 100%;
    height: 600px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.pixel-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 10px 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1;
}

.pixel-grid:hover::before {
    opacity: 1;
}

.pixel-grid.view-mode {
    cursor: pointer;
}

.selection-info {
    margin-top: 15px;
    padding: 15px;
    background: #e7f3ff;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #b8daff;
}

.selection-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.selection-info span {
    font-weight: 600;
    color: #004085;
}

.price-display {
    color: #28a745;
    font-size: 1.1em;
    font-weight: 700;
}

.price-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.price-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.price-value {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0 10px;
}

.price-note {
    font-size: 0.8em;
    opacity: 0.8;
}

.selection-info button {
    padding: 10px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.selection-info button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.ad-form-container {
    width: 350px;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.ad-form-container h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="color"] {
    height: 45px;
    cursor: pointer;
}

.form-group input[type="file"] {
    padding: 8px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.submit-btn,
.cancel-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

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

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.cancel-btn {
    background: #e9ecef;
    color: #495057;
}

.cancel-btn:hover {
    background: #dee2e6;
}

.stats-panel {
    width: 250px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.stats-panel h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item span:first-child {
    color: #666;
    font-weight: 500;
}

.stat-item span:last-child {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1em;
}

.visit-stats-panel {
    width: 250px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.visit-stats-panel h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.visit-stats-panel .stat-item span:last-child {
    color: #667eea;
    font-weight: 700;
    font-size: 1.1em;
}

.stats-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.payment-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.payment-modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.payment-modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.payment-details {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.payment-details p {
    margin: 10px 0;
    color: #666;
    font-size: 0.95em;
}

.payment-details span {
    color: #333;
    font-weight: 600;
    margin-left: 10px;
}

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

.qrcode-section {
    text-align: center;
    margin: 20px 0;
}

.qrcode-section p {
    color: #666;
    margin-bottom: 15px;
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.qrcode-img {
    max-width: 200px;
    height: auto;
    border: 2px solid #667eea;
    border-radius: 10px;
    padding: 10px;
    background: white;
}

.payment-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.confirm-payment-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.confirm-payment-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.order-number {
    font-size: 1.1em;
    color: #667eea;
    font-weight: 700;
}

.order-number span {
    font-size: 1.3em;
    letter-spacing: 2px;
}

.payment-instruction {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid #667eea;
}

.payment-instruction h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.payment-instruction p {
    color: #666;
    margin: 8px 0;
    font-size: 0.95em;
    line-height: 1.6;
}

.email-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    color: #667eea;
    font-size: 1em;
}

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

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

.ad-block {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.ad-block:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.ad-block img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ad-block .ad-title {
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
    padding: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selection-box {
    position: absolute;
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
    pointer-events: none;
    z-index: 2;
    box-sizing: border-box;
}

.selection-box::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background-image: 
        linear-gradient(to right, rgba(102, 126, 234, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(102, 126, 234, 0.3) 1px, transparent 1px);
    background-size: 10px 10px;
    background-position: 0 0;
    pointer-events: none;
}

.selection-box.overlapping {
    border: 2px dashed #dc3545;
    background: rgba(220, 53, 69, 0.2);
}

.selection-box.overlapping::after {
    background-image: 
        linear-gradient(to right, rgba(220, 53, 69, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(220, 53, 69, 0.3) 1px, transparent 1px);
}

@media (max-width: 1200px) {
    .pixel-grid-container {
        min-width: 100%;
    }
    
    .ad-form-container,
    .stats-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .pixel-grid {
        height: 400px;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .toolbar button {
        width: 100%;
    }
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 53, 69, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    font-size: 16px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: rgba(40, 167, 69, 0.95);
}

.toast.warning {
    background: rgba(255, 193, 7, 0.95);
    color: #333;
}

.footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.footer-content p {
    margin: 0;
}

.footer-link {
    color: #6c757d;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: #667eea;
}