/* =====================================================================
   Edgarversum – gemeinsame Optik für alle Spiele
   ===================================================================== */
:root {
    --bg: #1e3a8a;
    --on-bg: #ffffff;
    --accent: #0ea5e9;
    --accent-dark: #0369a1;
    --ring: #38bdf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif;
    font-weight: 500;
    background: var(--bg);
    background-attachment: fixed;
    color: #1e293b;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: hidden;
}
button { font-family: inherit; }
#app {
    max-width: 540px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 12px 16px 28px;
}

/* --- Kopfleiste --- */
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.spacer { flex: 1; }
.pill {
    background: rgba(255,255,255,.95);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 1.3rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    display: flex; align-items: center; gap: 6px;
}
.pill.bump { animation: bump .4s; }
.icon-btn {
    border: none;
    background: rgba(255,255,255,.95);
    width: 48px; height: 48px;
    border-radius: 50%;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    cursor: pointer; padding: 0;
    flex-shrink: 0;
}
.icon-btn:active { transform: scale(.92); }
#sync-status { font-size: 1.1rem; opacity: .85; width: 28px; text-align: center; }

/* --- Bildschirme --- */
.screen { display: none; flex: 1; flex-direction: column; align-items: center; gap: 14px; }
.screen.active { display: flex; animation: fadeUp .35s ease-out; }
.screen-title { color: var(--on-bg); font-size: 1.8rem; font-weight: 700; margin: 4px 0; text-align: center; }
.screen-sub { color: var(--on-bg); opacity: .9; font-size: 1.2rem; margin: 0; text-align: center; }

.card {
    background: #fff;
    border-radius: 22px;
    padding: 18px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0,0,0,.16);
    text-align: center;
}

.btn {
    display: block; width: 100%;
    border: none; border-radius: 16px;
    padding: 16px 20px;
    font-size: 1.4rem; font-weight: 700;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 6px 0 var(--accent-dark), 0 10px 20px rgba(0,0,0,.15);
    cursor: pointer;
    transition: transform .1s, box-shadow .1s;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--accent-dark); }
