@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: swap; src: url(../fonts/fredoka-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url(../fonts/fredoka-latin-700-normal.woff2) format('woff2'); }

:root {
  --green: #3fbf5a; --green-d: #23843a; --orange: #ff9a2e; --red: #ff4d5e;
  --cream: #fff7e3; --ink: #2b2140; --shadow: rgba(30, 20, 50, .35);
  --safe-t: env(safe-area-inset-top, 0px); --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; touch-action: none;
  font-family: 'Fredoka', system-ui, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button, a.mid, a.pill { font-family: inherit; cursor: pointer; border: 0; text-decoration: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hearts { position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); display: grid;
  grid-template-columns: repeat(5, auto); justify-content: start; gap: 3px; filter: drop-shadow(0 3px 2px var(--shadow)); }
#hearts svg { width: clamp(30px, 8vmin, 46px); height: auto; transition: transform .2s; }
#hearts svg.empty path { fill: rgba(255,255,255,.35); stroke: rgba(80,20,40,.5); }
#hearts svg.pop { animation: pop .45s ease-out; }
#hearts svg.lost { animation: lost .6s ease-out; }
@keyframes pop { 0% { transform: scale(.2); } 60% { transform: scale(1.45); } 100% { transform: scale(1); } }
@keyframes lost { 0% { transform: scale(1.5) rotate(-15deg); } 100% { transform: scale(1); } }
#score { position: absolute; top: calc(12px + var(--safe-t)); right: calc(70px + var(--safe-r)); font-weight: 700;
  font-size: clamp(26px, 7vmin, 40px); color: #fff; text-shadow: 0 3px 0 rgba(40,20,60,.45), 0 0 10px rgba(0,0,0,.25); }
#score small { font-size: .55em; }
.iconbtn { position: absolute; top: calc(8px + var(--safe-t)); right: calc(10px + var(--safe-r)); width: 52px; height: 52px;
  border-radius: 16px; background: rgba(255,255,255,.88); box-shadow: 0 4px 0 rgba(40,20,60,.3); pointer-events: auto; display: grid; place-items: center; }
.iconbtn svg { width: 28px; height: 28px; fill: var(--ink); }
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(40,20,60,.3); }

#hint { position: fixed; left: 50%; top: 24%; transform: translateX(-50%); background: rgba(255,255,255,.93); color: var(--ink);
  padding: 12px 20px; border-radius: 22px; font-weight: 700; font-size: clamp(20px, 5.4vmin, 30px); text-align: center;
  box-shadow: 0 6px 0 rgba(40,20,60,.25); pointer-events: none; max-width: 90vw; animation: hintIn .35s ease-out; }
