* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #25273c;
}

.app-container {
    flex: 1;
    width: 70%;
    margin: 20px auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    padding: 56px 40px 40px;
    position: relative;
}

footer {
    background: #23253a;
    text-align: center;
    padding: 5px;
    font-size: 12px;
    color: #fff;
}

footer a {
  color: #4da6ff;
  text-decoration: underline;
}

footer a:visited {
  color: #d32929;
}


h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
    background: linear-gradient(135deg, #1879a7, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 40px;
    font-size: 1.1em;
}

.upload-section {
    text-align: center;
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed #1879a7;
    border-radius: 15px;
    padding: 60px 40px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #764ba2;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #764ba2;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
}

.upload-text {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 10px;
}

.upload-subtext {
    color: #666;
    font-size: 1em;
}

#fileInput {
    display: none;
}

.controls {
    display: none;
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.language-group {
    position: absolute;
    top: 18px;
    right: 22px;
    margin: 0;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 999px;
    background: #f5f7ff;
    border: 1px solid #dde5ff;
    box-shadow: 0 6px 14px rgba(24, 121, 167, 0.08);
    z-index: 2;
}

.language-group label {
    min-width: auto;
    font-size: 0.85em;
    color: #4b5470;
}

.language-group select {
    border: 1px solid #b8c6f5;
    background: white;
    color: #25324d;
    font-weight: 600;
    border-radius: 999px;
    padding: 6px 12px;
    min-width: 110px;
}

.control-group:last-child {
    margin-bottom: 0;
}

label {
    font-weight: 600;
    color: #333;
    min-width: 100px;
}

select, input[type="range"] {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

select:focus, input[type="range"]:focus {
    outline: none;
    border-color: #1879a7;
}

input[type="range"] {
    flex: 1;
    max-width: 200px;
}

.range-value {
    font-weight: bold;
    color: #1879a7;
    min-width: 30px;
}

.preview-section {
    display: none;
    margin-bottom: 30px;
}

.preview-title {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.preview-container {
    border: 2px solid #e1e5e9;
    border-radius: 15px;
    padding: 20px;
    background: #f8f9fa;
    overflow: auto;
    max-height: 600px;
}

.preview-grid {
    display: grid;
    gap: 2px;
    justify-content: center;
}

.preview-cell {
    border: 1px solid #ccc;
    background: white;
    position: relative;
    overflow: hidden;
}

.preview-cell canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.cell-number {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.download-section {
    display: none;
    text-align: center;
}

.download-btn {
    background: linear-gradient(135deg, #1879a7, #764ba2);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

.download-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.info-panel {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.info-text {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1879a7;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes langTextSwap {
    0% {
        opacity: 0.55;
        transform: translateY(6px);
        filter: blur(1px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.lang-text-anim {
    animation: langTextSwap 0.32s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .lang-text-anim {
        animation: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        width: 92%;
        padding: 74px 20px 20px;
    }
    
    .control-group {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .control-group label {
        min-width: auto;
    }

    .language-group {
        top: 14px;
        right: 14px;
        left: 14px;
        justify-content: space-between;
        flex-direction: row;
    }

}
