* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #1b2a1b; color: #fff;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
canvas#game { position: fixed; left: 0; top: 0; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: #fff; border: none; cursor: pointer; touch-action: manipulation; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; overflow-y: auto;
  -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: radial-gradient(circle at 50% 25%, #66bb6a 0%, #2e7d32 45%, #0d260f 100%);
  text-align: center;
}
.screen.overlay { background: rgba(8, 18, 8, 0.8); z-index: 20; }
.screen .inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 900px; width: 100%; }
h1, h2, h3 { margin: 4px 0; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
h2 { font-size: clamp(28px, 5vw, 44px); color: #ffd54f; }
h3 { font-size: 22px; }
.logo {
  font-size: clamp(48px, 11vw, 110px); line-height: 1; color: #ffd54f; letter-spacing: 2px;
  text-shadow: 0 4px 0 #e65100, 0 8px 0 #7f2b00, 0 12px 24px rgba(0,0,0,.5);
}
.name-dragon { width: min(50vw, 240px); height: auto; aspect-ratio: 3 / 2; }
.best { font-size: 20px; color: #fff59d; min-height: 24px; }
.version { font-size: 13px; opacity: .6; }
#screen-title {
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 42%, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.35) 55%, rgba(0,0,0,0.7) 100%);
}
.title-inner { gap: 10px; }
.kicker {
  font-size: clamp(16px, 2.6vw, 22px); font-weight: bold; letter-spacing: 1px; color: #fff3e0;
  background: rgba(0,0,0,.45); padding: 6px 16px; border-radius: 20px; animation: fadeUp .6s ease-out both;
}
.logo.roar {
  font-family: "Arial Black", "Futura", "Trebuchet MS", sans-serif; font-weight: 900;
  font-size: clamp(56px, 13vw, 132px); line-height: .95; letter-spacing: 2px; margin: 2px 0 4px;
  background: linear-gradient(180deg, #fff9c4 0%, #ffd54f 30%, #ff8f00 62%, #d84315 85%, #8e1b0e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 2px #3e1200; text-shadow: none;
  filter: drop-shadow(0 5px 0 #3e1200) drop-shadow(0 12px 20px rgba(0,0,0,.65));
  animation: logoIn .9s cubic-bezier(.2, 1.5, .4, 1) both, roar 4s ease-in-out 1.2s infinite;
  cursor: pointer;
}
.logo.roar .tm {
  font-family: "Trebuchet MS", sans-serif; font-size: .22em; vertical-align: super; margin-left: .06em;
  -webkit-text-fill-color: #ffe082; -webkit-text-stroke: 0; color: #ffe082;
}
.copyright { line-height: 1.45; }
.logo.roar.roaring { animation: roarNow .6s ease-out; }
.tagline {
  font-size: clamp(16px, 2.4vw, 21px); max-width: 620px; color: #fff; font-weight: bold;
  text-shadow: 0 2px 6px rgba(0,0,0,.9); animation: fadeUp .6s .3s ease-out both;
}
.features { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 700px; animation: fadeUp .6s .5s ease-out both; }
.chip {
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.28); padding: 6px 13px; border-radius: 20px;
  font-size: 15px; font-weight: bold; white-space: nowrap;
}
.counter { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; animation: fadeUp .6s ease-out both; }
.count {
  display: flex; flex-direction: column; min-width: 150px; padding: 8px 18px; border-radius: 16px;
  background: rgba(20,8,0,.6); border: 2px solid rgba(255,193,7,.65); box-shadow: 0 0 18px rgba(255,111,0,.35);
}
.count .num { font-size: 30px; font-weight: 900; color: #ffd54f; font-variant-numeric: tabular-nums; line-height: 1.1; }
.count .lbl { font-size: 13px; letter-spacing: .5px; text-transform: uppercase; opacity: .85; }
#screen-title .best, #screen-title .version { text-shadow: 0 1px 4px #000; }
@keyframes logoIn { from { opacity: 0; transform: scale(.4) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes roar { 0%, 86%, 100% { transform: none; } 89% { transform: scale(1.07) rotate(-1.5deg); } 92% { transform: scale(1.04) rotate(1.5deg); } 95% { transform: scale(1.06) rotate(-1deg); } }
@keyframes roarNow { 0% { transform: none; } 30% { transform: scale(1.12) rotate(-2deg); } 60% { transform: scale(1.06) rotate(2deg); } 100% { transform: none; } }
.copyright { flex: none; padding-top: 10px; font-size: 13px; color: rgba(255,255,255,0.75); }

.big {
  font-size: 28px; font-weight: bold; padding: 14px 40px; border-radius: 40px;
  background: linear-gradient(#ffca28, #f57c00);
  box-shadow: 0 6px 0 #a64b00, 0 8px 20px rgba(0,0,0,.4);
  text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #a64b00; }
.big:disabled { filter: grayscale(1); opacity: .55; }
.mid {
  font-size: 20px; font-weight: bold; padding: 10px 24px; border-radius: 30px;
  background: #388e3c; box-shadow: 0 4px 0 #1b5e20;
}
.mid:active { transform: translateY(3px); box-shadow: 0 1px 0 #1b5e20; }
.nav-row { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* Pick screen */
.row-label { font-size: 20px; font-weight: bold; }
.row-label span { font-size: 15px; font-weight: normal; opacity: .85; margin-left: 6px; }
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.card {
  width: clamp(92px, 16vw, 140px); padding: 6px 4px 8px; border-radius: 16px;
  background: rgba(255,255,255,.14); border: 3px solid transparent;
  font-size: 14px; font-weight: bold; transition: transform .1s;
}
.card canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; display: block; }
.card.selected { border-color: #ffd54f; background: rgba(255,213,79,.32); transform: scale(1.06); }
.pick-info { font-size: 20px; min-height: 28px; color: #fff59d; padding: 0 10px; }

/* Name screen */
.name-row { display: flex; gap: 10px; align-items: center; }
#name-input {
  font-size: 26px; font-family: inherit; padding: 10px 16px; border-radius: 16px;
  border: 3px solid #ffd54f; width: min(66vw, 340px); text-align: center;
  -webkit-user-select: text; user-select: text; color: #222;
}
.diet-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.diet {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 22px; min-width: 160px; border-radius: 20px;
  background: rgba(255,255,255,.14); border: 3px solid transparent;
}
.diet .ic { font-size: 34px; }
.diet b { font-size: 20px; }
.diet small { font-size: 15px; opacity: .9; }
.diet.selected { border-color: #ffd54f; background: rgba(255,213,79,.32); }

/* End + how to */
.end-text { font-size: 22px; line-height: 1.5; }
.howto ul { text-align: left; font-size: 18px; line-height: 1.45; max-width: 640px; padding-left: 10px; list-style: none; margin: 0; }
.howto li { margin: 4px 0; }
.howto .keys { font-size: 14px; opacity: .7; }

/* ---------- In-game controls ---------- */
#controls { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#joy-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 72%; pointer-events: auto; touch-action: none; }
#joy-hint {
  position: absolute; left: calc(24px + env(safe-area-inset-left)); bottom: calc(40px + env(safe-area-inset-bottom));
  font-size: 18px; font-weight: bold; padding: 8px 14px; border-radius: 20px;
  background: rgba(0,0,0,.35); animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
#joy-base {
  position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: 3px solid rgba(255,255,255,.4); display: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px;
  border-radius: 50%; background: rgba(255,255,255,.6); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#action-pad {
  --b: clamp(54px, 11.5vmin, 92px);
  position: absolute; right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
  width: calc(var(--b) * 3.75); height: calc(var(--b) * 3.75); pointer-events: none;
}
.act {
  --s: 1;
  position: absolute; pointer-events: auto; touch-action: none;
  width: calc(var(--b) * var(--s)); height: calc(var(--b) * var(--s)); border-radius: 50%;
  background: rgba(0,0,0,.38); border: 3px solid rgba(255,255,255,.65);
  font-size: calc(var(--b) * 0.2); font-weight: bold; line-height: 1.05; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .15s;
}
.act .ic { font-size: calc(var(--b) * var(--s) * 0.36); line-height: 1.1; }
.act.on { background: rgba(255,193,7,.6); transform: scale(.93); }
.act.cool { opacity: .45; }
.act[data-act="breath"] { --s: 1.45; right: 0; bottom: 0; background: rgba(230,81,0,.45); }
.act[data-act="bite"]   { right: calc(var(--b) * 1.6);  bottom: 0; }
.act[data-act="claw"]   { right: calc(var(--b) * 1.5);  bottom: calc(var(--b) * 1.1); }
.act[data-act="tail"]   { right: calc(var(--b) * 0.3);  bottom: calc(var(--b) * 1.6); }
.act[data-act="throw"]  { right: calc(var(--b) * 2.7);  bottom: calc(var(--b) * 0.5); }
.act[data-act="roar"]   { right: calc(var(--b) * 1.45); bottom: calc(var(--b) * 2.25); }
.act[data-act="fly"]    { right: calc(var(--b) * 0.2);  bottom: calc(var(--b) * 2.75); background: rgba(3,155,229,.45); }
#btn-pause {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  width: 48px; height: 48px; border-radius: 50%; font-size: 22px; pointer-events: auto;
  background: rgba(0,0,0,.4); border: 2px solid rgba(255,255,255,.6);
}
#rotate-hint {
  position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 8;
  font-size: 20px; font-weight: bold; padding: 12px 18px; border-radius: 20px;
  background: rgba(0,0,0,.6); pointer-events: none;
}
