:root {
  --ink: #2b1a2f;
  --pink: #ff7eb9;
  --pink-d: #d9468f;
  --gold: #ffd23a;
  --paper: #fff4e2;
  --font: "Lilita One", "Arial Rounded MT Bold", sans-serif;
  --outline: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink),
    2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink);
}

html, body {
  margin: 0; height: 100%; overflow: hidden; background: #6fb8e8;
  font-family: var(--font); color: #fff;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#view, #view canvas { position: fixed; inset: 0; display: block; }
.hidden { display: none !important; }
h1, h2, b, button, #toast, .story, .best, #over-stats, #over-place { text-shadow: var(--outline); letter-spacing: 0.02em; }
button { font-family: var(--font); color: #fff; cursor: pointer; border: none; touch-action: manipulation; }
.row { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

.ico { display: inline-block; width: 30px; height: 30px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px var(--ink); vertical-align: middle; }
.ico.sm { width: 20px; height: 20px; box-shadow: 0 0 0 2px var(--ink); }
.ico.coin { background: radial-gradient(circle at 35% 30%, #fff6b0, #f2b21c 60%, #c9860e); }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: max(8px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  display: flex; align-items: center; gap: 14px; pointer-events: none;
}
.hearts { display: flex; gap: 4px; font-size: 34px; }
.hearts span { color: var(--pink); text-shadow: var(--outline); transition: transform 0.2s; }
.hearts span.lost { color: rgba(43, 26, 47, 0.45); transform: scale(0.8); }
.hearts span.shield { color: #ffd23a; }
.mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dist { font-size: 40px; line-height: 1; }
.dist small { font-size: 20px; margin-left: 3px; text-shadow: var(--outline); }
.route { width: min(420px, 60%); height: 12px; border-radius: 8px; background: rgba(43, 26, 47, 0.55); position: relative; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6); }
#route-fill { height: 100%; width: 0; border-radius: 8px; background: linear-gradient(90deg, #6fd0ff, var(--pink)); }
#route-dot { position: absolute; top: -7px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd0e6, var(--pink) 55%, var(--pink-d)); box-shadow: 0 0 0 3px var(--ink); left: 0; }
.pill { display: flex; align-items: center; gap: 8px; background: rgba(43, 26, 47, 0.72); border-radius: 999px; padding: 4px 16px 4px 4px; font-size: 24px; }
.round {
  pointer-events: auto; width: 50px; height: 50px; border-radius: 16px; font-size: 22px;
  background: #e8473c; box-shadow: 0 5px 0 #9e2a22, 0 5px 0 3px var(--ink), 0 0 0 3px var(--ink);
}
#powers { position: fixed; left: max(12px, env(safe-area-inset-left)); top: 70px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.power { display: flex; align-items: center; gap: 8px; background: rgba(43, 26, 47, 0.72); border-radius: 999px; padding: 4px 14px 4px 6px; font-size: 18px; }
.power .bar { width: 70px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.power .bar i { display: block; height: 100%; background: var(--gold); }

#zone {
  position: fixed; left: 0; right: 0; top: 18%; text-align: center; pointer-events: none;
  animation: zone 3s ease-out forwards;
}
#zone small { display: block; font-size: 20px; text-shadow: var(--outline); opacity: 0.9; }
#zone b { font-size: 56px; color: var(--gold); }
@keyframes zone {
  0% { opacity: 0; transform: translateY(-30px) scale(0.8); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

#shout {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  max-width: min(340px, 45vw); background: #fff; color: var(--ink); border-radius: 20px 20px 4px 20px;
  padding: 8px 16px 10px; box-shadow: 0 0 0 4px var(--ink), 0 8px 18px rgba(0, 0, 0, 0.25);
  animation: shout 2.6s ease-out forwards; pointer-events: none;
}
#shout-who { font-size: 14px; color: var(--pink-d); }
#shout p { margin: 0; font-size: 22px; line-height: 1.15; }
@keyframes shout { 0% { transform: scale(0.3); opacity: 0; } 10% { transform: scale(1.06); opacity: 1; } 16% { transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

#steer-hint { position: fixed; left: 0; right: 0; bottom: 18%; text-align: center; font-size: 30px; text-shadow: var(--outline); pointer-events: none; animation: hint 1.4s ease-in-out infinite; }
@keyframes hint { 50% { transform: translateX(12px); } }

#tap { position: fixed; left: 0; right: 0; bottom: 14%; text-align: center; pointer-events: none; }
#tap b { display: block; font-size: 64px; color: #fff; animation: tapbob 0.5s ease-in-out infinite; }
#tap small { font-size: 20px; text-shadow: var(--outline); }
#tap.pulse b { animation: tappop 0.18s ease-out; color: var(--gold); }
@keyframes tapbob { 50% { transform: scale(1.08); } }
@keyframes tappop { from { transform: scale(1.35); } to { transform: scale(1); } }

#toast { position: fixed; left: 0; right: 0; top: 40%; text-align: center; font-size: 40px; color: var(--gold); pointer-events: none; opacity: 0; }
#toast.show { animation: toast 1.5s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: scale(0.3); } 15% { opacity: 1; transform: scale(1.12); } 25% { transform: scale(1); }
  75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); }
}

/* ---------- ruudut ---------- */
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(ellipse at center, rgba(43, 26, 47, 0.25), rgba(43, 26, 47, 0.7)); text-align: center;
}
#menu { background: linear-gradient(rgba(43, 26, 47, 0.05), rgba(43, 26, 47, 0.55)); }
#loading { background: linear-gradient(#5fb4f2, #bfe6ff); }
h1 {
  margin: 0; font-size: min(17vw, 120px); line-height: 0.9; color: var(--pink); transform: rotate(-3deg);
  text-shadow: 0 8px 0 var(--ink), 5px 0 0 var(--ink), -5px 0 0 var(--ink), 0 -5px 0 var(--ink),
    4px 4px 0 var(--ink), -4px 4px 0 var(--ink), 4px -4px 0 var(--ink), -4px -4px 0 var(--ink);
}
h2 { margin: 0; font-size: 34px; font-weight: normal; }
.title h2 { color: #bfe8ff; font-size: 44px; transform: rotate(-3deg); margin-top: -4px; }
.story { max-width: 640px; font-size: 19px; line-height: 1.35; margin: 4px 16px; }
.best { font-size: 20px; }
#regions { display: flex; gap: 6px; background: rgba(43, 26, 47, 0.55); padding: 4px; border-radius: 999px; }
#regions button { font-size: 18px; padding: 5px 18px; border-radius: 999px; background: transparent; }
#regions button.on { background: var(--gold); color: var(--ink); text-shadow: none; }
#track-cards { flex: none; display: flex; gap: 10px; overflow-x: auto; max-width: calc(100% - 24px); padding: 6px 6px 8px; scrollbar-width: thin; }
#track-cards::before, #track-cards::after { content: ''; margin: auto; }
.track.locked { filter: saturate(0.4); opacity: 0.85; }
.track.locked .tb { color: #fff; }
.track {
  flex: none; width: 128px; padding: 6px 4px 8px; border-radius: 16px; background: rgba(43, 26, 47, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5); display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.track .ti { font-size: 30px; text-shadow: none; line-height: 1.1; }
.track b { font-size: 20px; }
.track small { font-size: 13px; opacity: 0.85; text-shadow: var(--outline); }
.track .tb { font-size: 13px; color: var(--gold); text-shadow: var(--outline); }
.track.on { background: var(--pink); box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(0, 0, 0, 0.3); transform: translateY(-3px); }
#season { display: flex; gap: 6px; background: rgba(43, 26, 47, 0.55); padding: 4px; border-radius: 999px; }
#season button { font-size: 18px; padding: 6px 18px; border-radius: 999px; background: transparent; }
#season button.on { background: #fff; color: var(--ink); text-shadow: none; }
.big {
  font-size: 30px; padding: 12px 40px 16px; border-radius: 22px; background: linear-gradient(#6fdc6f, #3fae4a);
  box-shadow: 0 7px 0 #2a7a33, 0 7px 0 4px var(--ink), 0 0 0 4px var(--ink), 0 14px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s;
}
.big:active { transform: translateY(5px); }
.big.alt { background: linear-gradient(#9d8cff, #6b5ad9); box-shadow: 0 7px 0 #463a9e, 0 7px 0 4px var(--ink), 0 0 0 4px var(--ink), 0 14px 20px rgba(0, 0, 0, 0.3); }
.big:disabled { filter: grayscale(1); opacity: 0.6; }
#btn-play { font-size: 40px; padding: 14px 60px 18px; }
.loadbar { width: min(360px, 70vw); height: 20px; border-radius: 12px; background: rgba(43, 26, 47, 0.5); box-shadow: 0 0 0 4px var(--ink); overflow: hidden; }
#loadfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), #ffb0d6); transition: width 0.2s; }
.credit { font-family: system-ui, sans-serif; font-size: 12px; opacity: 0.8; margin: 0; color: var(--ink); }

.over-dist { font-size: 80px; line-height: 1; }
.over-dist b { color: var(--gold); }
#over-place { font-size: 26px; }
#over-stats { font-size: 20px; line-height: 1.5; }

#skin-cards { display: flex; gap: 12px; overflow-x: auto; max-width: calc(100% - 24px); padding: 8px 6px 12px; }
.skin {
  flex: none; width: 150px; background: var(--paper); color: var(--ink); border-radius: 18px; padding: 8px;
  box-shadow: 0 0 0 4px var(--ink), 0 6px 0 4px var(--ink); position: relative;
}
.skin img { width: 130px; height: 110px; object-fit: contain; display: block; margin: 0 auto; }
.skin .nm { font-size: 18px; min-height: 42px; display: flex; align-items: center; justify-content: center; line-height: 1.05; }
.skin .ds { font-family: system-ui, sans-serif; font-size: 12px; min-height: 30px; opacity: 0.75; }
.skin button { width: 100%; font-size: 18px; padding: 6px 0 9px; margin-top: 6px; }
.skin.on { box-shadow: 0 0 0 4px var(--gold), 0 0 0 8px var(--ink), 0 6px 0 8px var(--ink); }
.skin.locked img { filter: brightness(0) opacity(0.35); }

#rotate { display: none; position: fixed; inset: 0; z-index: 10; background: var(--pink); color: var(--ink); font-size: 28px; flex-direction: column; align-items: center; justify-content: center; }
#rotate .phone { width: 60px; height: 100px; border: 6px solid var(--ink); border-radius: 12px; animation: turn 1.6s ease-in-out infinite; }
@keyframes turn { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: flex; } }

@media (max-height: 460px) {
  .hearts { font-size: 26px; }
  .dist { font-size: 30px; }
  #zone b { font-size: 40px; }
  .big { font-size: 22px; padding: 8px 26px 12px; }
  #btn-play { font-size: 30px; padding: 10px 40px 14px; }
  h1 { font-size: 70px; }
  .title h2 { font-size: 30px; }
  .story { font-size: 13px; margin: 0 16px; }
  .track { width: 104px; padding: 3px 2px 5px; }
  .track .ti { font-size: 22px; }
  #regions button { font-size: 14px; padding: 3px 12px; }
  .track b { font-size: 16px; }
  .title h1 { font-size: 54px; }
  .title h2 { font-size: 24px; }
  #menu { gap: 6px; }
  .over-dist { font-size: 56px; }
  .skin { width: 124px; }
  .skin img { width: 100px; height: 80px; }
  #shout p { font-size: 17px; }
}

/* tehtävät, juhlat, päivän joki, hahmovälilehdet, faktat */
#missions { width: min(460px, 90vw); display: flex; flex-direction: column; gap: 8px; text-align: left; }
#missions h3 { margin: 0; font-size: 18px; font-weight: normal; }
.mission { background: rgba(43, 26, 47, 0.62); border-radius: 14px; padding: 8px 14px 10px; font-size: 16px; line-height: 1.25; }
.mission .bar { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); margin-top: 4px; overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: var(--gold); }
.mission .rw { color: var(--gold); font-weight: bold; }
.mission.done { box-shadow: 0 0 0 2px var(--gold); }
#fest { position: absolute; top: 10px; left: 10px; max-width: 230px; text-align: left; background: rgba(43, 26, 47, 0.7); border-radius: 14px; padding: 6px 12px; font-size: 13px; line-height: 1.3; transform: rotate(-2deg); }
.track .daily { position: absolute; top: -8px; right: -6px; background: var(--gold); color: var(--ink); text-shadow: none; font-size: 11px; padding: 2px 6px; border-radius: 8px; transform: rotate(6deg); }
.track { position: relative; }
#skin-tabs { display: flex; gap: 6px; background: rgba(43, 26, 47, 0.55); padding: 4px; border-radius: 999px; }
#skin-tabs button { font-size: 18px; padding: 5px 18px; border-radius: 999px; background: transparent; }
#skin-tabs button.on { background: var(--gold); color: var(--ink); text-shadow: none; }
#over-fact { max-width: 560px; margin: 0 16px; font-size: 16px; line-height: 1.35; background: rgba(43, 26, 47, 0.55); border-radius: 14px; padding: 8px 14px; }
#over-fact:empty { display: none; }
.gold { color: var(--gold); }
#lakki-pill { display: none; }
#lakki-pill.has { display: flex; }
@media (max-height: 460px) { #missions { gap: 4px; } .mission { padding: 4px 10px 6px; font-size: 13px; } #fest { font-size: 11px; max-width: 170px; } #over-fact { font-size: 13px; } }
.track .stars { font-size: 11px; color: var(--gold); letter-spacing: 1px; line-height: 1; text-shadow: var(--outline); }
