:root {
  --bg: #0d0f1f;
  --panel: #171a33;
  --text: #f4f4ff;
  --accent: #ffd23f;
  --accent2: #ff5a4e;
  --green: #3ec33e;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#app {
  height: 100dvh; 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);
}

/* HUD */
#hud {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 6px 10px; font-weight: 800; font-size: 18px; letter-spacing: 0.5px;
  background: var(--panel); flex: 0 0 auto; flex-wrap: wrap;
}
.hud-item { white-space: nowrap; }
#hud-lives { color: var(--accent2); font-size: 22px; letter-spacing: 2px; }
#hud-key { color: #666; border: 2px solid #555; border-radius: 6px; padding: 0 8px; font-size: 14px; }
#hud-key.has { color: #111; background: var(--accent); border-color: var(--accent); }
#hud-score { color: var(--accent); }
#hud-dino { color: var(--green); }
.hud-btn {
  background: transparent; border: 0; cursor: pointer; padding: 4px 8px; color: var(--text);
  min-width: 40px; min-height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
}
.hud-btn svg { width: 22px; height: 22px; }
.hud-btn .ico-off, .hud-btn.muted .ico-on { display: none; }
.hud-btn.muted .ico-off { display: block; }
.hud-btn:focus-visible, .big-btn:focus-visible, .egg:focus-visible, #credit:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Stage */
#stage {
  flex: 1 1 auto; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 6px;
}
#game { display: block; image-rendering: auto; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,0.6); }

/* Screens */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 12px; gap: 10px; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(30,34,70,0.97), rgba(10,12,30,0.98));
}
/* centre the content, but let it scroll from the top when it is taller than the stage */
.screen { justify-content: flex-start; }
.screen::before, .screen::after { content: ''; flex: 1 1 0; min-height: 0; }
.screen.hidden { display: none; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kite { width: 64px; height: 80px; filter: drop-shadow(0 4px 0 rgba(0,0,0,0.35)); }
h1 { margin: 0; line-height: 1; }
.logo h1 { display: flex; flex-direction: column; align-items: center; }
.logo .t1 { font-size: clamp(26px, 6vw, 48px); color: var(--accent2); text-shadow: 3px 3px 0 #7a1d15, -1px -1px 0 #ffb3ad; letter-spacing: 2px; }
.logo .t2 { font-size: clamp(34px, 8vw, 64px); color: var(--accent); text-shadow: 3px 3px 0 #7a5a05, -1px -1px 0 #fff2b3; letter-spacing: 4px; }
.tagline { margin: 4px 0 0; font-size: clamp(14px, 2.2vw, 18px); max-width: 520px; color: #d7d9ff; }
.pick { margin: 6px 0 0; font-size: clamp(18px, 3vw, 26px); color: var(--green); }
.eggs { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 720px; }
.egg {
  width: 96px; padding: 6px 4px 8px; border-radius: 14px; border: 3px solid transparent; background: rgba(255,255,255,0.06);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .12s, border-color .12s;
  color: inherit; font: inherit;
}
.egg canvas { width: 70px; height: 84px; }
.egg span { font-size: 13px; font-weight: 800; }
.egg:hover { transform: translateY(-3px); }
.egg.sel { border-color: var(--accent); background: rgba(255,210,63,0.15); transform: scale(1.08); }
.power { margin: 2px 0; font-size: clamp(15px, 2.4vw, 20px); font-weight: 800; color: #fff; min-height: 1.4em; max-width: 560px; }
.big-btn {
  font-size: clamp(20px, 3.4vw, 30px); font-weight: 900; padding: 12px 40px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--accent); color: #1b1300; box-shadow: 0 6px 0 #b8860b; letter-spacing: 2px; margin-top: 4px;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8860b; }
.hint { margin: 4px 0 0; font-size: 13px; color: #a9acd6; line-height: 1.5; }
.hint.small { font-size: 12px; color: #7f83b8; }
.yay { font-size: clamp(28px, 6vw, 56px); color: var(--green); text-shadow: 3px 3px 0 #145214; }
.boo { font-size: clamp(28px, 6vw, 56px); color: var(--accent2); text-shadow: 3px 3px 0 #7a1d15; }
.big { font-size: clamp(16px, 2.6vw, 22px); font-weight: 700; margin: 0; max-width: 520px; }

/* Touch controls */
#controls {
  flex: 0 0 auto; display: none; align-items: center; justify-content: space-between;
  padding: 8px 18px 12px; gap: 12px;
}
body.touch #controls { display: flex; }
.dpad { display: grid; grid-template-columns: 56px 56px 56px; grid-template-rows: 56px 56px 56px; gap: 4px; }
.dbtn {
  border: 0; border-radius: 12px; background: #2a2f5e; color: #fff; font-size: 22px; font-weight: 900;
  box-shadow: 0 4px 0 #14173a; cursor: pointer;
}
.dbtn:active, .dbtn.on { background: #4d55a8; transform: translateY(3px); box-shadow: 0 1px 0 #14173a; }
.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 3; }
.jump-btn {
  width: 110px; height: 110px; border-radius: 50%; border: 0; background: var(--accent2); color: #fff;
  font-size: 22px; font-weight: 900; box-shadow: 0 6px 0 #7a1d15; cursor: pointer; letter-spacing: 1px;
}
.jump-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a1d15; }

@media (max-width: 480px) {
  #hud { font-size: 15px; gap: 10px; padding: 4px 6px; }
  .dpad { grid-template-columns: 48px 48px 48px; grid-template-rows: 48px 48px 48px; }
  .jump-btn { width: 90px; height: 90px; font-size: 18px; }
  .egg { width: 82px; }
  .egg canvas { width: 56px; height: 68px; }
  .kite { width: 44px; height: 55px; }
}

.rotate-hint { display: none; margin: 4px 0 0; font-size: 14px; font-weight: 700; color: var(--accent); }
@media (max-width: 600px) and (orientation: portrait) { .rotate-hint { display: block; } }

/* Credit link */
#credit {
  flex: 0 0 auto; align-self: flex-end; display: inline-flex; align-items: center;
  min-height: 24px; padding: 2px 10px 4px; font-size: 11px; letter-spacing: 0.3px;
  color: #7f83b8; text-decoration: none; -webkit-user-select: auto; user-select: auto;
}
#credit:hover { color: var(--accent); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .egg, .egg:hover, .egg.sel { transition: none; transform: none; }
}
