:root {
  color-scheme: dark;
  --ink: #fff5cf;
  --muted: #c9d3ca;
  --gold: #f6c654;
  --gold-light: #ffe79a;
  --panel: rgba(7, 16, 26, .88);
  --panel-2: rgba(18, 31, 39, .94);
  --danger: #ed4e42;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: #06101a; }
body { color: var(--ink); overflow-x: hidden; }
button, kbd { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.game-shell {
  position: relative;
  min-height: 100vh;
  padding: 12px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 9px;
  background:
    radial-gradient(circle at 50% -15%, rgba(31, 91, 150, .42), transparent 42%),
    radial-gradient(circle at 88% 28%, rgba(255, 170, 82, .12), transparent 28%),
    linear-gradient(180deg, #08162b 0%, #040b12 100%);
}

/* Werte bleiben für Accessibility/JS erhalten, die sichtbare HUD-Version wird direkt ins Canvas gezeichnet. */
.game-hud {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.game-stage {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  border: 2px solid rgba(246, 198, 84, .25);
  border-radius: 28px;
  background: #071422;
  box-shadow:
    0 28px 80px rgba(0,0,0,.48),
    inset 0 0 0 1px rgba(255,255,255,.05),
    inset 0 -30px 80px rgba(0,0,0,.18);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 590px;
  object-fit: contain;
  background: #0b2440;
  touch-action: none;
}

.screen-vignette {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 70px rgba(0,0,0,.22),
    inset 0 -70px 95px rgba(0,0,0,.14);
}

.visual-pause {
  position: absolute;
  top: 19px;
  right: 19px;
  z-index: 18;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 3px solid #c7973d;
  border-radius: 15px;
  color: #ffe7a1;
  background: linear-gradient(180deg, rgba(25,36,48,.96), rgba(7,14,22,.96));
  box-shadow: inset 0 0 0 2px rgba(255,226,140,.16), 0 8px 20px rgba(0,0,0,.35);
  font-size: 1.6rem;
  font-weight: 1000;
  line-height: 1;
  cursor: pointer;
}
.visual-pause:hover { filter: brightness(1.13); }
.visual-pause:active { transform: translateY(1px); }

.start-overlay,
.reward-overlay,
.end-overlay {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(4,12,20,.38), rgba(4,10,15,.82)),
    url('assets/visual-splash.webp') center/cover no-repeat;
  backdrop-filter: blur(2px);
}
.reward-overlay { background: radial-gradient(circle at center, rgba(27,38,47,.74), rgba(4,9,14,.94)); }
.end-overlay { background: radial-gradient(circle at center, rgba(32,24,25,.70), rgba(4,9,14,.94)); }

.start-overlay[hidden], .reward-overlay[hidden], .end-overlay[hidden],
.level-banner[hidden], .message-bubble[hidden] { display: none !important; }

.start-card, .reward-card, .end-card {
  width: min(690px, 94%);
  padding: clamp(25px, 4vw, 42px);
  border: 2px solid rgba(246,198,84,.45);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(19,34,45,.94), rgba(7,16,23,.97));
  box-shadow:
    0 35px 95px rgba(0,0,0,.58),
    inset 0 0 0 1px rgba(255,255,255,.05),
    inset 0 20px 45px rgba(62,94,111,.12);
  text-align: center;
}

.troll-emblem {
  width: 82px;
  height: 82px;
  margin: 0 auto 16px;
  border: 4px solid #d9a943;
  border-radius: 50%;
  background: url('assets/grummel-portrait.webp') center/cover no-repeat;
  box-shadow: 0 0 0 4px rgba(8,20,27,.9), 0 10px 25px rgba(0,0,0,.35);
  color: transparent;
  overflow: hidden;
}

.brand-kicker, .hud-stat span, .start-kicker, .end-kicker, .reward-kicker {
  display: block;
  color: #e6bd61;
  font-size: .68rem;
  font-weight: 1000;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.start-card h1, .end-card h2, .reward-card h2 {
  margin: 8px 0 12px;
  color: #fff1b7;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: .98;
  letter-spacing: -.04em;
  text-shadow: 0 3px 0 rgba(76,49,24,.8), 0 8px 24px rgba(0,0,0,.3);
}

.start-card p, .end-card p, .reward-card > p:not(.reward-kicker) {
  margin: 0 auto;
  max-width: 570px;
  color: #d2dbd6;
  line-height: 1.55;
}

.controls-copy {
  margin: 22px 0;
  display: grid;
  gap: 8px;
  color: #eef0dc;
  font-size: .9rem;
}

kbd {
  display: inline-block;
  margin: 0 2px;
  padding: 3px 8px;
  border: 1px solid rgba(255,225,139,.3);
  border-radius: 8px;
  color: #ffe39a;
  background: rgba(8,16,25,.72);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25);
}

.local-start {
  min-height: 52px;
  margin: 6px auto 12px;
  padding: 0 27px;
  border: 2px solid #d9a13a;
  border-radius: 15px;
  color: #2d1c0a;
  background: linear-gradient(180deg, #ffe47d, #d8a53b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 13px 27px rgba(0,0,0,.28);
  font-weight: 1000;
  cursor: pointer;
}
.start-card small, .end-card small, .reward-card small { color: #98a8a8; }

.level-banner {
  position: absolute;
  top: 22px;
  left: 50%;
  z-index: 14;
  min-width: 270px;
  padding: 11px 27px 13px;
  transform: translateX(-50%);
  border: 2px solid rgba(222,171,66,.60);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(15,26,38,.94), rgba(7,13,20,.96));
  box-shadow: 0 12px 26px rgba(0,0,0,.32);
  text-align: center;
}
.level-banner::before, .level-banner::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 28px;
  height: 2px;
  background: #b88937;
}
.level-banner::before { right: 100%; }
.level-banner::after { left: 100%; }
.level-banner span { display:block; color:#d5a84c; font-size:.60rem; font-weight:1000; letter-spacing:.16em; }
.level-banner strong { display:block; margin-top:2px; color:#ffeaad; font-size:1.08rem; }

.message-bubble {
  position: absolute;
  left: 50%;
  bottom: 100px;
  z-index: 15;
  max-width: min(600px, 86%);
  padding: 11px 18px;
  transform: translateX(-50%);
  border: 2px solid rgba(230,183,79,.42);
  border-radius: 999px;
  color: #fff3c4;
  background: rgba(6,15,23,.91);
  box-shadow: 0 12px 30px rgba(0,0,0,.33);
  font-size: .87rem;
  font-weight: 700;
  text-align: center;
}

.end-score {
  margin: 24px auto 18px;
  width: min(260px,100%);
  padding: 14px;
  border: 2px solid rgba(227,176,72,.35);
  border-radius: 18px;
  background: rgba(0,0,0,.22);
}
.end-score span { display:block; color:#cfad6a; font-size:.7rem; text-transform:uppercase; letter-spacing:.12em; }
.end-score strong { display:block; margin-top:2px; color:#ffe47d; font-size:2.15rem; }

.touch-controls {
  position: absolute;
  inset: auto 24px 20px 24px;
  z-index: 17;
  display: grid;
  grid-template-columns: 72px 72px 1fr 78px 82px;
  align-items: end;
  gap: 13px;
  pointer-events: none;
}
.touch-btn {
  width: 72px;
  height: 72px;
  border: 4px solid #b88635;
  border-radius: 50%;
  color: #ffe8a4;
  background: radial-gradient(circle at 40% 35%, #24323d, #09121a 70%);
  box-shadow: inset 0 0 0 3px rgba(255,230,152,.10), 0 8px 20px rgba(0,0,0,.38);
  font-size: 2rem;
  font-weight: 1000;
  pointer-events: auto;
  touch-action: none;
  text-shadow: 0 2px 0 #5e451f;
}
.touch-btn:active { transform: scale(.96); filter: brightness(1.2); }
.touch-attack { grid-column:4; width:78px; height:78px; color:#ffe8a4; }
.touch-jump { grid-column:5; width:82px; height:82px; color:#ffe8a4; }

.reward-options {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin:19px 0;
}
.reward-option {
  min-height:160px;
  padding:18px 15px;
  border:2px solid rgba(216,166,66,.34);
  border-radius:18px;
  color:#f8f2d8;
  background:linear-gradient(180deg, rgba(39,48,55,.78), rgba(11,20,27,.84));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  cursor:pointer;
  text-align:left;
}
.reward-option:hover, .reward-option:focus-visible { border-color:#e8bb5b; background:rgba(90,69,30,.30); outline:none; transform:translateY(-2px); }
.reward-option .reward-icon { display:block; margin-bottom:8px; font-size:1.9rem; }
.reward-option strong { display:block; margin-bottom:6px; color:#ffe797; }
.reward-option span:last-child { display:block; color:#c0cbc7; font-size:.8rem; line-height:1.4; }

.game-footer { min-height:28px; display:grid; place-items:center; }
.game-footer a { color:#72838c; font-size:.72rem; text-decoration:none; }
.game-footer a:hover { color:#d6bd7d; }

html.is-embedded .game-shell { min-height:100dvh; height:100dvh; padding:7px; grid-template-rows:minmax(0,1fr); }
html.is-embedded .game-footer { display:none; }
html.is-embedded .game-stage, html.is-embedded #gameCanvas { min-height:0; height:100%; }

@media (max-width: 820px) {
  .reward-options { grid-template-columns:1fr; }
  .reward-option { min-height:0; }
  .visual-pause { width:48px; height:48px; top:12px; right:12px; }
  .touch-controls { inset:auto 12px 12px 12px; grid-template-columns:58px 58px 1fr 64px 68px; gap:8px; }
  .touch-btn { width:58px; height:58px; border-width:3px; font-size:1.5rem; }
  .touch-attack { width:64px; height:64px; }
  .touch-jump { width:68px; height:68px; }
  .message-bubble { bottom:88px; }
}

@media (max-width: 560px) {
  .game-shell { padding:5px; }
  .game-stage, #gameCanvas { min-height:500px; }
  .start-card, .reward-card, .end-card { padding:20px 15px; }
  .start-card h1, .end-card h2, .reward-card h2 { font-size:2rem; }
  .controls-copy { font-size:.78rem; }
}

/* ─────────────────────────────────────────────────────────────
   Trollquest HUD v1.4.2 · reference-image rebuild
   Dark forged panels, warm gold bevels, glossy red hearts,
   circular mobile controls and a red boss bar.
   ───────────────────────────────────────────────────────────── */
.visual-pause {
  top: 16px;
  right: 16px;
  width: 62px;
  height: 62px;
  border: 5px solid #6d3e13;
  border-radius: 17px;
  color: #ffe3a0;
  background:
    linear-gradient(180deg, rgba(34, 38, 43, .99), rgba(5, 10, 16, .99));
  box-shadow:
    0 9px 20px rgba(0, 0, 0, .48),
    inset 0 0 0 2px #dfa641,
    inset 0 0 0 5px rgba(255, 229, 145, .08),
    inset 0 10px 14px rgba(255, 255, 255, .035);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 1000;
  text-shadow: 0 2px 0 #5c3516;
}
.visual-pause::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 231, 158, .22);
  border-radius: 10px;
  pointer-events: none;
}
.visual-pause:hover { filter: brightness(1.15) saturate(1.05); }
.visual-pause:active { transform: translateY(2px) scale(.985); }

.level-banner {
  top: 118px;
  min-width: 300px;
  padding: 10px 30px 12px;
  border: 4px solid #6f3d10;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(35, 39, 43, .98), rgba(5, 11, 17, .98));
  box-shadow:
    0 14px 30px rgba(0, 0, 0, .45),
    inset 0 0 0 2px #dca13e,
    inset 0 0 0 5px rgba(255, 231, 156, .05);
}
.level-banner::before,
.level-banner::after {
  width: 38px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #d79b35);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .7);
}
.level-banner::after { background: linear-gradient(90deg, #d79b35, transparent); }
.level-banner span {
  color: #d99d39;
  font-family: Georgia, "Times New Roman", serif;
  font-size: .64rem;
  letter-spacing: .18em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .75);
}
.level-banner strong {
  color: #ffe4a1;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .75);
}

.message-bubble {
  bottom: 110px;
  padding: 11px 20px 12px;
  border: 4px solid #623711;
  color: #ffe9b0;
  background: linear-gradient(180deg, rgba(30, 34, 39, .97), rgba(6, 12, 18, .98));
  box-shadow:
    0 12px 28px rgba(0, 0, 0, .42),
    inset 0 0 0 2px #d39a3c,
    inset 0 0 0 5px rgba(255, 231, 157, .035);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.touch-controls {
  inset: auto 26px 18px 26px;
  grid-template-columns: 86px 86px 1fr 90px 94px;
  gap: 15px;
}
.touch-btn {
  position: relative;
  width: 86px;
  height: 86px;
  border: 6px solid #653810;
  color: #f8cf72;
  background:
    radial-gradient(circle at 42% 31%, rgba(49, 55, 59, .98), rgba(8, 13, 19, .99) 64%, #02070b 100%);
  box-shadow:
    0 12px 25px rgba(0, 0, 0, .50),
    inset 0 0 0 3px #daa13e,
    inset 0 0 0 7px rgba(255, 226, 139, .055),
    inset 0 11px 18px rgba(255, 255, 255, .04);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.45rem;
  line-height: 1;
  text-shadow:
    0 3px 0 #6f4318,
    0 0 12px rgba(255, 195, 75, .16);
}
.touch-btn::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 232, 155, .20);
  border-radius: 50%;
  pointer-events: none;
}
.touch-btn:active {
  transform: translateY(2px) scale(.955);
  filter: brightness(1.22) saturate(1.08);
}
.touch-attack {
  grid-column: 4;
  width: 90px;
  height: 90px;
  font-size: 2.2rem;
}
.touch-jump {
  grid-column: 5;
  width: 94px;
  height: 94px;
  font-size: 2.55rem;
}

/* Reward/end surfaces follow the same forged-black + gold HUD material. */
.reward-card,
.end-card,
.start-card {
  border: 5px solid #613711;
  background: linear-gradient(180deg, rgba(31, 37, 42, .97), rgba(6, 12, 18, .985));
  box-shadow:
    0 35px 95px rgba(0, 0, 0, .62),
    inset 0 0 0 2px #d9a03d,
    inset 0 0 0 6px rgba(255, 231, 151, .04),
    inset 0 20px 45px rgba(92, 73, 40, .10);
}
.start-card h1,
.end-card h2,
.reward-card h2 {
  color: #ffe3a0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -.025em;
  text-shadow: 0 3px 0 #5d3518, 0 9px 26px rgba(0, 0, 0, .42);
}
.reward-option {
  border: 4px solid #5b3310;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(38, 43, 47, .92), rgba(8, 14, 20, .96));
  box-shadow: inset 0 0 0 2px rgba(215, 158, 57, .80), 0 10px 22px rgba(0,0,0,.24);
}
.reward-option:hover,
.reward-option:focus-visible {
  border-color: #7c4815;
  box-shadow: inset 0 0 0 2px #efbc54, 0 13px 26px rgba(0,0,0,.34);
}

@media (max-width: 820px) {
  .visual-pause { width: 54px; height: 54px; top: 10px; right: 10px; border-width: 4px; }
  .touch-controls { inset: auto 10px 10px 10px; grid-template-columns: 64px 64px 1fr 70px 74px; gap: 8px; }
  .touch-btn { width: 64px; height: 64px; border-width: 4px; font-size: 1.85rem; }
  .touch-attack { width: 70px; height: 70px; font-size: 1.7rem; }
  .touch-jump { width: 74px; height: 74px; font-size: 2rem; }
  .message-bubble { bottom: 92px; }
  .level-banner { top: 108px; min-width: 250px; }
}

@media (max-width: 560px) {
  .visual-pause { width: 48px; height: 48px; font-size: 1.35rem; }
  .touch-controls { grid-template-columns: 56px 56px 1fr 62px 66px; gap: 6px; }
  .touch-btn { width: 56px; height: 56px; border-width: 4px; font-size: 1.55rem; }
  .touch-attack { width: 62px; height: 62px; font-size: 1.45rem; }
  .touch-jump { width: 66px; height: 66px; font-size: 1.7rem; }
  .level-banner { top: 100px; min-width: 220px; padding-inline: 18px; }
}

/* v214: compact, low-obstruction touch controls. */
.touch-controls {
  inset: auto 14px 8px 14px;
  grid-template-columns: 58px 58px 1fr 62px 66px;
  gap: 8px;
}
.touch-btn {
  width: 58px;
  height: 58px;
  border-width: 4px;
  font-size: 1.65rem;
  opacity: .40;
  transition: opacity .12s ease, transform .12s ease, filter .12s ease;
  box-shadow:
    0 7px 14px rgba(0,0,0,.28),
    inset 0 0 0 2px rgba(218,161,62,.78),
    inset 0 0 0 5px rgba(255,226,139,.04);
}
.touch-btn::after { inset: 6px; opacity: .62; }
.touch-btn:hover,
.touch-btn:focus-visible,
.touch-btn:active {
  opacity: 1;
}
.touch-btn:active {
  transform: translateY(1px) scale(.96);
  filter: brightness(1.22) saturate(1.08);
}
.touch-attack {
  width: 62px;
  height: 62px;
  font-size: 1.55rem;
}
.touch-jump {
  width: 66px;
  height: 66px;
  font-size: 1.8rem;
}

@media (max-width: 820px) {
  .touch-controls { inset: auto 8px 6px 8px; grid-template-columns: 52px 52px 1fr 56px 60px; gap: 6px; }
  .touch-btn { width:52px; height:52px; border-width:3px; font-size:1.45rem; opacity:.40; }
  .touch-attack { width:56px; height:56px; font-size:1.35rem; }
  .touch-jump { width:60px; height:60px; font-size:1.55rem; }
  .message-bubble { bottom:72px; }
}

@media (max-width: 560px) {
  .touch-controls { grid-template-columns: 48px 48px 1fr 52px 56px; gap: 5px; }
  .touch-btn { width:48px; height:48px; font-size:1.3rem; }
  .touch-attack { width:52px; height:52px; font-size:1.2rem; }
  .touch-jump { width:56px; height:56px; font-size:1.4rem; }
}

/* v215: transient level intro overlays. The gameplay field is fully released after 3s. */
#levelBanner {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  transform-origin: center center;
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
}
#levelBanner.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-8px) scale(.92);
  pointer-events: none;
}

#messageBubble {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  transform-origin: center center;
  transition: opacity .5s ease, transform .5s ease;
  pointer-events: none;
}
#messageBubble.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(8px) scale(.96);
  pointer-events: none;
}


/* v256 music toggle ------------------------------------------------------ */
.music-toggle {
  position: absolute;
  top: 19px;
  right: 84px;
  z-index: 18;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 3px solid #c7973d;
  border-radius: 14px;
  color: #ffe7a1;
  background: linear-gradient(180deg, rgba(25,36,48,.96), rgba(7,14,22,.96));
  box-shadow: inset 0 0 0 2px rgba(255,226,140,.16), 0 8px 20px rgba(0,0,0,.35);
  font-size: 1.22rem;
  font-weight: 1000;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.music-toggle:hover { filter: brightness(1.13); }
.music-toggle:active { transform: translateY(1px); }
.music-toggle.is-muted { opacity: .76; }

@media (max-width: 760px) {
  .music-toggle { width: 44px; height: 44px; top: 12px; right: 70px; font-size: 1.05rem; }
}
@media (max-width: 540px) {
  .music-toggle { width: 42px; height: 42px; top: 10px; right: 66px; font-size: 1rem; border-width: 3px; }
}
