/* Pias und Sophies Peppa-Wutz-Spiel - alles selbst gebaut, keine externen Assets. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  font-family: "Trebuchet MS", "Verdana", "Avenir Next", system-ui, sans-serif;
}

body {
  height: 100dvh;
  background: linear-gradient(170deg, #ffe9a8 0%, #ffd3e0 55%, #c8f0ff 100%);
  color: #3a2412;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden { display: none !important; }

/* ---------- Startscreen ---------- */

#start {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(170deg, #ffe07a 0%, #ffb3cd 55%, #9fe0ff 100%);
  padding: 20px;
  text-align: center;
}

.start-inner { max-width: 560px; width: 100%; }

#start-pig svg { width: min(58vw, 240px); height: auto; }

#start h1 {
  font-size: clamp(26px, 7.5vw, 46px);
  line-height: 1.12;
  color: #7a3d0d;
  text-shadow: 0 3px 0 #fff, 0 6px 14px rgba(0,0,0,.14);
  margin: 6px 0 4px;
}
#start h1 span { color: #c2185b; }

#start-sub {
  font-size: clamp(15px, 4vw, 20px);
  color: #6a4a2c;
  margin: 10px auto 22px;
  max-width: 28ch;
}

#start-btn {
  font: inherit;
  font-size: clamp(22px, 6.5vw, 32px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(#ff7bac, #e0316f);
  border: 0;
  border-radius: 999px;
  padding: 20px 44px;
  box-shadow: 0 8px 0 #a91b4d, 0 14px 26px rgba(0,0,0,.22);
  cursor: pointer;
  animation: hop 1.5s ease-in-out infinite;
}
#start-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #a91b4d; animation: none; }

@keyframes hop {
  0%, 70%, 100% { transform: translateY(0); }
  82% { transform: translateY(-9px); }
}

/* ---------- Spiel ---------- */

#game { flex: 1; display: flex; flex-direction: column; min-height: 0; }

#hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px 4px;
}

#counter {
  font-size: clamp(17px, 4.6vw, 24px);
  font-weight: 700;
  color: #7a3d0d;
  background: #fff;
  border-radius: 999px;
  padding: 6px 18px;
  box-shadow: 0 3px 0 #e6bd7a;
}

#stars { font-size: clamp(15px, 4vw, 20px); letter-spacing: 2px; }
#stars .on  { filter: none; }
#stars .off { opacity: .28; filter: grayscale(1); }

#stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

#board {
  height: 100%;
  width: auto;
  max-width: 100%;
  aspect-ratio: 600 / 760;
  border-radius: 16px;
  box-shadow: 0 6px 22px rgba(0,0,0,.2);
  background: #efe2cc;
  image-rendering: auto;
}

/* Sprechblase */
#bubble {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: min(94%, 520px);
  background: #fff;
  border: 5px solid #ffb703;
  border-radius: 24px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,.26);
  animation: pop .28s cubic-bezier(.2,1.5,.4,1);
  z-index: 5;
}
#bubble.top { top: 6px; bottom: auto; }
#bubble.win { border-color: #e0316f; background: #fff6fa; }

#bubble-icon { font-size: clamp(30px, 9vw, 46px); line-height: 1; }
#bubble-text {
  font-size: clamp(17px, 4.9vw, 25px);
  font-weight: 700;
  line-height: 1.25;
  color: #3a2412;
}

@keyframes pop {
  from { transform: translateX(-50%) scale(.7); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ---------- D-Pad ---------- */

#pad {
  flex: 0 0 auto;
  height: min(32dvh, 250px);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 6px 10px 10px;
}

.dbtn {
  font: inherit;
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 700;
  color: #fff;
  border: 0;
  border-radius: 22px;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(#6ec1ff, #2b8ede);
  box-shadow: 0 6px 0 #1c6cae;
  transition: transform .05s, box-shadow .05s;
}
.dbtn.up    { grid-column: 2; grid-row: 1; background: linear-gradient(#8ee98a, #3faf49); box-shadow: 0 6px 0 #2c8635; }
.dbtn.left  { grid-column: 1; grid-row: 2; }
.dbtn.down  { grid-column: 2; grid-row: 2; background: linear-gradient(#ffc46b, #f39c12); box-shadow: 0 6px 0 #c07b0b; }
.dbtn.right { grid-column: 3; grid-row: 2; }

.dbtn.active { transform: translateY(5px); box-shadow: 0 1px 0 #1c6cae; filter: brightness(1.08); }
.dbtn.up.active   { box-shadow: 0 1px 0 #2c8635; }
.dbtn.down.active { box-shadow: 0 1px 0 #c07b0b; }

/* Querformat: Pad schmaler, damit die Wohnung sichtbar bleibt. */
@media (orientation: landscape) {
  #game { flex-direction: row; }
  #hud { position: absolute; top: 4px; left: 0; right: 0; z-index: 6; }
  #stage { padding-top: 44px; }
  #bubble.top { top: 46px; }
  #pad { height: auto; width: min(38vw, 320px); align-self: center; aspect-ratio: 3 / 2; }
}
