:root { --red: #d52b1e; --red2: #a81f15; --ink: #2a2233; --cream: #fff8ef; --green: #3faa45; --sky: #bfe4ff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--red); color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
#app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; overflow: hidden; }
.screen { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: none; flex-direction: column; overflow-y: auto; overflow-x: hidden;
  background: linear-gradient(#bfe4ff, #e8f6ff 45%, #d7f0c0 46%, #b7e08e); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.screen.on { display: flex; }
#s-play { background: #222; overflow: hidden; touch-action: none; }
#s-play canvas, #homecv { touch-action: none; }

/* Kopfleiste */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; background: var(--red); color: #fff; position: sticky; top: 0; z-index: 5;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12); }
.topbar h2 { margin: 0; font-size: 21px; font-weight: 900; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp { flex: 1; }
.pill { background: rgba(255, 255, 255, .95); color: var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 900; font-size: 17px; white-space: nowrap; }
.ibtn { width: 48px; height: 48px; border-radius: 16px; background: #fff; color: var(--ink); font-size: 26px; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18); flex: none; }
.ibtn.small { width: 42px; height: 42px; font-size: 22px; }
.ibtn:active, .big:active, .mode:active, .card:active, .lvl:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }

/* Start */
.hero-wrap { position: relative; height: 38vh; min-height: 210px; max-height: 330px; flex: none; }
#homecv { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.logo { position: absolute; left: 0; right: 0; top: 10px; text-align: center; pointer-events: none; }
.logo .l1 { display: inline-block; font-size: 44px; font-weight: 900; color: #fff; letter-spacing: 1px; text-shadow: 0 3px 0 var(--red2), 0 5px 10px rgba(0, 0, 0, .25);
  background: var(--red); padding: 0 18px 4px; border-radius: 20px; border: 4px solid #fff; transform: rotate(-2deg); }
.logo .l2 { font-size: 17px; font-weight: 900; color: var(--red2); margin-top: 4px; text-shadow: 0 1px 0 #fff; }
.hello { position: absolute; right: 14px; bottom: 14px; background: #fff; border-radius: 16px 16px 4px 16px; padding: 6px 12px; font-weight: 900; color: var(--red); box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.big { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px 16px; padding: 14px; border-radius: 24px; font-size: 26px; font-weight: 900;
  background: var(--red); color: #fff; box-shadow: 0 6px 0 var(--red2); border: 4px solid #fff; flex: none; }
.big .gi { font-size: 34px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 6px 14px; }
.mode { position: relative; background: #fff; border-radius: 20px; padding: 10px 4px 8px; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mode span { font-size: 32px; line-height: 1.1; }
.mode b { font-size: 13px; font-weight: 900; }
.lockb { position: absolute; top: -4px; right: -4px; background: #fff; border-radius: 999px; font-size: 14px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border-radius: 999px; min-width: 24px; height: 24px; font-size: 14px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; animation: pop 1s infinite; }
@keyframes pop { 50% { transform: scale(1.18); } }
.goals { margin: 10px 14px 18px; background: #fff; border-radius: 22px; padding: 10px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); position: relative; }
.goals h3 { margin: 0 0 6px; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.goal { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 2px dashed #f0e4e2; }
.goal:first-of-type { border-top: 0; }
.goal .gi2 { font-size: 28px; width: 38px; text-align: center; flex: none; }
.goal .gx { flex: 1; min-width: 0; font-weight: 800; font-size: 14px; }
.bar { height: 10px; border-radius: 10px; background: #f1e7e5; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb300, #ff7043); border-radius: 10px; }
.claim { background: var(--green); color: #fff; font-weight: 900; border-radius: 14px; padding: 8px 10px; box-shadow: 0 3px 0 #2a7a30; font-size: 15px; white-space: nowrap; }
.claimed { font-size: 24px; }

/* Welten & Level */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px; }
.card { position: relative; border-radius: 24px; padding: 14px 10px 10px; color: #fff; box-shadow: 0 5px 0 rgba(0, 0, 0, .2); text-align: center; min-height: 130px; overflow: hidden; border: 3px solid rgba(255, 255, 255, .7); }
.card .ci { font-size: 46px; line-height: 1; display: block; }
.card .cn { font-weight: 900; font-size: 16px; margin-top: 6px; display: block; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.card .cs { font-weight: 900; font-size: 14px; margin-top: 4px; display: inline-block; background: rgba(255, 255, 255, .9); color: var(--ink); border-radius: 999px; padding: 2px 10px; }
.card.locked { filter: saturate(.35) brightness(.92); }
.card .lk { position: absolute; top: 8px; right: 8px; font-size: 22px; background: #fff; border-radius: 999px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.lvls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px; }
.lvl { position: relative; background: #fff; border-radius: 20px; padding: 8px 4px; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); text-align: center; min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.lvl .ln { font-size: 22px; font-weight: 900; }
.lvl .lc { font-size: 26px; line-height: 1.1; }
.lvl .ls { font-size: 15px; letter-spacing: 1px; }
.lvl.locked { opacity: .5; }
.lvl.next { outline: 4px solid var(--red); animation: pop 1.4s infinite; }
.tip { margin: 0 14px; background: rgba(255, 255, 255, .9); border-radius: 18px; padding: 10px 14px; font-weight: 800; font-size: 15px; display: flex; gap: 10px; align-items: center; }
.tip span { font-size: 30px; }

/* Spiel */
#cv { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 10px 0; pointer-events: none; z-index: 3; }
.hud > * { pointer-events: auto; }
.hud .pill { font-size: 16px; padding: 6px 10px; box-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.tbar { flex: 1; max-width: 160px; height: 18px; border-radius: 10px; background: rgba(255, 255, 255, .85); overflow: hidden; box-shadow: 0 3px 0 rgba(0, 0, 0, .2); position: relative; }
.tbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #4caf50, #ffeb3b); }
.tbar.out i { background: #aaa; }
.hud.race { justify-content: center; top: 50%; transform: translateY(-50%); padding: 0; }
.ov { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: none; align-items: center; justify-content: center; padding: 16px; z-index: 6; background: rgba(30, 20, 40, .45); }
.ov.on { display: flex; }
.panel { background: #fff; border-radius: 28px; padding: 18px 16px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 8px 0 rgba(0, 0, 0, .2); border: 4px solid var(--red); max-height: 100%; overflow-y: auto; }
.panel h2 { margin: 4px 0 8px; font-size: 28px; color: var(--red); }
.panel .icons { font-size: 52px; line-height: 1.2; margin: 6px 0; }
.panel p { font-size: 17px; font-weight: 800; margin: 6px 0 12px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.btn { background: var(--red); color: #fff; border-radius: 18px; padding: 12px 18px; font-weight: 900; font-size: 20px; box-shadow: 0 5px 0 var(--red2); min-width: 64px; }
.btn.g { background: var(--green); box-shadow: 0 5px 0 #2a7a30; }
.btn.w { background: #f1ece8; color: var(--ink); box-shadow: 0 5px 0 #cfc6bf; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.starsrow { font-size: 56px; letter-spacing: 4px; }
.starsrow i { font-style: normal; display: inline-block; animation: starin .5s both; }
.starsrow i.off { filter: grayscale(1); opacity: .3; }
@keyframes starin { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
.newst { margin-top: 8px; background: #fff4d6; border-radius: 16px; padding: 8px; font-weight: 900; }
.newst span { font-size: 40px; vertical-align: middle; }
.racewin { position: absolute; left: 0; right: 0; height: 50%; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, .4); pointer-events: none; }

/* Album & Garderobe */
.alb { padding: 10px 14px 20px; }
.albrow { background: #fff; border-radius: 20px; padding: 8px 10px; margin-bottom: 10px; box-shadow: 0 4px 0 rgba(0, 0, 0, .1); }
.albrow h4 { margin: 2px 0 6px; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.sts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.st { height: 50px; border-radius: 14px; background: #fdf1e8; display: flex; align-items: center; justify-content: center; font-size: 30px; border: 3px dashed #ead7c8; }
.st.got { background: #fff7c2; border: 3px solid #ffcf3f; animation: wob 3s infinite; }
.st.no { filter: grayscale(1); opacity: .25; }
@keyframes wob { 50% { transform: rotate(4deg); } }
.dressv { display: flex; justify-content: center; padding: 6px; }
#dresscv { width: 180px; height: 180px; background: radial-gradient(#fff, #ffe9e6); border-radius: 50%; border: 4px solid #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.tabs { display: flex; gap: 8px; justify-content: center; padding: 8px; }
.tab { font-size: 26px; width: 58px; height: 50px; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.tab.on { background: var(--red); color: #fff; }
.items { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 8px 14px 20px; }
.item { position: relative; background: #fff; border-radius: 18px; min-height: 82px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); font-size: 30px; }
.item canvas { width: 64px; height: 64px; }
.item.sel { outline: 4px solid var(--red); }
.item.locked { opacity: .55; }
.item small { font-size: 12px; font-weight: 900; }

/* Rennen, Woche, Eltern */
.sec { background: #fff; border-radius: 22px; margin: 10px 14px; padding: 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .1); }
.sec h3 { margin: 0 0 8px; font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; font-size: 28px; min-width: 56px; height: 56px; border-radius: 16px; background: #f5efe9; display: flex; align-items: center; justify-content: center; padding: 0 8px; font-weight: 900; }
.chip.on { background: var(--red); color: #fff; }
.chip.locked { opacity: .5; }
.wk { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-weight: 900; font-size: 17px; border-top: 2px dashed #eee; }
.wk:first-child { border-top: 0; }
.set { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid #f0e8e4; font-weight: 800; }
.set:first-of-type { border-top: 0; }
.set .si { font-size: 24px; width: 32px; text-align: center; }
.set .sl { flex: 1; }
.tog { width: 58px; height: 32px; border-radius: 99px; background: #ddd; position: relative; flex: none; }
.tog::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 3px rgba(0, 0, 0, .3); transition: left .15s; }
.tog.on { background: var(--green); }
.tog.on::after { left: 29px; }
.seg { display: flex; gap: 4px; margin-left: auto; }
.seg button { background: #f1ece8; border-radius: 12px; padding: 6px 10px; font-weight: 900; font-size: 14px; }
.seg button.on { background: var(--red); color: #fff; }
.prog { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 800; font-size: 14px; }
.prog .bar { flex: 1; margin: 0; }
.gate { text-align: center; padding: 18px; }
.gate .q { font-size: 34px; font-weight: 900; margin: 10px 0; }
.keys { display: grid; grid-template-columns: repeat(3, 70px); gap: 10px; justify-content: center; margin-top: 12px; }
.keys button { height: 58px; border-radius: 16px; background: #fff; font-size: 26px; font-weight: 900; box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.ans { font-size: 30px; font-weight: 900; min-height: 44px; background: #fff; border-radius: 14px; width: 140px; margin: 0 auto; padding: 4px; }
.small-note { font-size: 13px; color: #6a5e66; font-weight: 700; padding: 0 14px 16px; text-align: center; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 140px); background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 900; font-size: 17px; z-index: 80; transition: transform .3s; max-width: 92%; text-align: center; pointer-events: none; }
#toast.on { transform: translate(-50%, 0); }
#note { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 70; display: none; align-items: center; justify-content: center; background: rgba(30, 20, 40, .55); padding: 16px; }
#note.on { display: flex; }

@media (min-width: 600px) {
  .modes { grid-template-columns: repeat(8, 1fr); max-width: 900px; margin: 0 auto; width: 100%; }
  .grid { grid-template-columns: repeat(3, 1fr); max-width: 900px; margin: 0 auto; width: 100%; }
  .lvls { grid-template-columns: repeat(4, 1fr); max-width: 760px; margin: 0 auto; width: 100%; }
  .goals, .sec, .tip, .alb { max-width: 760px; margin-left: auto; margin-right: auto; width: calc(100% - 28px); }
  .items { grid-template-columns: repeat(6, 1fr); max-width: 760px; margin: 0 auto; width: 100%; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .hero-wrap { height: 46vh; min-height: 150px; }
  .logo .l1 { font-size: 32px; }
  .modes { grid-template-columns: repeat(8, 1fr); }
  .big { padding: 8px; font-size: 22px; }
}
