@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3ff; font-family: 'Fredoka', system-ui, sans-serif; color: #263238; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud button, #tasks, #prompt { pointer-events: auto; }
.pill { background: rgba(255,255,255,.92); border-radius: 18px; box-shadow: 0 4px 0 rgba(0,0,0,.15), 0 6px 18px rgba(0,0,0,.12); }

#topLeft { position: absolute; left: 14px; top: 12px; display: flex; flex-direction: column; gap: 8px; }
#moneyBox { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 10px; font-size: 26px; font-weight: 700; color: #2e7d32; transition: transform .15s; }
#moneyBox.pop { transform: scale(1.15); }
#moneyBox .ico { font-size: 24px; }
#levelBox { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; }
#lvlBadge { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,#ffb300,#ff6f00); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.xpWrap { width: 150px; }
.xpBar { height: 12px; background: #e0e0e0; border-radius: 8px; overflow: hidden; }
#xpFill { height: 100%; width: 0; background: linear-gradient(90deg,#7c4dff,#e040fb); transition: width .25s; }
#xpText { font-size: 12px; font-weight: 600; color: #555; margin-top: 2px; }

#topRight { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; }
.hbtn { position: relative; border: 0; background: #fff; border-radius: 16px; padding: 6px 12px; font-size: 24px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .1s; }
.hbtn span { font-size: 12px; font-weight: 600; color: #444; }
.hbtn:hover { transform: translateY(-2px); }
.hbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
#btnShop { background: #ffeb3b; }
.dot { position: absolute; top: 3px; right: 5px; width: 13px; height: 13px; border-radius: 50%; background: #ff1744; border: 2px solid #fff; display: none; animation: pulse 1s infinite; }
.dot.on { display: block; }
@keyframes pulse { 50% { transform: scale(1.3); } }

#tasks { position: absolute; left: 14px; top: 118px; width: 250px; background: rgba(255,255,255,.9); border-radius: 16px; box-shadow: 0 6px 18px rgba(0,0,0,.15); overflow: hidden; }
#tasksHead { background: #5c6bc0; color: #fff; font-weight: 600; padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; }
#tasks.collapsed #taskList { display: none; }
#tasks.collapsed #tasksToggle { transform: rotate(-90deg); }
#taskList { max-height: 46vh; overflow-y: auto; padding: 6px; }
.task { padding: 6px 8px; border-radius: 10px; margin-bottom: 5px; background: #f3f4fb; cursor: pointer; border: 2px solid transparent; }
.task:hover { background: #e8eaf6; }
.task.tracked { border-color: #ffb300; background: #fff8e1; }
.task .t1 { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.task .sw { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.25); flex: none; }
.task .t2 { display: flex; justify-content: space-between; font-size: 12px; color: #666; margin-top: 3px; }
.task .t2 b { color: #2e7d32; }
.task .bar { height: 6px; background: #ddd; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.task .bar i { display: block; height: 100%; background: #66bb6a; }
.bigtag { font-size: 10px; background: #ff7043; color: #fff; padding: 1px 5px; border-radius: 6px; }
.taskNote { font-size: 12px; color: #666; padding: 4px 6px; }

#jobPanel { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.93); padding: 7px 16px 8px; border-radius: 16px; min-width: 260px; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
#jpTitle { font-weight: 700; font-size: 16px; }
.jpBar { height: 14px; background: #e0e0e0; border-radius: 8px; overflow: hidden; margin: 4px 0; border: 2px solid rgba(0,0,0,.08); }
#jpFill { height: 100%; width: 0; background: #42a5f5; transition: width .15s; }
#jpInfo { font-size: 13px; color: #555; display: flex; justify-content: center; align-items: center; gap: 6px; }
#jpInfo .sw { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid rgba(0,0,0,.2); }

#crosshair { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid rgba(255,255,255,.85); border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.3); transition: transform .1s, border-color .1s; }
#crosshair i { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #fff; }
#crosshair.ok { border-color: #69f0ae; transform: scale(1.15); }
#crosshair.far { border-color: #ff5252; }
#crosshair.done { border-color: #ffd740; }
#crosshair.painting { transform: scale(.85); }
body.mouseAim #crosshair { display: none; }
#hint { position: absolute; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); color: #fff; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,.6); font-size: 16px; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#hint.show { opacity: 1; }

#toasts { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: 90vw; }
.toast { background: rgba(38,50,56,.9); color: #fff; padding: 8px 16px; border-radius: 14px; font-weight: 500; font-size: 15px; animation: tin .3s ease-out, tout .4s ease-in forwards; animation-delay: 0s, var(--d, 3s); text-align: center; max-width: 520px; }
.toast.big { background: linear-gradient(135deg,#43a047,#00897b); font-size: 18px; font-weight: 700; }
.toast.gold { background: linear-gradient(135deg,#ffb300,#f57c00); font-weight: 700; }
.toast.lvl { background: linear-gradient(135deg,#7c4dff,#e040fb); font-weight: 700; font-size: 20px; }
@keyframes tin { from { transform: translateY(-15px) scale(.9); opacity: 0; } }
@keyframes tout { to { opacity: 0; transform: translateY(-10px); } }

#prompt { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); background: rgba(255,255,255,.95); padding: 8px 8px 8px 16px; border-radius: 16px; display: flex; gap: 10px; align-items: center; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
#promptBtn { border: 0; background: #ffb300; color: #fff; font-weight: 700; border-radius: 10px; padding: 6px 14px; font-size: 16px; box-shadow: 0 3px 0 #c67c00; }

#bottom { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 96vw; }
#toolInfo { font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); font-weight: 500; }
#colorName { background: rgba(0,0,0,.45); color: #fff; padding: 2px 12px; border-radius: 10px; font-weight: 600; }
#hotbar { display: flex; gap: 6px; background: rgba(255,255,255,.85); padding: 7px; border-radius: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.2); overflow-x: auto; max-width: 96vw; pointer-events: auto; }
.slot { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.2); cursor: pointer; transition: transform .1s; }
.slot.on { transform: scale(1.18); box-shadow: 0 0 0 3px #263238; }
.slot small { position: absolute; bottom: -4px; right: -4px; background: #263238; color: #fff; font-size: 10px; border-radius: 6px; padding: 0 4px; }
.rainbowSw { background: conic-gradient(red, orange, yellow, lime, cyan, blue, magenta, red) !important; }
.goldSw { background: radial-gradient(circle at 30% 30%, #fff6c2, #ffc629 45%, #c48a00) !important; }

#keysHelp { position: absolute; left: 14px; bottom: 10px; font-size: 11px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); max-width: 300px; opacity: .85; }
#clickHint { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); background: rgba(0,0,0,.6); color: #fff; padding: 10px 22px; border-radius: 14px; font-size: 18px; font-weight: 600; animation: pulse 1.5s infinite; }

#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.floater { position: absolute; font-weight: 700; color: #fff; font-size: 20px; text-shadow: 0 2px 0 #1b5e20, 0 0 6px rgba(0,0,0,.5); animation: floatUp 1.1s ease-out forwards; transform: translate(-50%,-50%); white-space: nowrap; }
.floater.big { font-size: 34px; color: #ffeb3b; text-shadow: 0 3px 0 #e65100, 0 0 10px rgba(0,0,0,.4); animation-duration: 1.8s; }
.floater.xp { color: #e1bee7; text-shadow: 0 2px 0 #4a148c; font-size: 16px; }
@keyframes floatUp { 0% { opacity: 0; margin-top: 10px; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -70px; } }

/* mobile controls */
#joyZone, .mbtn { display: none; }
body.touch #joyZone { display: block; position: absolute; left: 0; bottom: 0; width: 42%; height: 55%; pointer-events: auto; touch-action: none; }
#joyBase { position: absolute; left: 70px; bottom: 70px; width: 120px; height: 120px; margin: -60px; border-radius: 50%; background: rgba(255,255,255,.25); border: 3px solid rgba(255,255,255,.6); }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 3px 8px rgba(0,0,0,.3); }
body.touch .mbtn { display: grid; place-items: center; position: absolute; border: 0; border-radius: 50%; color: #fff; font-weight: 700; touch-action: none; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
body.touch #btnPaint { right: 24px; bottom: 96px; width: 96px; height: 96px; font-size: 34px; background: linear-gradient(135deg,#ff4081,#7c4dff); line-height: 1; }
body.touch #btnPaint small { font-size: 12px; }
body.touch #btnPaint.on { transform: scale(.92); }
body.touch #btnJump { right: 132px; bottom: 40px; width: 66px; height: 66px; font-size: 30px; background: #29b6f6; }
body.touch #keysHelp { display: none; }
body.touch #bottom { bottom: 8px; }
body.touch #prompt { bottom: 210px; }

/* ---------- start ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(255,255,255,.15), rgba(30,40,80,.55)); }
.startCard { background: #fff; border-radius: 28px; padding: 28px 34px; text-align: center; max-width: 460px; width: 92vw; box-shadow: 0 10px 0 rgba(0,0,0,.15), 0 20px 50px rgba(0,0,0,.3); animation: tin .4s; }
.logo { font-size: 46px; font-weight: 700; color: #ff4081; text-shadow: 3px 3px 0 #ffe082; }
.logo b { color: #536dfe; }
.tag { margin: 4px 0 14px; font-size: 18px; color: #666; }
.howto { text-align: left; background: #f3f4fb; border-radius: 16px; padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; margin-bottom: 16px; }
.bigBtn { border: 0; background: linear-gradient(135deg,#00c853,#00bfa5); color: #fff; font-size: 24px; font-weight: 700; padding: 12px 42px; border-radius: 18px; box-shadow: 0 6px 0 #00796b; }
.bigBtn:active { transform: translateY(3px); box-shadow: 0 3px 0 #00796b; }
.bigBtn:disabled { background: #bbb; box-shadow: 0 6px 0 #888; cursor: default; }
.small { font-size: 12px; color: #999; margin-top: 12px; }
.center { text-align: center; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 15; background: rgba(20,30,60,.5); display: grid; place-items: center; }
.mcard { background: #fff; border-radius: 24px; width: min(480px, 94vw); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.35); animation: tin .25s; }
.mcard.wide { width: min(860px, 96vw); }
.mhead { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(135deg,#536dfe,#7c4dff); color: #fff; }
.mhead h2 { margin: 0; font-size: 22px; flex: 1; }
.mmoney { background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 12px; font-weight: 700; }
.x { border: 0; background: rgba(255,255,255,.25); color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; }
#shopTabs { display: flex; gap: 4px; padding: 8px; background: #eef0fb; overflow-x: auto; flex: none; }
#shopTabs button { border: 0; background: #fff; border-radius: 12px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; color: #555; }
#shopTabs button.on { background: #536dfe; color: #fff; }
#shopBody { padding: 12px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 10px; align-content: start; }
#shopBody h3 { grid-column: 1/-1; margin: 6px 0 0; font-size: 16px; color: #536dfe; }
.card { background: #f6f7fd; border-radius: 16px; padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; border: 2px solid #e6e8f5; }
.card.equipped { border-color: #00c853; background: #effbf3; }
.card .icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 32px; }
.card .icon.sw { border: 4px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }
.card .cname { font-weight: 700; font-size: 15px; }
.card .cdesc { font-size: 12px; color: #666; min-height: 30px; }
.b { border: 0; border-radius: 12px; padding: 7px 12px; font-weight: 700; font-size: 14px; background: #536dfe; color: #fff; box-shadow: 0 3px 0 #303f9f; width: 100%; }
.b:active { transform: translateY(2px); box-shadow: 0 1px 0 #303f9f; }
.b.buy { background: #00c853; box-shadow: 0 3px 0 #00873a; }
.b.buy.poor { background: #9e9e9e; box-shadow: 0 3px 0 #666; }
.b.locked { background: #bdbdbd; box-shadow: 0 3px 0 #888; }
.b.eq { background: #e0f2e9; color: #00873a; box-shadow: none; cursor: default; }
.b.danger { background: #ff5252; box-shadow: 0 3px 0 #c62828; }
.lvlPips { display: flex; gap: 3px; }
.lvlPips i { width: 10px; height: 10px; border-radius: 3px; background: #ddd; }
.lvlPips i.on { background: #ffb300; }

.setList { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 500; background: #f3f4fb; padding: 10px 14px; border-radius: 12px; }
.row input[type=checkbox] { width: 22px; height: 22px; accent-color: #536dfe; }
.row input[type=range] { width: 50%; accent-color: #536dfe; }
.row select { font-family: inherit; font-size: 15px; padding: 4px 8px; border-radius: 8px; }
.row.btns { background: none; padding: 0; }

#achList { padding: 12px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 10px; }
.ach { display: flex; gap: 10px; align-items: center; background: #f3f4fb; border-radius: 14px; padding: 10px; opacity: .75; }
.ach.got { background: #fff8e1; opacity: 1; border: 2px solid #ffca28; }
.ach .ai { font-size: 30px; filter: grayscale(1); }
.ach.got .ai { filter: none; }
.ach .an { font-weight: 700; font-size: 14px; }
.ach .ad { font-size: 12px; color: #666; }
.ach .ap { height: 5px; background: #ddd; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.ach .ap i { display: block; height: 100%; background: #ffb300; }

#dailyDays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 8px 16px 14px; }
.day { background: #f3f4fb; border-radius: 12px; padding: 8px 2px; text-align: center; font-size: 12px; font-weight: 600; border: 2px solid transparent; }
.day b { display: block; font-size: 20px; }
.day.got { background: #e0f2e9; color: #00873a; }
.day.next { border-color: #ffb300; background: #fff8e1; animation: pulse 1.2s infinite; }
#dailyModal .mcard { padding-bottom: 16px; }

@media (max-width: 700px) {
  #moneyBox { font-size: 20px; padding: 4px 12px 4px 8px; }
  .xpWrap { width: 100px; }
  #lvlBadge { width: 32px; height: 32px; font-size: 16px; }
  .hbtn { padding: 5px 8px; font-size: 20px; }
  .hbtn span { display: none; }
  #tasks { top: 100px; width: 200px; }
  #taskList { max-height: 30vh; }
  #jobPanel { top: auto; bottom: 120px; min-width: 200px; padding: 5px 12px; }
  body.touch #jobPanel { bottom: auto; top: 60px; }
  #toasts { top: 150px; }
  .slot { width: 34px; height: 34px; }
  #keysHelp { display: none; }
  .logo { font-size: 36px; }
}

/* phone layout tweaks */
@media (max-width: 700px) {
  body.touch #jobPanel { top: 104px; left: auto; right: 10px; transform: none; width: 50vw; min-width: 0; padding: 4px 8px; }
  body.touch #jpTitle { font-size: 13px; }
  body.touch #jpInfo { font-size: 11px; flex-wrap: wrap; gap: 3px; }
  body.touch #tasks { width: 44vw; }
  body.touch #toolInfo { display: none; }
  body.touch #btnJump { right: 40px; bottom: 210px; }
  body.touch #btnPaint { bottom: 70px; }
  body.touch #bottom { left: 50%; bottom: 6px; }
  body.touch #colorName { font-size: 12px; }
  #toasts { top: 190px; }
  .toast { font-size: 13px; padding: 6px 12px; }
  .toast.big, .toast.lvl { font-size: 15px; }
}

/* username */
.nameBox { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; text-align: left; }
.nameBox label { font-weight: 600; font-size: 15px; }
#nameInput { font-family: inherit; font-size: 20px; font-weight: 600; padding: 10px 14px; border-radius: 14px; border: 3px solid #c5cae9; outline: none; text-align: center; -webkit-user-select: text; user-select: text; }
#nameInput:focus { border-color: #536dfe; }
#nameInput.bad { border-color: #ff5252; animation: shake .3s; }
#nameErr { color: #e53935; font-size: 13px; font-weight: 600; min-height: 16px; text-align: center; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
#nameBox { padding: 4px 14px; font-weight: 600; font-size: 15px; color: #3949ab; align-self: flex-start; }
.nameEdit { display: flex; gap: 6px; }
.nameEdit input { font-family: inherit; font-size: 15px; width: 130px; padding: 4px 8px; border-radius: 8px; border: 2px solid #c5cae9; -webkit-user-select: text; user-select: text; }
.nameEdit .b { width: auto; }
@media (max-width: 700px) { #nameBox { font-size: 13px; padding: 3px 10px; } #tasks { top: 132px; } body.touch #jobPanel { top: 136px; } }
#tasks { top: 156px; }
@media (max-width: 700px) { #tasks { top: 140px; } body.touch #jobPanel { top: 140px; } }

/* leaderboard */
#lbBody { padding: 10px 14px 14px; overflow-y: auto; }
.lbRow { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: #f3f4fb; margin-bottom: 5px; }
.lbRow.me { background: #fff8e1; border: 2px solid #ffb300; }
.lbRank { width: 34px; text-align: center; font-weight: 700; font-size: 18px; }
.lbName { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbName small { display: block; font-weight: 400; color: #777; font-size: 11px; }
.lbMoney { font-weight: 700; color: #2e7d32; }
.lbNote { text-align: center; font-size: 13px; color: #666; margin: 8px 0 2px; }
