/* Grundlegende Formatierung */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    color: #333;
    padding: 10px;
    text-align: center;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px 10px; 
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative; 
}

h1 {
    color: #cc0000;
    border-bottom: 2px solid #cc0000;
    padding-bottom: 10px;
    font-size: 1.8em;
}

/* --------------------------------------
   Steuerelemente (Controls) - Layout
   -------------------------------------- */
.controls {
    margin-bottom: 15px; 
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    display: flex;
    flex-wrap: wrap; 
    justify-content: flex-start;
    align-items: flex-end; 
    gap: 5px;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 0;
    flex-shrink: 1; 
}

/* BREITEN ANPASSUNGEN DER INPUT-FELDER */
#zugnummer { max-width: 80px; min-width: 70px; }
.input-group:nth-child(1) { width: 90px; }
#datum { max-width: 110px; min-width: 90px; }
.input-group:nth-child(2) { width: 120px; }


.controls label {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 0.9em;
}

.controls input {
    padding: 6px; 
    width: 100%;
    box-sizing: border-box;
    font-size: 1em;
}

.button-group {
    display: flex;
    gap: 4px; 
    flex-shrink: 0; 
    flex-grow: 1; 
    justify-content: flex-end;
}

/* Button Styling */
.controls button {
    padding: 3px; 
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    min-width: 85px; 
    flex-grow: 1; 
    line-height: 1.1; 
    height: 48px; 
    font-size: 0.9em;
}

.generate-btn { background-color: #008000; color: white; }
.generate-btn:hover { background-color: #006400; }
.print-btn { background-color: #007bff; color: white; }
.print-btn:hover { background-color: #0056b3; }
.save-img-btn { background-color: #ffc107; color: #333; }
.save-img-btn:hover { background-color: #e0a800; }


/* --------------------------------------
   Bingo-Schein Layout (3x3 Gitter, quadratisch)
   -------------------------------------- */
.bingo-card-container {
    max-width: 600px; 
    margin: 20px auto;
    overflow: hidden; 
}
.bingo-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    grid-auto-rows: 1fr; 
    width: 100%;
    aspect-ratio: 1 / 1; 
    border: 3px solid #333;
}

.bingo-cell {
    border: 1px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px; 
    font-size: 1em; 
    font-weight: bold;
    text-align: center;
    background-color: #eee;
    word-wrap: break-word; 
    overflow-wrap: break-word;
    min-height: 50px; 
    cursor: pointer; 
    position: relative;
    user-select: none; 
}

/* Stil für markierte (getippte) Zelle */
.bingo-cell.marked {
    background-color: #ffe0e0; 
}

/* KREUZLINIEN */
.bingo-cell.marked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 6px; 
    background: red;
    transform: translateY(-50%) rotate(-45deg);
    border-radius: 3px;
    width: 80%; 
    animation: strike-through 0.3s ease-out;
}

.bingo-cell.marked::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 6px; 
    background: red;
    transform: translateY(-50%) rotate(45deg); 
    border-radius: 3px;
    width: 80%;
    animation: strike-through 0.3s ease-out;
}

@keyframes strike-through {
    from { width: 0; }
    to { width: 80%; }
}


.card-info {
    text-align: left;
    margin-bottom: 10px;
    font-size: 0.9em; 
    padding: 5px 0;
    border-bottom: 1px solid #ccc;
    max-width: 100%; 
    margin-left: auto;
    margin-right: auto;
}

.hinweis {
    font-style: italic;
    font-size: 0.8em;
    color: #666;
}

/* --------------------------------------
   BINGO OVERLAY ANIMATION - BASIS
   -------------------------------------- */
#bingo-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 0, 0, 0.9); 
    color: white;
    font-size: 5em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none; 
    opacity: 0;
    z-index: 1000;
    text-shadow: 0 0 10px white, 0 0 20px white;
    transition: opacity 0.5s ease;
    transform: rotate(0deg) scale(0);
}

/* Zustand bei 0 Gewinnlinien */
#bingo-overlay:not(.show-1):not(.show-2):not(.show-3):not(.show-4):not(.show-5):not(.show-6) {
    opacity: 0 !important;
    transform: rotate(0deg) scale(0) !important;
    animation: none !important;
}


/* STUFE 1: BINGO (1 Linie) */
#bingo-overlay.show-1 {
    opacity: 1;
    animation: tada 1.5s ease-out forwards;
}
@keyframes tada {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.2) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* STUFE 2: DOPPEL-BINGO (2 Linien) */
#bingo-overlay.show-2 {
    opacity: 1;
    background-color: rgba(255, 140, 0, 0.95); /* Orange */
    animation: shake-rotate 1.5s ease-out forwards;
}
@keyframes shake-rotate {
    0% { transform: scale(0) rotate(0deg); }
    30% { transform: scale(1.5) rotate(-10deg); }
    60% { transform: scale(1.3) rotate(10deg); }
    80% { transform: scale(1.4) rotate(-5deg); }
    100% { transform: scale(1.3) rotate(0deg); }
}

