:root {
  --ink: #23204f;
  --muted: #6c6993;
  --panel: #ffffff;
  --soft: #efeefb;
  --blue: #2f7dff;
  --red: #ff4d4d;
  --green: #2fbf71;
  --yellow: #ffc83d;
  --gold: #ffc83d;
  --focus: #ffc83d;
  --font: 'Trebuchet MS', 'Arial Rounded MT Bold', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #4fb0ff;
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

.i {
  width: 1em;
  height: 1em;
  fill: currentColor;
  display: inline-block;
  vertical-align: middle;
  flex: none;
}
.i.on { color: var(--green); }
.i.off { color: var(--red); }
.emo { font-size: 1.4em; line-height: 1; vertical-align: middle; }

#ui { position: fixed; inset: 0; pointer-events: none; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}
.screen.active { display: flex; animation: fade .25s ease-out; }
.screen.dim { background: rgba(26, 22, 70, .55); }

/* ---------- Titel ---------- */

#screen-title {
  justify-content: flex-start;
  padding-left: max(16px, 7vw);
  background: linear-gradient(90deg, rgba(26, 22, 70, .62) 0%, rgba(26, 22, 70, .35) 38%, rgba(26, 22, 70, 0) 65%);
}
.title-box { width: min(400px, 100%); }

.logo {
  margin: 0 0 22px;
  font-size: clamp(54px, 9vw, 112px);
  line-height: .9;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .01em;
}
.logo span {
  display: block;
  color: #fff;
  text-shadow: 0 5px 0 #1d4fb8, 0 9px 0 rgba(0, 0, 0, .18), 0 14px 30px rgba(0, 0, 0, .25);
}
.logo .logo-2 {
  color: var(--yellow);
  text-shadow: 0 5px 0 #d07a00, 0 9px 0 rgba(0, 0, 0, .18), 0 14px 30px rgba(0, 0, 0, .25);
  transform: rotate(-3deg);
  transform-origin: left;
}

.big-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 64px !important;
  padding: 14px 20px !important;
}
.lvl-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .18);
  font-size: 30px;
  font-weight: 900;
  color: #fff;
}
.lvl-tag .i { color: #fff; }

.icon-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.icon-btn { font-size: 40px !important; padding: 12px 0 !important; }

.gem-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 12px;
  border-radius: 999px;
  background: rgba(34, 32, 74, .72);
  color: #fff;
  font-size: 28px;
  font-weight: 900;
}
.gem-count.corner { position: absolute; top: 16px; right: 16px; }

/* ---------- Knöpfe ---------- */

.btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 20px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 6px 0 #cfcbe9;
  cursor: pointer;
  text-align: center;
  outline: 5px solid transparent;
  outline-offset: 3px;
  transition: transform .12s ease, outline-color .12s ease;
}
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 6px 0 #1d8a50; font-size: 46px; }
.btn.danger { background: #ffe3e3; color: #c42a30; box-shadow: 0 6px 0 #f2b8b8; }
.btn.focused { transform: translateY(-2px) scale(1.04); outline-color: var(--focus); }
.btn:active { transform: translateY(3px); }

/* Gedrückt halten: roter Balken füllt sich */
.hold { position: relative; overflow: hidden; }
.hold::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #ff4d4d;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
}
.hold > .i { position: relative; }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.btn-row.wide-left { grid-template-columns: 2fr 1fr; }

/* ---------- Panels ---------- */

.panel {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel);
  border-radius: 28px;
  padding: 22px 26px 18px;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .35), 0 24px 60px rgba(10, 8, 40, .45);
  text-align: center;
  animation: pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.panel > .btn { margin-top: 14px; }
