* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1c1a18; color: #1c1c1c;
  font-family: 'Baloo 2', 'Nunito', system-ui, 'Noto Sans', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#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; touch-action: none; display: block; }
.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, rgba(40,34,28,.35), rgba(20,16,12,.72));
  animation: fade .22s ease; z-index: 10;
}
.overlay.clear { background: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0 } 70% { transform: scale(1.05); opacity: 1 } 100% { transform: scale(1) } }
@keyframes wiggle { 0%, 100% { transform: rotate(0) } 25% { transform: rotate(-3deg) } 75% { transform: rotate(3deg) } }
@keyframes bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 3px #1c1c1c, 0 0 18px 4px rgba(255,140,40,.6) } 50% { box-shadow: 0 0 0 3px #1c1c1c, 0 0 34px 12px rgba(255,160,60,.95) } }

.loader { text-align: center; font-size: 24px; color: #f4efe6; font-weight: 800; }
.spin { width: 60px; height: 60px; margin: 0 auto 10px; border-radius: 50%; border: 7px solid rgba(244,239,230,.2); border-top-color: #c0392b; animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }
.loader .bar { width: 260px; height: 10px; border-radius: 6px; background: rgba(244,239,230,.2); margin: 8px auto 0; overflow: hidden; }
.loader .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #1f4e9c, #c0392b); transition: width .2s; }

/* ---------------------------------------------------------------- ink buttons */
.btn {
  font: inherit; font-weight: 800; font-size: 21px; color: #f7f2e7; border: 0; cursor: pointer;
  padding: 9px 22px 11px; border-radius: 14px 18px 14px 20px; position: relative; line-height: 1.1;
  box-shadow: 0 0 0 3px #1c1c1c, 0 6px 0 3px rgba(28,28,28,.85);
  transition: transform .1s cubic-bezier(.3,1.6,.5,1), filter .15s;
  text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.08); }
.btn:active { transform: translateY(4px) scale(.97); box-shadow: 0 0 0 3px #1c1c1c, 0 2px 0 3px rgba(28,28,28,.85); }
.btn:disabled { filter: grayscale(.9) brightness(.85); cursor: not-allowed; transform: none; }
.btn.red { background: linear-gradient(#d65a45, #a82c1f); }
.btn.blue { background: linear-gradient(#3f71c4, #173d80); }
.btn.gold { background: linear-gradient(#e9b949, #b9801a); color: #2a1a05; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.btn.jade { background: linear-gradient(#8fb89a, #4f7c5c); }
.btn.ink { background: linear-gradient(#4a4540, #24211e); }
.btn.round { width: 54px; height: 54px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn.round-sm { width: 56px; flex: none !important; padding: 0; font-size: 22px; }
.btn.big { width: 100%; font-size: 28px; padding: 10px 16px 12px; display: flex; flex-direction: column; align-items: center; }
.btn.big small { font-size: 15px; font-weight: 700; opacity: .92; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { position: absolute; top: -10px; right: -8px; background: #c0392b; color: #fff; border-radius: 12px; min-width: 24px; height: 24px; font-size: 15px; display: grid; place-items: center; padding: 0 6px; box-shadow: 0 0 0 2px #1c1c1c; animation: bounce 1s infinite; }
.btn.toggle { min-width: 110px; font-size: 18px; padding: 6px 16px 8px; background: linear-gradient(#8fb89a, #4f7c5c); }
.btn.toggle.off { background: linear-gradient(#a8a29a, #6b6660); }

/* ---------------------------------------------------------------- menu */
#menu { align-items: flex-start; justify-content: center; padding-left: 44px; }
.menu-col {
  width: 480px; display: flex; flex-direction: column; gap: 12px; padding: 18px 26px 22px; border-radius: 26px 30px 24px 34px;
  background: rgba(247,242,231,.9); box-shadow: 0 0 0 3px #1c1c1c, 0 18px 40px rgba(20,16,12,.35); animation: pop .4s ease both;
}
.logo { display: flex; align-items: baseline; justify-content: center; gap: 12px; line-height: .9; margin-bottom: 0; }
.logo .l1, .logo .l2 { white-space: nowrap; flex: none; }
.logo .l1 { font-size: 70px; font-weight: 800; color: #1f4e9c; -webkit-text-stroke: 2px #1c1c1c; paint-order: stroke fill; text-shadow: 0 5px 0 #1c1c1c; animation: wiggle 3.2s ease-in-out infinite; display: inline-block; }
.logo .l2 { font-size: 70px; font-weight: 800; color: #c0392b; -webkit-text-stroke: 2px #1c1c1c; paint-order: stroke fill; text-shadow: 0 5px 0 #1c1c1c; display: inline-block; transform: rotate(-3deg); }
.tagline { margin: 0; text-align: center; font-size: 17px; font-weight: 700; color: #6b6b6b; }
.menu-btns { display: flex; flex-direction: column; gap: 14px; }
.menu-btns .row { display: flex; gap: 12px; }
.menu-btns .grow { flex: 1; min-width: 0; }
.small-new { width: 64px; font-size: 30px; padding: 0; }
.menu-row { display: flex; gap: 12px; }
.menu-row .btn { flex: 1; font-size: 17px; padding: 8px 8px 10px; min-width: 0; }
.menu-row.small { justify-content: center; margin-top: 12px; }
.menu-row.small .btn { flex: none; }
.icon-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet-row { position: absolute; top: 18px; right: 22px; display: flex; gap: 10px; }
.pill { background: rgba(247,242,231,.92); color: #1c1c1c; font-size: 24px; font-weight: 800; padding: 3px 18px; border-radius: 22px; box-shadow: 0 0 0 3px #1c1c1c; }
.pill b { color: #c0392b; }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#btn-pause { position: absolute; right: 18px; top: 16px; }
.blaze-btn {
  position: absolute; left: 834px; top: 484px; width: 150px; height: 64px; border: 0; border-radius: 18px; cursor: pointer; font: inherit; color: #fff;
  background: linear-gradient(#ff9a3c, #c0392b); display: flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 0 0 3px #1c1c1c; transition: transform .1s; animation: glow 1s ease-in-out infinite;
}
.blaze-btn .ic { font-size: 28px; }
.blaze-btn b { font-size: 19px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blaze-btn small { position: absolute; right: 8px; bottom: 3px; font-size: 12px; opacity: .8; }
.blaze-btn.off { background: linear-gradient(#6b6660, #3a3632); animation: none; opacity: .55; cursor: default; }
.blaze-btn:active { transform: scale(.94); }
#touch { position: absolute; inset: 0; pointer-events: none; }
.tbtn {
  position: absolute; width: 100px; height: 96px; border: 0; border-radius: 26px; pointer-events: auto; touch-action: none;
  background: rgba(247,242,231,.78); color: #1c1c1c; font-size: 44px; font-weight: 800; box-shadow: 0 0 0 3px rgba(28,28,28,.85);
}
.tbtn.drop { background: rgba(192,57,43,.85); color: #fff; }
.tbtn.big { background: rgba(31,78,156,.85); color: #fff; }
.tbtn.on { transform: scale(.92); filter: brightness(.85); }
.hint {
  position: absolute; left: 340px; width: 600px; top: 88px; text-align: center; color: #f7f2e7; font-weight: 800; font-size: 18px;
  background: rgba(28,28,28,.85); border-radius: 14px; padding: 5px 14px; animation: pop .3s ease both; pointer-events: none !important; z-index: 6;
}
.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); background: rgba(247,242,231,.97); color: #1c1c1c; font-weight: 800; font-size: 21px; padding: 7px 22px; border-radius: 18px; box-shadow: 0 0 0 3px #1c1c1c, 0 8px 20px rgba(0,0,0,.3); animation: pop .3s ease both; z-index: 20; max-width: 900px; text-align: center; pointer-events: none; }

/* ---------------------------------------------------------------- modals */
.modal {
  background: #f7f2e7; border-radius: 24px 30px 26px 22px; padding: 20px 32px 22px; min-width: 440px; max-width: 920px; text-align: center;
  box-shadow: 0 0 0 4px #1c1c1c, 0 24px 60px rgba(0,0,0,.5); animation: pop .35s ease both; max-height: 690px; overflow-y: auto;
  background-image: radial-gradient(ellipse at 90% 100%, rgba(31,78,156,.08), transparent 60%);
}
.modal.wide { width: 900px; }
.modal h2 { margin: 0 0 6px; font-size: 38px; line-height: 1.1; color: #1f4e9c; text-shadow: 0 3px 0 rgba(192,57,43,.25); }
.modal h3 { margin: 10px 0 6px; font-size: 21px; color: #c0392b; text-align: left; }
.modal .sub { margin: 0 0 10px; color: #6b6b6b; font-size: 17px; font-weight: 700; }
.modal .note { margin: -4px 0 8px; color: #8a5a2a; font-size: 15px; font-weight: 700; text-align: left; font-style: italic; }
.stack { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.actions { display: flex; gap: 14px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.goal { font-size: 26px; font-weight: 800; color: #1c1c1c; margin: 8px 0; }

.list { display: grid; gap: 10px; margin-top: 10px; text-align: left; }
.mission { display: grid; grid-template-columns: 50px 1fr auto; gap: 12px; align-items: center; background: #fff; border-radius: 16px; padding: 9px 14px; box-shadow: 0 0 0 2px #1c1c1c; }
.mission .ic { font-size: 30px; text-align: center; }
.mission .nm { font-size: 19px; font-weight: 800; }
.mission .pb { height: 10px; border-radius: 6px; background: #e8e0d0; overflow: hidden; margin-top: 4px; }
.mission .pb i { display: block; height: 100%; background: linear-gradient(90deg, #1f4e9c, #c0392b); border-radius: 6px; }
.mission .rw { font-size: 14px; color: #6b6b6b; font-weight: 700; }
.mission .btn { font-size: 16px; padding: 6px 14px 8px; min-width: 104px; }
.login-row { display: flex; gap: 8px; justify-content: center; margin: 6px 0 4px; flex-wrap: wrap; }
.login-row .day { width: 88px; border-radius: 12px; background: #e8e0d0; padding: 4px 0; font-weight: 800; font-size: 14px; color: #6b6b6b; }
.login-row .day b { display: block; font-size: 17px; color: #1f4e9c; }
.login-row .day.on { background: linear-gradient(#e9b949, #b9801a); color: #2a1a05; }
.login-row .day.today { outline: 3px solid #c0392b; }

.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.shop-grid.three { grid-template-columns: repeat(3, 1fr); }
.card { background: #fff; border-radius: 16px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 0 0 2px #1c1c1c; }
.card .pic { width: 170px; height: 40px; background-repeat: no-repeat; background-size: contain; background-position: center; }
.card .pic.vase { width: 80px; height: 66px; background-size: 400% 100%; }
.card .nm { font-weight: 800; font-size: 16px; line-height: 1.1; min-height: 30px; display: flex; align-items: center; }
.card .btn { font-size: 15px; padding: 5px 10px 7px; width: 100%; }
.card.owned { background: #eef6ef; }

.puzzle-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 10px; margin: 12px 0; }
.pnode {
  height: 64px; border: 0; border-radius: 14px; font: inherit; font-weight: 800; font-size: 22px; cursor: pointer; color: #f7f2e7;
  background: linear-gradient(#3f71c4, #173d80); box-shadow: 0 0 0 2px #1c1c1c, 0 4px 0 2px #1c1c1c; position: relative; transition: transform .1s;
}
.pnode:hover { transform: translateY(-2px) scale(1.05); }
.pnode .st { position: absolute; left: 0; right: 0; bottom: 2px; font-size: 11px; color: #ffd66b; letter-spacing: 1px; }
.pnode.done { background: linear-gradient(#8fb89a, #4f7c5c); }
.pnode.next { background: linear-gradient(#d65a45, #a82c1f); animation: bounce 1s ease-in-out infinite; }
.pnode.locked { background: linear-gradient(#b8b0a4, #857d72); cursor: not-allowed; font-size: 18px; }

.ranks-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; text-align: left; }
.rank-list { margin: 0; padding-left: 26px; font-size: 17px; font-weight: 700; min-height: 120px; }
.rank-list li { margin: 3px 0; }
.rank-list li b { color: #1f4e9c; }
.rank-list li small { color: #6b6b6b; margin-left: 6px; }
.rank-list .empty { list-style: none; margin-left: -20px; color: #6b6b6b; font-style: italic; }

.howto { text-align: left; font-size: 18px; line-height: 1.4; margin: 8px 0; padding-left: 26px; font-weight: 600; }
.howto li { margin: 5px 0; }
.keys { color: #6b6b6b; font-size: 15px; font-weight: 700; margin: 4px 0; }
.set-grid { display: grid; grid-template-columns: 1fr auto; gap: 12px 24px; align-items: center; text-align: left; font-size: 20px; font-weight: 800; margin: 14px 0; }
select { font: inherit; font-size: 18px; font-weight: 700; padding: 6px 10px; border-radius: 12px; border: 3px solid #1c1c1c; color: #1c1c1c; background: #fff; }

.quip { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: #8a5a2a; font-style: italic; }
.big-score { font-size: 70px; font-weight: 800; color: #c0392b; line-height: 1; -webkit-text-stroke: 2px #1c1c1c; paint-order: stroke fill; margin: 6px 0; }
.badge-new { display: inline-block; background: linear-gradient(#e9b949, #b9801a); color: #2a1a05; font-weight: 800; font-size: 20px; padding: 3px 18px; border-radius: 14px; box-shadow: 0 0 0 2px #1c1c1c; animation: wiggle .6s ease-in-out infinite; }
.stars { font-size: 66px; letter-spacing: 10px; line-height: 1; margin: 2px 0 6px; }
.stars span { display: inline-block; color: #e9b949; -webkit-text-stroke: 2px #1c1c1c; animation: pop .45s ease both; }
.stars span.off { color: #e0d8ca; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.stats div { background: #fff; border-radius: 12px; padding: 6px 8px; box-shadow: 0 0 0 2px #1c1c1c; }
.stats b { display: block; font-size: 24px; color: #1f4e9c; }
.stats small { color: #6b6b6b; font-size: 13px; font-weight: 700; line-height: 1.1; display: block; }
.reward { font-size: 24px; font-weight: 800; color: #b9801a; }
.tip { font-size: 16px; color: #6b6b6b; font-weight: 700; margin: 6px 0 0; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; bottom: 0; background: rgba(31,78,156,.95); color: #fff; text-align: center; padding: 12px; font-weight: 800; z-index: 50; }
}
