/* Avas Einhorn-Spiel — Pastell/Rosa-Look, große kinderfreundliche Knöpfe */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; touch-action: none; }
body {
  font-family: 'Comic Sans MS', 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(#ffd9ec, #e1bee7);
  user-select: none; -webkit-user-select: none;
}
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---- Vollbild-Menüs ---- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; text-align: center;
  background: linear-gradient(160deg, #ffd9ecee, #d1c4e9ee);
  overflow-y: auto;
}
.screen.hidden, .hidden { display: none !important; }
.screen h1 { color: #ad1457; font-size: clamp(1.8rem, 6vw, 3.2rem); text-shadow: 2px 2px 0 #fff; }
.screen h2 { color: #ad1457; font-size: clamp(1.4rem, 5vw, 2.2rem); text-shadow: 1px 1px 0 #fff; }
.screen p, .subtitle { color: #6a1b9a; font-size: 1.1rem; }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; min-width: min(320px, 80vw); }
.menu-buttons .row { display: flex; gap: 8px; }
button {
  font-family: inherit; font-size: 1.15rem; padding: 14px 26px;
  border: 3px solid #fff; border-radius: 999px; cursor: pointer;
  background: linear-gradient(#ff80ab, #f06292); color: #fff;
  box-shadow: 0 4px 12px #ad145744; transition: transform .1s;
}
button:hover { transform: scale(1.04); }
button:active { transform: scale(0.97); }
button.secondary { background: linear-gradient(#ce93d8, #ab47bc); }
input[type="text"] {
  font-family: inherit; font-size: 1.1rem; padding: 12px 18px; flex: 1;
  border: 3px solid #f48fb1; border-radius: 999px; outline: none;
  text-transform: uppercase; text-align: center; color: #ad1457; background: #fff;
}
.progress { width: min(360px, 70vw); height: 18px; background: #fff; border-radius: 999px; overflow: hidden; border: 2px solid #f48fb1; }
#loading-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #ff5252, #ffb300, #ffee58, #66bb6a, #42a5f5, #ab47bc); transition: width .3s; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud-top-left { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; }
#health-bar { width: min(260px, 40vw); height: 22px; background: #ffffffaa; border: 3px solid #fff; border-radius: 999px; overflow: hidden; box-shadow: 0 2px 8px #0002; }
#health-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff8a80, #ff4081); border-radius: 999px; transition: width .2s; }
#hud-crystals, #hud-trophy-items { font-size: 1.2rem; color: #ad1457; background: #ffffffcc; padding: 4px 14px; border-radius: 999px; width: fit-content; font-weight: bold; }
#wand-timers { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.wand-timer { background: #ffffffcc; border-radius: 999px; padding: 4px 14px; font-size: 1rem; font-weight: bold; border: 2px solid; }

/* Boss-Tafel */
#boss-panel { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #4a148ccc; border: 3px solid #ff80ab; border-radius: 16px; padding: 10px 22px; color: #fff; text-align: center; min-width: min(300px, 70vw); }
#boss-name { font-size: 1.2rem; font-weight: bold; }
#boss-hp-bar { height: 12px; background: #0006; border-radius: 999px; overflow: hidden; margin: 6px 0; }
#boss-hp-fill { height: 100%; background: linear-gradient(90deg, #ff5252, #d50000); transition: width .2s; }
#boss-hint { font-size: .85rem; opacity: .85; }

/* Toasts */
#toasts { position: absolute; bottom: 18vh; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #ffffffee; color: #ad1457; font-size: 1.15rem; font-weight: bold;
  padding: 10px 24px; border-radius: 999px; border: 3px solid #ff80ab;
  animation: toast-in .3s, toast-out .5s 2.7s forwards; box-shadow: 0 4px 14px #0003;
  max-width: 86vw;
}
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-14px); opacity: 0; } }
#coop-badge { position: absolute; bottom: 12px; left: 12px; font-size: 1.6rem; background: #fffc; border-radius: 999px; padding: 6px 12px; }

/* HUD-Knöpfe (Zauberladen, Ton) — klickbar trotz pointer-events:none am HUD */
#castle-compass {
  position: absolute; top: 12px; right: 12px; width: 56px; height: 56px;
  background: #ffffffcc; border: 3px solid #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px #0003;
}
#castle-compass-arrow {
  position: absolute; width: 0; height: 0;
  border-left: 11px solid transparent; border-right: 11px solid transparent;
  border-bottom: 26px solid #ff4081; transform-origin: center;
  filter: drop-shadow(0 1px 1px #0004);
}
#castle-compass .compass-label { position: absolute; bottom: -2px; right: -2px; font-size: .8rem; opacity: .9; }
#hud-buttons { position: absolute; bottom: 12px; right: 12px; display: flex; gap: 8px; pointer-events: auto; }
#hud-buttons button { font-size: 1rem; padding: 10px 16px; }
#btn-sound { padding: 10px 14px; }

/* Blauer Unterwasser-Schleier */
#water-overlay {
  position: fixed; inset: 0; z-index: 9; pointer-events: none; display: none;
  background: radial-gradient(ellipse at center, #2e7bb455 0%, #1a4f8899 100%);
}
#hurt-overlay {
  position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, #ff000000 35%, #d50000cc 100%);
  transition: opacity .08s;
}
.seed-row { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; opacity: .8; font-size: .85rem; }
.seed-row .seed-label { color: #8e6aa8; }
.seed-row input { width: 92px; padding: 6px 10px; font-size: .85rem; border-radius: 999px; border: 2px solid #e1bee7; text-align: center; }
.seed-row button { padding: 5px 12px; font-size: .85rem; }
.seed-line { font-size: 1rem; color: #6a1b9a; background: #fff6; border-radius: 12px; padding: 6px 14px; cursor: pointer; user-select: all; }

/* ---- Shop ---- */
#shop-items { display: flex; flex-direction: column; gap: 10px; width: min(520px, 92vw); }
.shop-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 10px 16px; text-align: left; }
.shop-item .info { flex: 1; }
.shop-item .name { font-weight: bold; color: #ad1457; }
.shop-item .desc { font-size: .85rem; color: #6a1b9a; }
.shop-item .pips { letter-spacing: 2px; font-size: .9rem; }
.shop-item button { padding: 8px 16px; font-size: 1rem; white-space: nowrap; }

/* ---- Trophäen ---- */
#stats-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; width: min(560px, 92vw); }
.stat-box { background: #fff; border-radius: 14px; padding: 8px; color: #ad1457; }
.stat-box .num { font-size: 1.5rem; font-weight: bold; }
#trophy-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; width: min(560px, 92vw); }
.trophy { background: #fff; border-radius: 14px; padding: 10px; color: #ad1457; }
.trophy.locked { opacity: .45; filter: grayscale(.8); }
.trophy .t-name { font-weight: bold; }
.trophy .t-desc { font-size: .8rem; color: #6a1b9a; }

/* ---- Steuerungstabelle ---- */
#controls-table { background: #fff; border-radius: 16px; padding: 10px; border-collapse: collapse; }
#controls-table td { padding: 8px 18px; color: #6a1b9a; }
#controls-table td:first-child { font-weight: bold; color: #ad1457; }

/* ---- Skin-Editor ---- */
#editor-area { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
#editor-canvas { background: #fff; border-radius: 20px; border: 4px solid #f48fb1; max-width: 92vw; }
#editor-controls { display: flex; flex-direction: column; gap: 12px; }
.color-row { display: flex; align-items: center; gap: 10px; background: #fff; padding: 8px 14px; border-radius: 999px; }
.color-row label { color: #ad1457; font-weight: bold; min-width: 130px; text-align: left; }
.color-row input[type="color"] { width: 46px; height: 36px; border: none; border-radius: 8px; cursor: pointer; background: none; }
#editor-canvas { touch-action: none; cursor: crosshair; }
.editor-hint { color: #6a1b9a; font-size: .95rem; margin: 4px 0; }
#editor-tools { display: flex; flex-direction: column; gap: 8px; align-items: center; margin: 10px 0; }
.tool-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; background: #fff8; padding: 6px 10px; border-radius: 999px; max-width: 92vw; }
.tool-label { font-size: 1.2rem; }
.tool-row .swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px #0003; cursor: pointer; padding: 0; }
.tool-row .tool-btn { width: 38px; height: 38px; font-size: 1.3rem; border-radius: 12px; padding: 0; background: #fff; }
.tool-row .swatch.active, .tool-row .tool-btn.active { outline: 3px solid #ad1457; transform: scale(1.12); }

/* ---- Touch ---- */
#touch-ui { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch-stick {
  position: absolute; bottom: 30px; left: 26px; width: 120px; height: 120px;
  border-radius: 50%; background: #ffffff55; border: 3px solid #ffffffaa; pointer-events: auto;
}
#touch-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: #ff80abcc; }
#touch-buttons { position: absolute; bottom: 30px; right: 20px; display: grid; grid-template-columns: auto auto; gap: 10px; pointer-events: auto; }
.touch-btn { width: 64px; height: 64px; border-radius: 50%; font-size: 1.6rem; padding: 0; }
.touch-btn.big { width: 80px; height: 80px; }
.touch-btn.active { background: linear-gradient(#69f0ae, #00c853); }
