/**
 * DEZIMAN - Midnight Ocean Design (Fixed Console Version)
 * Fokus: Stabiles Layout, kein Blenden, perfekte Zentrierung auf iPads.
 */

* {
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

body {
    margin: 0;
    background-color: #1e272e; 
    color: #f1f2f6; 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center; 
    /* WICHTIG: dvh berücksichtigt die Safari-Leisten */
    height: 100dvh; 
    width: 100vw;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    width: 95vw; /* Etwas schmaler für den Rand-Effekt */
    max-width: 450px; 
    /* Hier ist der Trick: 95% des ECHTEN sichtbaren Bereichs */
    height: 95dvh; 
    max-height: 850px; 
    
    position: relative;
    background-color: #2f3542; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border-radius: 20px; 
    overflow: hidden;
    /* Zentriert die Card sauber */
    margin: auto; 
	/*Holt den Canvas nach oben*/
	justify-content: flex-start;
}

/* --- HEADER --- */
#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    background: #2f3542;
    padding-top: env(safe-area-inset-top, 10px); 
    min-height: 60px;
    flex-shrink: 0;
}

/* --- RECHENBEREICH (JETZT OBEN) --- */
#task-area {
    display: flex;
    flex-direction: row; 
    width: 100%;
    padding: 10px 15px; 
    gap: 10px;
    background: #2f3542;
    border-top: 2px solid #0fb9b1;
    transition: all 0.4s ease;
    flex-shrink: 0;
}

.task-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px 12px;
    border-radius: 15px;
    transition: all 0.4s ease;
}

/* --- FARBEN FÜR DIE RECHEN-KACHELN --- */
.p-blue {
    background-color: #54a0ff; /* Spieler-Blau vollflächig */
}

.c-red {
    background-color: #ff6b6b; /* Computer-Rot vollflächig */
}

/* --- SCHRIFTSTYLING DER AUFGABEN --- */
#p-math, #c-math {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    transition: font-size 0.4s ease;
    color: #ffffff; /* Weiß für besseren Kontrast auf Blau/Rot */
}

/* --- LOS BUTTON --- */
#skip-btn {
    background: #1dd1a1; 
    color: white;
    border: none;
    padding: 12px 20px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    width: auto;
    margin: 10px 15px;
    display: block;
    flex-shrink: 0;
    border-radius: 12px;
    box-shadow: 0 4px 0 #10ac84; 
    transition: transform 0.1s;
}

#skip-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #2e86de;
}

/* Neue Klasse für den Wechsel zur Action-Phase (Blau) */
#skip-btn.action-mode {
    background: #54a0ff;
    box-shadow: 0 4px 0 #2e86de;
}

/* --- SPIELFELD --- */
canvas {
    background-color: #ffffff;
    width: 92%;
    margin: 15px auto; /* Fester Abstand oben/unten verhindert das Hüpfen */
    aspect-ratio: 1/1;
    display: block;
    flex-shrink: 0;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

/* --- START OVERLAY --- */
#start-overlay {
	display: none !important; /*ACHTUNG!!! blendet das Start-Overlay aus */
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(47, 53, 66, 0.98); 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#start-overlay h1 {
    color: #0fb9b1; /* Unser Türkis */
    font-size: 3.5rem;
    margin-bottom: 20px;
    letter-spacing: 4px;
    text-shadow: 0 0 15px rgba(15, 185, 177, 0.6); /* Das "Strahlen" */
    text-align: center;
}

#start-btn {
    padding: 20px 50px;
    font-size: 1.8rem;
    font-weight: bold;
    background: #0fb9b1; 
    color: white;
    border: none;
    border-radius: 20px;
    box-shadow: 0 6px 0 #098a84;
    cursor: pointer;
}
.quick-guide hr { /*Gestaltung der Anleitung im Start-Overlay*/
    border: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 15px 0;
}

/* Spezifischere Auswahl für die vs-line */
.quick-guide p.vs-line {
    text-align: center;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 10px;
}

/* Alle anderen p-Elemente im Guide */
.quick-guide p:not(.vs-line) {
    text-align: left;
    margin: 12px 0;
    font-size: 1.1rem;
}

/* Der rote Gegner-Text */
.enemy-text {
    color: #ff6b6b;
    font-weight: 800;
}

/* Die Trennlinie */
hr {
    border: none;
    border-top: 1px solid rgba(15, 185, 177, 0.3);
    margin: 15px 0;
}