.panel.wide { width: min(760px, 100%); }
.panel .btn:not(.primary):not(.danger) { background: var(--soft); box-shadow: 0 6px 0 #d3d0ee; }

.head-icon { font-size: 52px; color: var(--ink); line-height: 1; margin-bottom: 8px; }
.head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.head-row .head-icon { margin: 0; }

/* ---------- Ergebnis ---------- */

.crown-badge { font-size: 84px; line-height: 1; color: #d6d3e6; }
.crown-badge.on { color: var(--gold); filter: drop-shadow(0 0 14px rgba(255, 200, 61, .9)); animation: crownPop .7s cubic-bezier(.2, 1.6, .4, 1) both; }

.stars { font-size: 60px; line-height: 1; margin: 4px 0; }
.star { color: #dcd9ef; display: inline-block; margin: 0 2px; }
.star.on { color: var(--yellow); filter: drop-shadow(0 4px 0 #d08a00); animation: starPop .5s cubic-bezier(.2, 1.6, .4, 1) both; }

.calc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 34px;
  font-weight: 900;
  margin: 12px 0 4px;
  min-height: 1em;
}
.num { display: inline-block; padding: 2px 14px; border-radius: 14px; color: #fff; }
.num.b { background: var(--blue); }
.num.r { background: var(--red); }
.giant-mini { font-size: 34px; color: var(--gold); }

.gems-won { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0 0; font-size: 40px; font-weight: 900; color: #0b7fd8; }

.sad { font-size: 110px; line-height: 1; }

/* ---------- Level-Auswahl ---------- */

.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  padding: 6px;
}
.lvl {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: #eef0ff;
  box-shadow: 0 4px 0 #cfd3f3;
  font: inherit;
  font-weight: 900;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  outline: 4px solid transparent;
  outline-offset: 2px;
  transition: transform .1s ease;
}
.lvl .st { font-size: 12px; color: #cfcbe6; line-height: 1; min-height: 12px; letter-spacing: 1px; }
.lvl .st .on { color: #f5b000; }
.lvl.locked { background: #e9e8f1; color: #a5a3bd; box-shadow: 0 4px 0 #d6d4e4; }
.lvl.current { background: #dff7ea; box-shadow: 0 4px 0 #a6e3c2; }
.lvl.focused { outline-color: var(--focus); transform: scale(1.1); z-index: 1; }
.lvl-crown { position: absolute; top: -9px; right: -6px; font-size: 22px; color: var(--gold); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }

/* ---------- Farben-Laden ---------- */

.shop-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; padding: 8px 4px; }
.skin {
  border: 0;
  border-radius: 18px;
  padding: 10px 4px 8px;
  background: var(--soft);
  box-shadow: 0 5px 0 #d3d0ee;
  cursor: pointer;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  outline: 5px solid transparent;
  outline-offset: 2px;
  transition: transform .1s ease;
}
.skin img { height: 96px; width: auto; }
.skin .price { display: flex; align-items: center; gap: 3px; height: 28px; font-size: 22px; font-weight: 900; color: var(--ink); }
.skin .price .sel { font-size: 30px; color: var(--green); }
.skin.selected { background: #dff7ea; box-shadow: 0 5px 0 #a6e3c2; }
.skin.cant .price { opacity: .5; }
.skin.focused { outline-color: var(--focus); transform: scale(1.06); }

/* ---------- Einstellungen ---------- */

.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: 16px;
  background: var(--soft);
  cursor: pointer;
  outline: 4px solid transparent;
  outline-offset: 2px;
}
.opt.focused { outline-color: var(--focus); background: #fff8e1; }
.opt-icon { font-size: 34px; color: var(--ink); display: flex; }
.opt-val { display: flex; align-items: center; gap: 8px; }
.opt-val b { min-width: 7.5em; display: flex; justify-content: center; font-size: 30px; }
.arr { color: var(--muted); font-size: 28px; display: flex; padding: 2px; }
.ops { display: inline-flex; gap: 4px; }
.ops i {
  font-style: normal;
  display: inline-grid;
  place-items: center;
  width: 1.15em;
  height: 1.15em;
  border-radius: 8px;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  background: var(--blue);
}
.ops i:nth-child(2), .ops i:nth-child(4) { background: var(--red); }

/* ---------- Tasten-Hinweise ---------- */

.hints {
  margin: 16px 0 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.hints .i { font-size: 24px; }
.hints .hint-ok { color: var(--green); }
.hints .hint-back { color: var(--muted); }
.hints.light { color: rgba(255, 255, 255, .92); justify-content: flex-start; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.hints.light .hint-back { color: #fff; }
.hints .sep { width: 12px; }
.g {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}
.g-a { background: #3cb043; }
.g-b { background: #e5383b; }
.g-pad { background: #2b2b3d; }
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  border: 2px solid #c9c6e8;
  border-bottom-width: 4px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

/* ---------- Meldungen ---------- */

#toast {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translate(-50%, -160%);
  padding: 10px 22px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 34px;
  box-shadow: 0 10px 30px rgba(10, 8, 40, .3);
  transition: transform .3s cubic-bezier(.2, 1.3, .4, 1), visibility 0s linear .3s;
  pointer-events: none;
  visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }

#sound-hint {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 9;
  display: flex;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 18px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 6px 18px rgba(10, 8, 40, .25);
  cursor: pointer;
  animation: nudge 1.6s ease-in-out infinite;
}
#sound-hint[hidden] { display: none; }

.shake { animation: shake .4s ease; }

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: #fff;
  font-size: 22px;
  font-weight: 800;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
@keyframes starPop { from { transform: scale(0) rotate(-40deg); } }
@keyframes crownPop { 0% { transform: scale(0) rotate(-30deg); } 60% { transform: scale(1.25) rotate(8deg); } }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
@keyframes nudge { 50% { transform: translateY(-4px); } }

@media (max-width: 720px) {
  .level-grid { grid-template-columns: repeat(5, 1fr); }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  #screen-title { justify-content: center; padding-left: 16px; background: rgba(26, 22, 70, .5); }
  .opt-val b { min-width: 5.5em; }
}

@media (max-height: 600px) {
  .logo { font-size: 46px; margin-bottom: 12px; }
  .big-play { font-size: 44px !important; }
  .icon-btn { font-size: 30px !important; }
  .btn { font-size: 28px; }
  .btn.primary { font-size: 34px; }
  .crown-badge { font-size: 60px; }
  .stars { font-size: 44px; }
}