/* STUFE 3: DREIFACH-BINGO (3 Linien) */
#bingo-overlay.show-3 {
    opacity: 1;
    background-color: rgba(255, 255, 0, 0.98); /* Gelb */
    color: black;
    animation: crazy-zoom 0.5s ease-in-out infinite alternate;
}
@keyframes crazy-zoom {
    0% { transform: scale(1.0) rotate(-1deg); text-shadow: 0 0 5px black; }
    100% { transform: scale(1.6) rotate(1deg); text-shadow: 0 0 20px red; }
}

/* STUFE 4: VIERFACH-BINGO (4 Linien) */
#bingo-overlay.show-4 {
    opacity: 1;
    background-color: rgba(0, 255, 255, 0.98); /* Cyan */
    color: #333;
    font-size: 6em;
    animation: pulse-spin 0.3s infinite;
}
@keyframes pulse-spin {
    0% { transform: scale(1.0) rotate(0deg); text-shadow: 0 0 10px #00f; }
    100% { transform: scale(1.1) rotate(5deg); text-shadow: 0 0 20px #f00; }
}

/* STUFE 5: FÜNFFACH-BINGO (5 Linien) */
#bingo-overlay.show-5 {
    opacity: 1;
    background-color: rgba(255, 0, 255, 0.98); /* Magenta */
    color: white;
    font-size: 7em;
    animation: screen-shake 0.1s infinite;
}
@keyframes screen-shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    100% { transform: translate(-1px, -1px) rotate(-0.5deg); }
}

/* STUFE 6: EXTREM-BINGO (6+ Linien oder Full Card) */
#bingo-overlay.show-6 {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.99); /* Schwarz */
    color: lime; /* Neon-Grün */
    font-size: 8em;
    animation: matrix-glitch 0.05s infinite;
}
@keyframes matrix-glitch {
    0% { transform: scale(1.0) skewX(0deg); filter: blur(0px); }
    50% { transform: scale(1.05) skewX(2deg); filter: blur(0.5px); }
    100% { transform: scale(1.0) skewX(-2deg); filter: blur(0px); }
}


/* --------------------------------------
   Media Query für SCHMALE BILDSCHIRME (Smartphone)
   -------------------------------------- */
@media (max-width: 400px) { 
    .bingo-card-container {
        transform: scale(0.85); 
        transform-origin: top center; 
        margin-top: -30px; 
        margin-bottom: -100px; 
        padding: 0 10px;
    }
    
    .container { padding: 10px; }
    .card-info, .bingo-cell { font-size: 0.9em; }
}

/* --------------------------------------
   Media Query für Größere Bildschirme (PC/Tablet Landscape)
   -------------------------------------- */
@media (min-width: 600px) {
    h1 { font-size: 2.2em; }
    .controls { flex-wrap: nowrap; justify-content: space-between; gap: 15px; }
    .input-group:nth-child(1) { width: 120px; }
    .input-group:nth-child(2) { width: 160px; }
    .controls button { height: auto; min-width: 120px; padding: 10px 15px; font-size: 1em; }
    .bingo-card-container { transform: none; margin: 20px auto; max-width: 600px; }
    .bingo-cell { font-size: 1.1em; }
}


/* --------------------------------------
   DRUCKEINSTELLUNGEN (@media print)
   -------------------------------------- */
@media print {
    body { background-color: white; padding: 0; }
    .container { box-shadow: none; max-width: none; margin: 0; }
    .controls, .hinweis, #bingo-overlay { display: none; } 
    #bingo-card-container { width: 100%; page-break-after: always; }
    .bingo-card { max-width: 100%; border-width: 2px; margin: 10px auto; grid-auto-rows: 1fr; }
    .bingo-cell { font-size: 13pt; min-height: 80px; padding: 5px; }
    .card-info { max-width: 100%; font-size: 11pt; }
    .bingo-cell.marked::after, .bingo-cell.marked::before { content: none; } 
}