/* Optional: Die Begriffe "Du" und "Computer" direkt einfärben */
.quick-guide b:first-child { color: #54a0ff; } /* Blau für den Spieler */
.quick-guide b:nth-of-type(2) { color: #ff6b6b; } /* Rot für den Gegner */

.pacman-mini {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    border-radius: 50%;
    margin-right: 5px;
    /* Erzeugt den Mund durch einen geschickten Border-Trick */
    background: transparent;
    border-right: 10px solid transparent !important;
    border-top: 10px solid;
    border-left: 10px solid;
    border-bottom: 10px solid;
}

.pacman-mini.player {
    border-top-color: #54a0ff;
    border-left-color: #54a0ff;
    border-bottom-color: #54a0ff;
}

.pacman-mini.enemy {
    border-top-color: #ff6b6b;
    border-left-color: #ff6b6b;
    border-bottom-color: #ff6b6b;
}

/*---END-OVERLAY---*/
#end-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(30, 39, 46, 0.95); /* Midnight Ocean Dunkel */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 110;
    padding: 20px;
}

.end-content {
    background: #2f3542;
    width: 100%;
    max-width: 350px;
    border-radius: 25px;
    padding: 30px;
    text-align: center;
    border: 2px solid #0fb9b1;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

#praise-text { color: #0fb9b1; font-size: 2rem; margin: 0 0 20px 0; }

.stats-grid { display: flex; gap: 15px; margin-bottom: 20px; }
.stat-card { 
    background: rgba(255,255,255,0.05); 
    flex: 1; padding: 15px; border-radius: 15px; 
}
.stat-card .label { display: block; font-size: 0.8rem; opacity: 0.7; }
.stat-card .value { font-size: 1.4rem; font-weight: bold; }

.total-box { 
    background: rgba(241, 196, 15, 0.1); 
    border: 1px solid #f1c40f;
    padding: 15px; border-radius: 15px;
    display: flex; align-items: center; justify-content: center; gap: 15px;
    margin-bottom: 20px;
}
.total-info { text-align: left; }
.total-info .value { color: #f1c40f; font-weight: bold; font-size: 1.2rem; }

.motivation { 
    font-size: 1.1rem; 
    line-height: 1.5;
    color: #f1f2f6;
    margin: 20px 0; 
}

.motivation b {
    color: #ff9f43; /* Ein warmes Orange für die Flammen-Info */
}

.final-compliment { 
    color: #54a0ff; 
    font-weight: bold; 
    font-size: 1.5rem; 
    margin-top: 10px;
    letter-spacing: 1px;
}

/* Spielfeld-Effekte */
.shake-it { animation: shake 0.4s ease-in-out; }
.bounce-it { animation: bounce 0.4s ease-in-out; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-4px); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-30px); }
    70% { transform: translateY(-10px); }
}

/* --- PWA INSTALL TUTORIAL --- */
#install-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100dvh;
    background: rgba(30, 39, 46, 0.98);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; padding: 20px;
}

.ipad-arrow-hint {
    position: fixed; 
    top: 10px;        /* Passt ihn an die iPad-Leiste an */
    right: 140px;      /* Position rechts oben beim Teilen-Pfeil */
    font-size: 50px;
    z-index: 10001;   /* Über dem Overlay */
    animation: bounce-up 0.8s infinite alternate ease-in-out;
    pointer-events: none; 
}

@keyframes bounce-up {
    from { transform: translateY(0); }
    to { transform: translateY(15px); }
}

@keyframes bounce-up {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(10px) scale(1.1); }
}

.install-box {
    background: #2f3542;
    border: 3px solid #0fb9b1;
    border-radius: 25px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    position: relative;
    color: white;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    text-align: center;
}

#install-close {
    position: absolute;
    top: -15px; right: -15px;
    background: #ff6b6b; border: 2px solid white; color: white;
    width: 35px; height: 35px; border-radius: 50%;
    font-weight: bold; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.step-card { background: rgba(0,0,0,0.2); padding: 15px; border-radius: 15px; margin: 15px 0; text-align: left; }
.step-row { display: flex; align-items: center; gap: 15px; margin: 10px 0; font-size: 1.1rem; }
.icon-bg { background: white; padding: 4px 8px; border-radius: 8px; font-weight: bold; }

#install-reminder {
    position: fixed;
    /* Wir schieben ihn nach unten, das ist auf iPads sicherer gegen Interface-Färbung */
    bottom: 20px; 
    top: auto; 
    left: 50%;
    transform: translateX(-50%);
    width: 90%; /* Nicht die volle Breite, sieht edler aus */
    max-width: 400px;
    background: #f1c40f; 
    color: #1e272e;
    text-align: center; 
    padding: 12px 15px;
    font-size: 1rem; 
    font-weight: 800;
    z-index: 1500; 
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-radius: 15px; /* Abgerundet sieht es mehr nach einem Tipp aus */
    border: 2px solid #ffffff;
}