* { box-sizing: border-box; }
:root {
  --ink: #1b1036; --ink2: #4a3a6a; --paper: #fff8ec; --red: #ff595e; --yellow: #ffca3a; --green: #8ac926;
  --blue: #1982c4; --purple: #6a4c93; --font: "Baloo 2", "Nunito", system-ui, "Noto Sans", sans-serif;
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #140b2a; color: var(--ink); font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; display: block; touch-action: none; }
button, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ------------------------------------------------ HUD: chunky toy pills */
#hud { position: absolute; left: 10px; right: 10px; top: 8px; height: 56px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.pill {
  pointer-events: auto; display: flex; align-items: center; gap: 6px; height: 48px; padding: 0 14px 0 8px; border-radius: 24px;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 5px 0 rgba(27,16,54,.55), inset 0 -4px 0 rgba(0,0,0,.08);
  font-weight: 800; white-space: nowrap;
}
.pill b { font-size: 26px; line-height: 1; }
.pill small { font-size: 14px; color: var(--ink2); font-weight: 700; }
.pill.money { min-width: 170px; }
.pill.bump { animation: bump .25s ease; }
.pill.skulls b { color: var(--purple); }
.pill.rating { gap: 4px; }
.pill.rating #stars { font-size: 20px; letter-spacing: -2px; color: #ffb400; text-shadow: 0 1px 0 #b97a00; }
.pill.rating #stars .off { color: #d9d0e8; text-shadow: none; }
.pill.rating b { font-size: 18px; color: var(--ink2); margin-left: 4px; }
.pill.moon { font-size: 17px; padding: 0 14px; background: #2b1846; color: #ffe9a8; margin-left: auto; margin-right: auto; }
.pill.moon.active { background: linear-gradient(#ff595e, #b3262b); color: #fff; animation: throb .8s ease-in-out infinite; }
.pill.moon:empty { visibility: hidden; }
@keyframes bump { 50% { transform: scale(1.12); } }
@keyframes throb { 50% { transform: scale(1.06); } }
.coin { display: inline-block; width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #fff3b0 0 18%, #ffca3a 20% 60%, #e09a00 62%); border: 2.5px solid #b97a00; }
.coin.big { width: 54px; height: 54px; }
.hud-btns { display: flex; gap: 8px; pointer-events: auto; }
.hbtn {
  position: relative; width: 54px; height: 50px; border-radius: 16px; cursor: pointer; font-size: 26px; padding: 0;
  background: linear-gradient(#fff, #efe4ff); border: 3px solid var(--ink); box-shadow: 0 5px 0 rgba(27,16,54,.55);
  transition: transform .1s;
}
.hbtn:hover { transform: translateY(-2px) scale(1.05); }
.hbtn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(27,16,54,.55); }
.hbtn.glow { animation: throb 1s ease-in-out infinite; background: linear-gradient(#e8ffc8, #b8ea70); }
.badge { position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: var(--red); color: #fff; font-size: 15px; line-height: 20px; border: 2px solid #fff; font-weight: 800; }

/* ------------------------------------------------ tutorial + toast */
#tut {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%); z-index: 12; display: flex; align-items: center; gap: 12px;
  max-width: 760px; padding: 8px 10px 8px 18px; border-radius: 18px; background: var(--yellow); border: 3px solid var(--ink);
  box-shadow: 0 5px 0 rgba(27,16,54,.55); font-size: 20px; font-weight: 800; animation: pop .3s ease both;
}
#tut-skip { cursor: pointer; border: 0; background: rgba(27,16,54,.12); border-radius: 10px; padding: 2px 10px; font-size: 14px; font-weight: 800; }
.toast {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 30; pointer-events: none; max-width: 900px;
  background: var(--paper); border: 3px solid var(--ink); font-weight: 800; font-size: 20px; text-align: center;
  padding: 8px 22px; border-radius: 16px; box-shadow: 0 5px 0 rgba(27,16,54,.5); animation: pop .3s ease both;
}

/* ------------------------------------------------ overlays */
.overlay {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(27,16,54,.45), rgba(12,6,26,.8)); animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: scale(.85); opacity: 0 } }
#tut, .toast { animation-name: popc; }
@keyframes popc { from { transform: translateX(-50%) scale(.85); opacity: 0 } }
.loader { text-align: center; font-size: 22px; color: #fff; }
.spin { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; border: 7px solid rgba(255,255,255,.25); border-top-color: var(--yellow); animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }

.modal {
  background: var(--paper); border: 4px solid var(--ink); border-radius: 26px; padding: 18px 28px; min-width: 460px; max-width: 1060px; max-height: 690px;
  text-align: center; box-shadow: 0 10px 0 rgba(27,16,54,.6), 0 30px 60px rgba(0,0,0,.5); animation: pop .25s cubic-bezier(.3,1.6,.5,1) both; overflow-y: auto;
}
.modal.wide { width: 1000px; }
.modal h2 { margin: 0 0 4px; font-size: 36px; line-height: 1.1; }
.modal .sub { margin: 0 0 10px; color: var(--ink2); font-size: 17px; line-height: 1.3; }
.modal .gain { font-size: 22px; font-weight: 800; color: var(--purple); margin: 6px 0; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; min-width: 0; padding-left: 10px; padding-right: 10px; hyphens: auto; overflow-wrap: anywhere; } /* long German/Russian labels wrap instead of spilling */
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.keys { font-size: 14px !important; margin-top: 12px !important; }

.btn {
  cursor: pointer; font-weight: 800; font-size: 20px; color: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 7px 20px 9px;
  box-shadow: 0 5px 0 rgba(27,16,54,.6), inset 0 -4px 0 rgba(0,0,0,.15), inset 0 3px 0 rgba(255,255,255,.35);
  text-shadow: 0 2px 0 rgba(0,0,0,.25); transition: transform .1s, filter .1s; line-height: 1.15;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(27,16,54,.6); }
.btn:disabled { filter: grayscale(.8) brightness(.9); cursor: not-allowed; transform: none; }
.btn.green { background: linear-gradient(#a6e04a, #6aa81c); }
.btn.blue { background: linear-gradient(#4cb0ea, #1570a8); }
.btn.purple { background: linear-gradient(#9a78cc, #5a3c83); }
.btn.dark { background: linear-gradient(#6a5a8a, #43365e); }
.btn.red { background: linear-gradient(#ff7a7e, #d9383d); }
.btn.big { font-size: 32px; padding: 10px 46px 13px; }
.btn.small { font-size: 16px; padding: 4px 14px 6px; }
.btn.off { opacity: .55; text-decoration: line-through; }
textarea { width: 100%; height: 70px; font: 13px/1.3 monospace; border: 2px solid var(--ink2); border-radius: 10px; background: #fff; resize: none; user-select: text; -webkit-user-select: text; }
.langrow { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 800; font-size: 19px; }
select { font-size: 18px; font-weight: 700; padding: 4px 10px; border-radius: 12px; border: 3px solid var(--ink); background: #fff; cursor: pointer; }

/* title */
.overlay.title { background: radial-gradient(ellipse at center, rgba(27,16,54,.25), rgba(12,6,26,.7)); }
.title-card { text-align: center; animation: pop .45s cubic-bezier(.3,1.6,.5,1) both; }
.logo { display: flex; flex-direction: column; line-height: .82; filter: drop-shadow(0 8px 0 rgba(27,16,54,.8)); }
.logo .l1 { font-size: 84px; font-weight: 800; color: var(--yellow); -webkit-text-stroke: 4px var(--ink); letter-spacing: 6px; }
.logo .l2 { font-size: 132px; font-weight: 800; color: #b8ea70; -webkit-text-stroke: 5px var(--ink); letter-spacing: 10px; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-2deg) scale(1.02); } 75% { transform: rotate(2deg); } }
.tagline { font-size: 24px; color: #fff; font-weight: 800; margin: 16px auto 8px; text-shadow: 0 3px 0 var(--ink); max-width: 700px; }
.title-cast { display: flex; justify-content: center; gap: 4px; height: 110px; margin: 4px 0 14px; }
.title-cast img { height: 100px; animation: hop 1.2s ease-in-out infinite; filter: drop-shadow(0 6px 0 rgba(0,0,0,.35)); }
@keyframes hop { 50% { transform: translateY(-12px) scaleY(1.04); } }
.hint { font-size: 16px; color: #e6dcff; margin: 12px 0 0; font-weight: 700; }
.title-lang { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 20px; }
.title-lang select { font-size: 15px; padding: 2px 8px; }
.big-reward { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0; }
.big-reward b { font-size: 56px; color: #b97a00; -webkit-text-stroke: 1.5px var(--ink); }

/* upgrade cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; text-align: left; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; border-radius: 16px; background: #fff; border: 3px solid rgba(27,16,54,.25); min-height: 150px; }
.card.can { border-color: var(--green); box-shadow: 0 0 0 3px rgba(138,201,38,.35); }
.card .top { display: flex; gap: 8px; align-items: center; }
.card .ic { font-size: 32px; line-height: 1; }
.card .nm { font-weight: 800; font-size: 17px; line-height: 1.1; }
.card .lv { font-size: 14px; color: var(--ink2); font-weight: 800; }
.card .ds { font-size: 14px; color: var(--ink2); line-height: 1.2; flex: 1; }
.card .pips { display: flex; gap: 2px; flex-wrap: wrap; }
.card .pips i { width: 8px; height: 8px; border-radius: 3px; background: #e5dcf3; }
.card .pips i.on { background: var(--purple); }
.card .btn { font-size: 17px; padding: 3px 8px 5px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.card .btn .coin { width: 18px; height: 18px; border-width: 2px; }

/* quests + guestbook */
.list { display: grid; gap: 8px; text-align: left; }
.quest { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 14px; background: #fff; border: 3px solid rgba(27,16,54,.2); }
.quest .qi { font-size: 30px; text-align: center; }
.quest .qn { font-weight: 800; font-size: 18px; line-height: 1.15; }
.quest .qr { font-size: 14px; color: var(--ink2); font-weight: 700; }
.quest .prog { height: 10px; border-radius: 5px; background: #e5dcf3; overflow: hidden; margin-top: 4px; }
.quest .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #b8ea70); }
.guests { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; text-align: left; }
.guest { display: flex; gap: 8px; padding: 8px; border-radius: 14px; background: #fff; border: 3px solid rgba(27,16,54,.2); min-height: 132px; }
.guest img, .guest .ph { width: 64px; height: 84px; object-fit: contain; flex: none; }
.guest .ph { display: grid; place-items: center; font-size: 40px; }
.guest.locked img { filter: brightness(0) opacity(.35); }
.guest .gn { font-weight: 800; font-size: 16px; line-height: 1.1; }
.guest .gc { font-size: 13px; color: var(--purple); font-weight: 800; }
.guest .gb { font-size: 12.5px; color: var(--ink2); line-height: 1.2; margin-top: 2px; }
.howto { text-align: left; font-size: 19px; line-height: 1.45; margin: 6px 0; padding-left: 28px; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 760px) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 12px; text-align: center; z-index: 50; background: var(--yellow); color: var(--ink); font-weight: 800; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .toast, #tut, .logo .l2, .title-cast img, .pill.moon.active, .hbtn.glow { animation: none !important; }
}
