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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Generator-Seite: Scrollbar erlauben */
body.generator-page {
    overflow-y: auto;
    align-items: flex-start;
    padding: 20px 0;
}

body.generator-page .container {
    margin: 0 auto;
}

.container {
    width: 90%;
    max-width: 1400px;
    background: rgba(29, 29, 46, 0.9);
    border-radius: 15px;
    padding: 15px 25px;
    box-shadow: 0 0 50px rgba(22, 200, 187, 0.3);
    border: 2px solid rgba(22, 200, 187, 0.5);
}

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

h1 {
    font-size: 1.8em;
    color: #16c8bb;
    text-shadow: 0 0 20px rgba(22, 200, 187, 0.8);
    letter-spacing: 3px;
}

.level-info {
    font-size: 1em;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.stars {
    font-size: 1.2em;
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.grid-container {
    text-align: center;
}

.grid-title {
    font-size: 1em;
    margin-bottom: 8px;
    color: #ff6b9d;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.6);
}

canvas {
    border: 2px solid rgba(22, 200, 187, 0.5);
    border-radius: 10px;
    background: rgba(13, 13, 26, 0.8);
    box-shadow: 0 0 30px rgba(22, 200, 187, 0.3);
    cursor: pointer;
    transition: transform 0.3s;
}

canvas:hover {
    transform: scale(1.05);
}

.masks-section {
    margin-bottom: 12px;
}

.section-title {
    font-size: 1.1em;
    margin-bottom: 8px;
    color: #16c8bb;
    text-shadow: 0 0 10px rgba(22, 200, 187, 0.6);
}

.masks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.mask-item {
    background: rgba(45, 45, 58, 0.8);
    border: 2px solid rgba(22, 200, 187, 0.3);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mask-item:hover {
    border-color: #16c8bb;
    box-shadow: 0 0 20px rgba(22, 200, 187, 0.5);
    transform: translateY(-5px);
}

.mask-item.selected {
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
    background: rgba(255, 215, 0, 0.1);
}

.mask-label {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #fff;
}

.operations-section {
    margin-bottom: 12px;
    background: rgba(45, 45, 58, 0.8);
    border: 3px solid #ff6b9d;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 0 30px rgba(255, 107, 157, 0.5);
}

.operations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}

.operation-btn {
    background: linear-gradient(135deg, #ff6b9d 0%, #c44569 100%);
    border: none;
    border-radius: 8px;
    padding: 12px 15px;
    font-size: 1.2em;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(255, 107, 157, 0.6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.operation-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 0 30px rgba(255, 107, 157, 1);
}

.operation-btn:active:not(:disabled) {
    transform: translateY(0);
}

.operation-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    background: rgba(100, 100, 100, 0.3);
    box-shadow: none;
}

.controls-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.control-btn {
    background: linear-gradient(135deg, #16c8bb 0%, #0e7c74 100%);
    border: none;
    border-radius: 8px;
    padding: 8px 15px;
    font-size: 0.9em;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 15px rgba(22, 200, 187, 0.4);
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 25px rgba(22, 200, 187, 0.8);
}

.control-btn.reset {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.tutorial {
    background: rgba(22, 200, 187, 0.1);
    border: 2px solid rgba(22, 200, 187, 0.5);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
}

.tutorial-text {
    font-size: 0.95em;
    line-height: 1.4;
    color: #fff;
}

.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.success-overlay.show {
    display: flex;
}

.success-content {
    text-align: center;
    animation: scaleIn 0.5s;
}

.success-title {
    font-size: 4em;
    color: #ffd700;
    text-shadow: 0 0 30px rgba(255, 215, 0, 1);
    margin-bottom: 20px;
}

.success-message {
    font-size: 1.5em;
    margin-bottom: 30px;
}

.next-level-btn {
    background: linear-gradient(135deg, #ffd700 0%, #f39c12 100%);
    border: none;
    border-radius: 15px;
    padding: 20px 50px;
    font-size: 1.5em;
    font-weight: bold;
    color: #1a1a2e;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    transition: all 0.3s;
}

.next-level-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 50px rgba(255, 215, 0, 1);
}

/* Level-Auswahlmenü */
.level-select-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s;
}

.level-select-overlay.show {
    display: flex;
}

.level-select-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: rgba(29, 29, 46, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(22, 200, 187, 0.5);
    border: 2px solid rgba(22, 200, 187, 0.7);
    overflow-y: auto;
    animation: scaleIn 0.4s;
}

.level-select-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.level-select-header h2 {
    color: #16c8bb;
    text-shadow: 0 0 15px rgba(22, 200, 187, 0.8);
    font-size: 2em;
}

.close-btn {
    background: rgba(231, 76, 60, 0.8);
    border: none;
    color: white;
    font-size: 1.5em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(231, 76, 60, 1);
    transform: rotate(90deg);
}

.level-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.level-select-btn {
    background: rgba(45, 45, 58, 0.8);
    border: 2px solid rgba(22, 200, 187, 0.3);
    border-radius: 10px;
    padding: 15px 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.level-select-btn:hover {
    background: rgba(45, 45, 58, 1);
    border-color: #16c8bb;
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(22, 200, 187, 0.5);
}

.level-select-btn.completed {
    background: rgba(46, 204, 113, 0.2);
    border-color: rgba(46, 204, 113, 0.6);
}

.level-select-btn.completed:hover {
    background: rgba(46, 204, 113, 0.3);
    border-color: #2ecc71;
}

.level-select-btn.current {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.8);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.level-select-btn.current:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
}

.level-number {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.level-status {
    position: absolute;
    top: 5px;
    right: 5px;
    color: #2ecc71;
    font-size: 1.2em;
}

.level-moves {
    font-size: 0.75em;
    color: #95a5a6;
    margin-top: 5px;
}

.level-current {
    position: absolute;
    bottom: 5px;
    color: #ffd700;
    font-size: 1em;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.5); }
    to { transform: scale(1); }
}

.history {
    background: rgba(45, 45, 58, 0.6);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
    min-height: 45px;
}

.history-title {
    font-size: 0.9em;
    color: #ff6b9d;
    margin-bottom: 6px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.history-item {
    background: rgba(22, 200, 187, 0.2);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid rgba(22, 200, 187, 0.5);
}

/* 3D Pixel Grid Styles */
.pixel-3d-grid {
    display: inline-block;
    perspective: 1200px;
    perspective-origin: 50% 50%;
}

.pixel-3d-container {
    display: grid;
    gap: 5px;
    transform-style: preserve-3d;
    transform: rotateX(10deg) rotateY(0deg);
    transition: transform 0.5s ease;
}

.pixel-3d-container:hover {
    transform: rotateX(0deg) rotateY(0deg) scale(1.05);
}

.pixel-3d {
    width: 30px;
    height: 30px;
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* Würfel-Seiten */
.pixel-3d-face {
    position: absolute;
    width: 30px;
    height: 30px;
    background: #2d2d3a;
    border: 1px solid #1a1a2e;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.pixel-3d.active .pixel-3d-face {
    background: linear-gradient(135deg, #16c8bb 0%, #0e9c91 100%);
    box-shadow: 0 0 20px rgba(22, 200, 187, 0.8),
                inset 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Front Face */
.pixel-3d-front {
    transform: translateZ(15px);
}

.pixel-3d.active .pixel-3d-front {
    background: linear-gradient(135deg, #16c8bb 0%, #0e9c91 100%);
    animation: pixelGlow 2s ease-in-out infinite;
}

/* Back Face */
.pixel-3d-back {
    transform: translateZ(-15px) rotateY(180deg);
    background: #1a1a2e;
}

.pixel-3d.active .pixel-3d-back {
    background: #0a5c56;
}

/* Top Face */
.pixel-3d-top {
    transform: rotateX(90deg) translateZ(15px);
    background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(0,0,0,0.2) 100%);
}

.pixel-3d.active .pixel-3d-top {
    background: linear-gradient(180deg, #1ee7d5 0%, #16c8bb 100%);
}

/* Bottom Face */
.pixel-3d-bottom {
    transform: rotateX(-90deg) translateZ(15px);
    background: #1a1a2e;
}

.pixel-3d.active .pixel-3d-bottom {
    background: #0a5c56;
}

/* Right Face */
.pixel-3d-right {
    transform: rotateY(90deg) translateZ(15px);
    background: linear-gradient(90deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.1) 100%);
}

.pixel-3d.active .pixel-3d-right {
    background: linear-gradient(90deg, #0e9c91 0%, #16c8bb 100%);
}

/* Left Face */
.pixel-3d-left {
    transform: rotateY(-90deg) translateZ(15px);
    background: linear-gradient(90deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 100%);
}

.pixel-3d.active .pixel-3d-left {
    background: linear-gradient(90deg, #16c8bb 0%, #0e9c91 100%);
}

@keyframes pixelGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(22, 200, 187, 0.8),
                    inset 0 0 10px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(22, 200, 187, 1),
                    inset 0 0 20px rgba(255, 255, 255, 0.5);
    }
}

.pixel-3d:hover {
    transform: translateZ(10px) scale(1.1);
}

/* Animations */
@keyframes pixelFlip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

.pixel-3d.flipping {
    animation: pixelFlip 0.6s ease;
}

@keyframes operationPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.operation-btn.active-op {
    animation: operationPulse 0.3s ease;
}

/* Canvas Container für 3D */
.grid-container canvas {
    display: none;
}

.grid-3d-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
    padding: 15px;
}

/* Level Generator Styles */
.generator-page .section {
    background: rgba(45, 45, 58, 0.8);
    border: 2px solid rgba(22, 200, 187, 0.3);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.generator-page .section-title {
    font-size: 1.1em;
    color: #ff6b9d;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.6);
}

.generator-page .form-group {
    margin-bottom: 8px;
}

.generator-page label {
    display: block;
    margin-bottom: 5px;
    color: #16c8bb;
    font-weight: bold;
}

.generator-page input[type="text"],
.generator-page input[type="number"],
.generator-page textarea {
    width: 100%;
    padding: 6px;
    background: rgba(13, 13, 26, 0.8);
    border: 2px solid rgba(22, 200, 187, 0.5);
    border-radius: 5px;
    color: #fff;
    font-size: 0.9em;
    font-family: inherit;
}

.generator-page textarea {
    min-height: 40px;
    resize: vertical;
}

.generator-page .grid-editor {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.generator-page .grid-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.generator-page .grid-controls input {
    width: 60px;
    padding: 5px;
}

.generator-page .pixel-grid {
    display: inline-grid;
    gap: 1px;
    background: rgba(13, 13, 26, 0.8);
    padding: 6px;
    border: 2px solid rgba(22, 200, 187, 0.5);
    border-radius: 5px;
}

.generator-page .pixel {
    width: 20px;
    height: 20px;
    background: #2d2d3a;
    border: 1px solid #1a1a2e;
    cursor: pointer;
    transition: all 0.2s;
}

.generator-page .pixel.active {
    background: #16c8bb;
    box-shadow: 0 0 10px rgba(22, 200, 187, 0.8);
}

.generator-page .pixel:hover {
    transform: scale(1.1);
}

.generator-page .masks-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
}

.generator-page .mask-editor {
    background: rgba(45, 45, 58, 0.6);
    padding: 10px;
    border-radius: 8px;
    flex: 0 1 auto;
    min-width: 180px;
    max-width: 350px;
}
    border: 2px solid rgba(255, 107, 157, 0.3);
}

.generator-page .mask-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.generator-page .mask-title {
    font-size: 0.95em;
    color: #ffd700;
}

.generator-page .btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85em;
}

.generator-page .btn-primary {
    background: linear-gradient(135deg, #16c8bb 0%, #0e7c74 100%);
    color: #fff;
    box-shadow: 0 0 15px rgba(22, 200, 187, 0.4);
}

.generator-page .btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 25px rgba(22, 200, 187, 0.8);
}

.generator-page .btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.4);
}

.generator-page .btn-danger:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 25px rgba(231, 76, 60, 0.8);
}

.generator-page .btn-success {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: #fff;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
    padding: 10px 30px;
    font-size: 1em;
}

.generator-page .btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 25px rgba(46, 204, 113, 0.8);
}

.generator-page .btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: #fff;
}

.generator-page .operations-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.generator-page .operation-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(45, 45, 58, 0.6);
    padding: 10px 15px;
    border-radius: 5px;
    border: 2px solid rgba(22, 200, 187, 0.3);
    cursor: pointer;
}

.generator-page .operation-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.generator-page .operation-checkbox:hover {
    border-color: #16c8bb;
    box-shadow: 0 0 10px rgba(22, 200, 187, 0.5);
}

.generator-page .save-section {
    text-align: center;
    padding: 15px 0;
}

.generator-page .message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.generator-page .message.success {
    background: rgba(46, 204, 113, 0.2);
    border: 2px solid #2ecc71;
    color: #2ecc71;
}

.generator-page .message.error {
    background: rgba(231, 76, 60, 0.2);
    border: 2px solid #e74c3c;
    color: #e74c3c;
}

.generator-page .back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #16c8bb;
    text-decoration: none;
    font-size: 1.1em;
    transition: all 0.3s;
}

.generator-page .back-link:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(22, 200, 187, 0.8);
}