#hint img { height: 1.6em; vertical-align: middle; margin: 0 4px; }
@keyframes hintIn { from { transform: translate(-50%, -20px) scale(.8); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

#countdown { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; font-weight: 700;
  font-size: clamp(90px, 30vmin, 200px); color: #fff; text-shadow: 0 8px 0 rgba(40,20,60,.4); }
#countdown.go { color: #ffe14d; }
#countdown span { animation: cd .9s ease-out both; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }

#flash { position: fixed; inset: 0; background: #ff3050; opacity: 0; pointer-events: none; transition: opacity .35s; }
#flash.on { opacity: .35; transition: none; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); text-align: center; }
.screen.show { display: flex; }
.logo { font-weight: 700; font-size: clamp(46px, 13vmin, 96px); letter-spacing: 1px; color: #ffe14d; line-height: 1;
  -webkit-text-stroke: 3px #3a1f4f; paint-order: stroke fill; text-shadow: 0 7px 0 #3a1f4f, 0 12px 18px rgba(0,0,0,.25);
  transform: rotate(-3deg); }
.logo span { color: #ff6b3d; }
.sub { font-weight: 700; font-size: clamp(20px, 5vmin, 30px); color: #fff; text-shadow: 0 3px 0 rgba(40,20,60,.45); }

#loading { background: radial-gradient(circle at 50% 30%, #9ee6a8, #2f9b5a 70%, #1f6f4a); }
#loading .bar { width: min(70vw, 360px); height: 22px; border-radius: 12px; background: rgba(0,0,0,.25); overflow: hidden; border: 3px solid #3a1f4f; }
#loadBar { height: 100%; width: 0; background: linear-gradient(#ffe97a, #ffb72e); transition: width .2s; }
#loadText { color: #fff; font-weight: 500; font-size: 18px; }

#title { background: linear-gradient(to bottom, rgba(20,60,40,0) 40%, rgba(20,40,30,.45)); }
#title .menu { height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#title .logo { margin-top: 2vh; }
#title .spacer { flex: 1; }
@media (orientation: landscape) {
  #title { align-items: flex-end; background: linear-gradient(to right, rgba(20,40,30,0) 35%, rgba(20,40,30,.35)); }
  #title .menu { width: min(60vw, 680px); justify-content: center; gap: 10px; }
  #title .spacer { display: none; }
}
#dinoCards { display: flex; gap: clamp(8px, 2.5vw, 22px); justify-content: center; flex-wrap: nowrap; }
.card { width: clamp(96px, 27vw, 170px); padding: 10px 6px 8px; border-radius: 22px; background: rgba(255,255,255,.88);
  box-shadow: 0 6px 0 rgba(40,20,60,.3); border: 4px solid transparent; transition: transform .15s; }
.card img { width: 100%; aspect-ratio: 1; display: block; }
.card b { display: block; font-size: clamp(15px, 4vw, 22px); margin-top: 2px; }
.card.sel { border-color: var(--c, #3fbf5a); transform: translateY(-8px) scale(1.06); background: #fff; }
.card:active { transform: scale(.96); }

button.big { font-weight: 700; font-size: clamp(30px, 8vmin, 46px); color: #fff; padding: 12px 54px; border-radius: 26px;
  background: linear-gradient(#5fd96f, #2fa346); box-shadow: 0 7px 0 #1d6b2d, 0 10px 18px rgba(0,0,0,.25);
  text-shadow: 0 3px 0 rgba(0,0,0,.25); }
button.big:active { transform: translateY(5px); box-shadow: 0 2px 0 #1d6b2d; }
.mid { display: inline-block; font-weight: 700; font-size: clamp(20px, 5vmin, 26px); color: var(--ink); padding: 10px 28px;
  border-radius: 20px; background: #fff; box-shadow: 0 5px 0 rgba(40,20,60,.3); min-width: 230px; }
.mid:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(40,20,60,.3); }
.pill { font-weight: 700; font-size: 17px; color: var(--ink); padding: 8px 16px; border-radius: 16px; background: rgba(255,255,255,.9);
  box-shadow: 0 4px 0 rgba(40,20,60,.3); }
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(40,20,60,.3); }
.pill.off { opacity: .55; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#best { color: #fff; font-weight: 700; font-size: 20px; text-shadow: 0 2px 0 rgba(40,20,60,.5); min-height: 24px; }

#pause, #over { background: rgba(30, 20, 50, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { background: var(--cream); border-radius: 30px; padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 12px;
  align-items: center; box-shadow: 0 10px 0 rgba(40,20,60,.35); border: 4px solid #3a1f4f; max-width: 92vw; }
.panel h2 { margin: 0; font-size: clamp(34px, 9vmin, 50px); color: #ff6b3d; -webkit-text-stroke: 2px #3a1f4f; paint-order: stroke fill; }
#overDino img { width: 120px; height: 120px; }
.dist { font-size: 44px; font-weight: 700; }
#overRecord { font-weight: 700; font-size: 20px; color: #2f9b5a; min-height: 26px; }
#overRecord.new { color: #ff6b3d; animation: pop .6s ease-out; font-size: 26px; }

@media (orientation: landscape) and (max-height: 520px) {
  .screen { gap: 8px; }
  .logo { font-size: 13vh; }
  .card { width: 19vh; padding: 6px; } .card b { font-size: 16px; }
  button.big { font-size: 28px; padding: 8px 40px; }
  .mid { font-size: 19px; padding: 7px 20px; min-width: 200px; }
  .panel { gap: 7px; padding: 12px 18px; } .panel h2 { font-size: 30px; }
  #overDino img { width: 70px; height: 70px; } .dist { font-size: 32px; }
}

/* ---------- Tablet (z.B. Galaxy Tab 10 Zoll) ---------- */
@media (min-width: 700px) and (min-height: 700px) {
  #hearts svg { width: 54px; }
  #hearts { gap: 5px; top: calc(16px + var(--safe-t)); left: calc(16px + var(--safe-l)); }
  #score { font-size: 50px; top: calc(16px + var(--safe-t)); right: calc(100px + var(--safe-r)); }
  .iconbtn { width: 70px; height: 70px; border-radius: 20px; top: calc(14px + var(--safe-t)); right: calc(16px + var(--safe-r)); }
  .iconbtn svg { width: 38px; height: 38px; }
  #hint { font-size: 36px; padding: 16px 28px; border-radius: 28px; }
  .logo { font-size: 110px; }
  .sub { font-size: 36px; }
  .card { width: 200px; border-radius: 28px; } .card b { font-size: 26px; }
  #dinoCards { gap: 26px; }
  button.big { font-size: 56px; padding: 16px 80px; border-radius: 32px; }
  .mid { font-size: 30px; min-width: 320px; padding: 14px 32px; }
  .pill { font-size: 22px; padding: 12px 22px; }
  #best { font-size: 26px; }
  .panel { padding: 30px 40px 34px; gap: 18px; } .panel h2 { font-size: 64px; }
  #overDino img { width: 170px; height: 170px; } .dist { font-size: 64px; } #overRecord { font-size: 26px; }
  #countdown { font-size: 240px; }
}