.btn:disabled { background: #94a3b8; box-shadow: 0 6px 0 #64748b; cursor: default; transform: none; }
.btn.green  { background: #22c55e; box-shadow: 0 6px 0 #16a34a; }
.btn.orange { background: #f59e0b; box-shadow: 0 6px 0 #d97706; }
.btn.white  { background: #fff; color: #1e293b; box-shadow: 0 6px 0 #cbd5e1; }
.btn.big { padding: 20px; font-size: 1.6rem; }

.speak-btn {
    border: none; background: #e0f2fe; color: #0369a1;
    width: 46px; height: 46px; border-radius: 50%;
    font-size: 1.35rem; cursor: pointer; flex-shrink: 0;
    box-shadow: 0 3px 0 #bae6fd;
}
.speak-btn:active { transform: translateY(2px); box-shadow: none; }
.speak-btn.talking { animation: bump .6s infinite; }

/* --- Willkommen --- */
.world-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.world-card {
    border: 4px solid rgba(255,255,255,.4);
    border-radius: 20px;
    padding: 18px 8px;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 8px 18px rgba(0,0,0,.2);
}
.world-card:active { transform: scale(.96); }
.world-card .w-icon { font-size: 3.2rem; display: block; }
.world-card .w-name { font-size: 1.25rem; font-weight: 700; margin-top: 6px; display: block; }

/* --- Basis --- */
.logo {
    font-size: 2.3rem; font-weight: 700; color: var(--on-bg);
    letter-spacing: .5px; text-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.home-card { display: flex; align-items: center; gap: 14px; text-align: left; }
.avatar { font-size: 4.6rem; line-height: 1; animation: float 3s ease-in-out infinite; }
.home-right { flex: 1; min-width: 0; }
.home-hello { font-size: 1.15rem; color: #64748b; font-weight: 600; }
.rank-name { font-size: 1.35rem; font-weight: 700; color: #1e3a8a; margin: 2px 0; }
.xp-bar { height: 16px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.xp-fill { height: 100%; background: linear-gradient(90deg, #facc15, #f97316); border-radius: 999px; transition: width .6s; }
.xp-text { font-size: .95rem; color: #64748b; }

.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.game-tile {
    border: none; border-radius: 24px; padding: 18px 10px 14px;
    color: #fff; cursor: pointer; text-align: center;
    box-shadow: 0 7px 0 rgba(0,0,0,.25), 0 12px 24px rgba(0,0,0,.2);
    position: relative;
}
.game-tile:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.game-tile .g-icon { font-size: 3.4rem; display: block; line-height: 1.1; }
.game-tile .g-name { font-size: 1.3rem; font-weight: 700; display: block; margin-top: 6px; }
.game-tile .g-sub { font-size: .95rem; opacity: .92; display: block; margin-top: 2px; }
.game-tile .g-badge {
    position: absolute; top: -8px; right: -6px; background: #facc15; color: #78350f;
    font-size: .9rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; transform: rotate(8deg);
}
.home-buttons { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.shop-hint { color: var(--on-bg); font-weight: 600; text-align: center; font-size: 1.1rem; }

/* --- Level --- */
.level-list { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.level-group { color: var(--on-bg); font-weight: 700; font-size: 1.25rem; margin: 6px 4px -2px; }
.level-card {
    display: flex; align-items: center; gap: 14px;
    background: #fff; border: none; border-radius: 20px;
    padding: 14px 16px; width: 100%;
    box-shadow: 0 6px 0 #cbd5e1, 0 10px 20px rgba(0,0,0,.12);
    cursor: pointer; text-align: left;
}
.level-card:active:not(.locked) { transform: translateY(4px); box-shadow: 0 2px 0 #cbd5e1; }
.level-card.locked { opacity: .62; cursor: default; }
.level-icon { font-size: 2.4rem; width: 52px; text-align: center; }
.level-info { flex: 1; }
.level-name { font-size: 1.3rem; font-weight: 700; color: #1e293b; }
.level-sub { font-size: .98rem; color: #64748b; margin-top: 2px; }
.mini-bar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.mini-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.level-coins { font-weight: 700; color: #b45309; font-size: 1.05rem; white-space: nowrap; }

/* --- Gemeinsame Spiel-Elemente --- */
.mission-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--on-bg); font-weight: 700; font-size: 1.1rem; }
.dots { display: flex; gap: 4px; font-size: 1.5rem; flex-shrink: 0; }
.dot { opacity: .25; filter: grayscale(1); transition: all .3s; }
.dot.on { opacity: 1; filter: none; transform: scale(1.15); }
.task-row { display: flex; align-items: center; gap: 10px; }
.task-row .task-texts { flex: 1; text-align: center; }

.float-coins {
    position: fixed; z-index: 1001; pointer-events: none;
    font-size: 2.3rem; font-weight: 700; color: #f59e0b;
    text-shadow: 0 2px 0 #fff, 0 0 12px rgba(255,255,255,.8);
    animation: floatUp 1.4s ease-out forwards;
}
.success { animation: successPulse 1s ease-out; }
.error { animation: shake .5s cubic-bezier(.36,.07,.19,.97) both; }

/* --- Schatz --- */
.treasure-card { margin-top: 20px; padding: 30px 18px; }
.treasure-icon { font-size: 7rem; display: inline-block; transition: transform .5s; }
.treasure-open .treasure-icon { transform: scale(1.25) rotate(8deg); }
.treasure-title { font-size: 1.9rem; color: #1e3a8a; font-weight: 700; margin: 10px 0; }
.treasure-line { font-size: 1.3rem; color: #334155; margin: 6px 0; }
.unlock-note { background: #fef3c7; color: #92400e; border-radius: 14px; padding: 10px; font-weight: 600; margin-top: 10px; font-size: 1.15rem; }
.unlock-note.green { background: #dcfce7; color: #166534; }

/* --- Shop --- */
/* Kategorien brechen in mehrere Zeilen um – so sind immer alle sichtbar (auch am Notebook ohne Wischen) */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.tab {
    flex: 1 1 auto; border: none; border-radius: 14px; padding: 12px 14px; white-space: nowrap;
    font-size: 1.1rem; font-weight: 600;
    background: rgba(255,255,255,.7); color: #334155; cursor: pointer;
}
.tab.active { background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); color: #1e3a8a; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.shop-item { background: #fff; border-radius: 20px; padding: 12px; text-align: center; box-shadow: 0 8px 18px rgba(0,0,0,.14); display: flex; flex-direction: column; gap: 8px; }
.shop-item.equipped { outline: 4px solid #22c55e; }
.preview { height: 88px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 3rem; background: #f1f5f9; overflow: hidden; }
.preview svg { height: 80px; width: 80px; }
.item-name { font-weight: 700; font-size: 1.1rem; color: #1e293b; }
.shop-item .btn { font-size: 1.1rem; padding: 10px 6px; box-shadow: 0 4px 0 var(--accent-dark); }
.shop-item .btn.green { box-shadow: 0 4px 0 #16a34a; }
.shop-item .btn.white { box-shadow: 0 4px 0 #cbd5e1; border: 2px solid #e2e8f0; }

/* --- Dialog & Hinweise --- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 24px; padding: 24px; width: 100%; max-width: 380px; text-align: center; animation: pop .3s; }
.modal-icon { font-size: 4rem; }
.modal-title { font-size: 1.6rem; font-weight: 700; color: #1e3a8a; margin: 8px 0; }
.modal-text { font-size: 1.2rem; color: #475569; margin-bottom: 18px; }
.modal-buttons { display: flex; gap: 12px; }
.toast {
    position: fixed; left: 50%; top: 18%;
    background: #fff; border-radius: 22px; padding: 18px 26px; z-index: 1500;
    box-shadow: 0 20px 40px rgba(0,0,0,.3); text-align: center; font-weight: 700;
    font-size: 1.45rem; color: #1e3a8a; max-width: 90vw;
    transform: translateX(-50%); animation: toastPop .35s;
}
.toast .t-icon { font-size: 3.5rem; display: block; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 70% { transform: scale(1.05); } 100% { transform: scale(1); opacity: 1; } }
@keyframes toastPop { 0% { transform: translateX(-50%) scale(.7); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes bump { 50% { transform: scale(1.18); } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -20px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -120px) scale(1); } }
@keyframes successPulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shake {
    10%, 90% { transform: translate3d(-4px, 0, 0); }
    20%, 80% { transform: translate3d(8px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-12px, 0, 0); }
    40%, 60% { transform: translate3d(12px, 0, 0); }
}

/* =====================================================================
   Spiel: Uhr-Mission
   ===================================================================== */
.uhr-task { padding: 14px 16px; }
.task-prompt { font-size: 1.2rem; color: #64748b; font-weight: 600; }
.task-time { font-size: 2.3rem; color: #1e40af; font-weight: 700; margin: 2px 0 10px; min-height: 1.2em; }
.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
.options .btn { font-size: 1.45rem; padding: 13px; }
.options .btn.wrong { background: #fca5a5; box-shadow: 0 6px 0 #f87171; animation: shake .4s; }
.options .btn.right { background: #22c55e; box-shadow: 0 6px 0 #16a34a; color: #fff; }
.clock-container {
    width: min(100%, 56vh);
    aspect-ratio: 1;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 6px var(--ring), 0 15px 35px rgba(0,0,0,.25);
    position: relative;
    margin-top: 6px;
}
.clock-container svg { width: 100%; height: 100%; touch-action: none; display: block; }
.clock-container svg text { pointer-events: none; font-family: 'Fredoka', sans-serif; }
.hand { cursor: grab; }
.clock-container.locked .hand { cursor: default; }
.clock-container.success { animation: successPulse 1s ease-out; box-shadow: 0 0 0 6px #22c55e, 0 15px 35px rgba(34,197,94,.5); }

/* =====================================================================
   Spiel: Zahlenmonster
   ===================================================================== */
.monster-stage { position: relative; height: 118px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.monster { font-size: 6rem; line-height: 1; animation: monsterIdle 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.monster.eat { animation: monsterEat .7s ease-out; }
.monster.sad { animation: monsterSad .6s ease-out; filter: grayscale(.6); }
.food-fly { position: absolute; left: 50%; bottom: -60px; font-size: 2.6rem; pointer-events: none; animation: feed .6s ease-in forwards; }
.monster-bubble {
    position: absolute; right: 4%; top: 0; background: #fff; border-radius: 16px 16px 16px 4px;
    padding: 6px 12px; font-weight: 600; font-size: 1.05rem; color: #334155; box-shadow: 0 4px 10px rgba(0,0,0,.15);
    opacity: 0; transition: opacity .3s; max-width: 45%;
}
.monster-bubble.show { opacity: 1; }
@keyframes monsterIdle { 50% { transform: translateY(-6px) scale(1.02, .98); } }
@keyframes monsterEat { 0% { transform: scale(1); } 30% { transform: scale(1.25, .8); } 60% { transform: scale(.9, 1.15); } 100% { transform: scale(1); } }
@keyframes monsterSad { 20%, 60% { transform: rotate(-8deg); } 40%, 80% { transform: rotate(8deg); } }
@keyframes feed { 0% { transform: translate(-50%, 0) scale(1); opacity: 1; } 100% { transform: translate(-50%, -150px) scale(.3); opacity: 0; } }

.board {
    width: 100%; border-radius: 22px; padding: 14px 14px 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,.2); text-align: center;
    border: 6px solid #8b5a2b;
    background: #1f3a2e; color: #fff;
}
.board.grid-paper { border-color: #cbd5e1; }
.board-row { display: flex; align-items: center; gap: 8px; }
.board-row .speak-btn, .board-row .help-btn { flex-shrink: 0; }
.help-btn {
    border: none; background: #fef3c7; color: #92400e; height: 46px; border-radius: 999px;
    padding: 0 14px; font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 #fde68a;
}
.help-btn:active { transform: translateY(2px); box-shadow: none; }
.m-task { flex: 1; font-size: 2.6rem; font-weight: 700; white-space: nowrap; letter-spacing: 1px; }
.m-answer {
    display: inline-block; min-width: 1.9em; padding: 0 .2em; border-radius: 12px;
    background: rgba(255,255,255,.18); border-bottom: 4px solid currentColor;
}
.m-answer.blink::after { content: '|'; animation: blink 1s steps(1) infinite; opacity: .6; }
@keyframes blink { 50% { opacity: 0; } }
.board.right .m-answer { background: #22c55e; color: #fff; border-color: #16a34a; }
.board.wrong .m-answer { background: #f87171; color: #fff; }

.m-help { margin-top: 12px; display: none; background: #fff; color: #334155; border-radius: 16px; padding: 12px; }
.m-help.show { display: block; animation: fadeUp .3s; }
.m-help .hint { font-size: 1.25rem; font-weight: 700; color: #1e40af; margin-top: 8px; }
.field20 { display: inline-flex; flex-direction: column; gap: 6px; }
.f-row { display: flex; gap: 12px; }
.f-five { display: flex; gap: 4px; }
.d { width: 20px; height: 20px; border-radius: 50%; display: inline-block; background: #e2e8f0; position: relative; }
.d.a { background: #3b82f6; }
.d.b { background: #f97316; }
.d.x { background: #93c5fd; }
.d.x::after { content: '✕'; position: absolute; inset: 0; color: #dc2626; font-size: 18px; line-height: 20px; font-weight: 700; }
.blocks { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: flex-end; }
.block-num { display: flex; gap: 4px; align-items: flex-end; flex-wrap: wrap; justify-content: center; max-width: 230px; }
.bar { display: flex; flex-direction: column-reverse; gap: 2px; }
.bar i { width: 13px; height: 9px; border-radius: 2px; display: block; }
.ones { display: grid; grid-template-columns: repeat(5, 12px); gap: 3px; align-content: end; }
.ones i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.c-a i { background: #3b82f6; } .c-b i { background: #f97316; }
.block-plus { font-size: 1.8rem; font-weight: 700; color: #475569; align-self: center; }
.array { display: inline-flex; flex-direction: column; gap: 5px; }
.array .a-row { display: flex; gap: 4px; align-items: center; }
.array .a-row .gap { width: 6px; }
.array .d { width: 16px; height: 16px; }
.array .a-row:nth-child(5n) { margin-bottom: 5px; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.numpad button {
    border: none; border-radius: 18px; background: #fff; color: #1e293b;
    font-size: 2rem; font-weight: 700; padding: 12px 0; cursor: pointer;
    box-shadow: 0 5px 0 #cbd5e1;
}
.numpad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }
.numpad .np-del { background: #fee2e2; box-shadow: 0 5px 0 #fca5a5; }
.numpad .np-ok { background: #22c55e; color: #fff; box-shadow: 0 5px 0 #16a34a; }
.numpad button:disabled { opacity: .5; }
