* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; background: #10141c; }
canvas#c { display: block; width: 100%; height: 100%; }

/* ============ menu ============ */
#menu {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #16213a 0%, #0f3450 55%, #1a5b6e 100%); z-index: 50;
}
.menuCard {
  background: rgba(12, 20, 34, .88); border: 1px solid #2e4a6b; border-radius: 18px;
  padding: 38px 44px; text-align: center; width: 380px; box-shadow: 0 22px 70px rgba(0,0,0,.55);
}
.menuCard h1 { color: #ffd54f; font-size: 40px; letter-spacing: 1px; text-shadow: 0 3px 12px rgba(0,0,0,.6); }
.menuSub { color: #90caf9; margin: 6px 0 22px; }
#charSelTitle { color: #90caf9; font-size: 14px; margin-bottom: 8px; }
#charSel { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.charBtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #17263c; border: 2px solid #26405f; border-radius: 14px; padding: 14px 10px;
  color: #a9c4e0; font-size: 15px; cursor: pointer; transition: .15s;
}
.charBtn:hover { background: #1e3450; }
.charBtn.on { border-color: #ffd54f; background: #22334e; color: #ffe082; }
.charEmoji { font-size: 40px; line-height: 1; }
.menuCard input {
  width: 100%; margin: 6px 0; padding: 11px 14px; border-radius: 10px; border: 1px solid #33507a;
  background: #0d1524; color: #e8eef7; font-size: 15px; outline: none;
}
.menuCard input:focus { border-color: #64b5f6; }
#menuErr { color: #ef9a9a; min-height: 18px; font-size: 13px; margin: 4px 0; }
.menuBtn {
  width: 100%; margin: 5px 0; padding: 12px; border: none; border-radius: 10px; cursor: pointer;
  background: #24405f; color: #dbe8f5; font-size: 16px; transition: .15s;
}
.menuBtn:hover { background: #2f527a; }
.menuBtn.primary { background: #f9a825; color: #1b1400; font-weight: 700; }
.menuBtn.primary:hover { background: #ffc046; }
.menuBtn.small { width: auto; padding: 7px 16px; font-size: 13px; margin-top: 12px; }
#saveList { max-height: 150px; overflow-y: auto; margin-top: 8px; }
.menuSave {
  display: block; width: 100%; margin: 3px 0; padding: 8px 10px; text-align: left; cursor: pointer;
  background: #17263c; color: #a9c4e0; border: 1px solid #26405f; border-radius: 8px; font-size: 13px;
}
.menuSave:hover { background: #1e3450; }

/* ============ HUD ============ */
#hudTopLeft {
  position: fixed; top: 14px; left: 16px; z-index: 10; color: #fff;
  background: rgba(10, 16, 28, .72); padding: 12px 18px; border-radius: 14px; border: 1px solid rgba(120,160,220,.25);
  backdrop-filter: blur(4px);
}
#hudMoney { font-size: 26px; font-weight: 800; color: #aed581; }
#hudMoney.neg { color: #ef5350; }
#hudLevel { font-size: 13px; color: #ffd54f; margin-top: 2px; }
#hudClock { font-size: 12px; color: #b0c4de; margin-top: 4px; }
#hudFlyers { font-size: 13px; color: #ffcc80; margin-top: 4px; }

#hudBars {
  position: fixed; top: 14px; right: 16px; z-index: 10; width: 190px;
  background: rgba(10, 16, 28, .72); padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(120,160,220,.25);
  backdrop-filter: blur(4px);
}
.bar { margin: 5px 0; }
.blabel { font-size: 10px; color: #9fb6d0; text-transform: uppercase; letter-spacing: .5px; }
.bar .track { height: 8px; background: #1a2436; border-radius: 5px; overflow: hidden; margin-top: 2px; }
.bar .fill { height: 100%; width: 50%; background: #66bb6a; border-radius: 5px; transition: width .3s; }

#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 30; width: 380px; pointer-events: none; }
.toast {
  margin: 5px auto; padding: 10px 16px; border-radius: 10px; color: #fff; font-size: 14px; text-align: center;
  background: rgba(30, 45, 70, .92); border: 1px solid rgba(130,170,230,.3); box-shadow: 0 6px 18px rgba(0,0,0,.4);
  animation: tin .25s ease;
}
.toast.good { background: rgba(35, 80, 45, .93); border-color: #66bb6a; }
.toast.warn { background: rgba(95, 70, 20, .93); border-color: #ffb300; }
.toast.bad { background: rgba(95, 32, 30, .93); border-color: #ef5350; }
.toast.out { opacity: 0; transition: opacity .4s; }
@keyframes tin { from { transform: translateY(-12px); opacity: 0; } }

#hint {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 10; display: none;
  background: rgba(10, 16, 28, .85); color: #ffe082; padding: 9px 20px; border-radius: 22px;
  font-size: 15px; font-weight: 600; border: 1px solid rgba(255,224,130,.4);
}

#progress {
  position: fixed; bottom: 140px; left: 50%; transform: translateX(-50%); z-index: 11; display: none;
  width: 240px; text-align: center;
}
#progressLabel { color: #fff; font-size: 13px; margin-bottom: 4px; text-shadow: 0 1px 4px #000; }
#progress .track { height: 12px; background: rgba(10,16,28,.8); border-radius: 7px; overflow: hidden; border: 1px solid #3d5a80; }
#progressFill { height: 100%; width: 0; background: #4fc3f7; }

#hudRent { font-size: 12px; color: #ffab91; margin-top: 3px; }

/* ============ quests ============ */
#quests {
  position: fixed; bottom: 18px; left: 16px; z-index: 10; width: 320px;
  background: rgba(10, 16, 28, .78); padding: 12px 16px; border-radius: 14px;
  border: 1px solid rgba(255, 213, 79, .35); backdrop-filter: blur(4px);
}
.qtitle { color: #ffd54f; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.qitem { color: #cfe0f2; font-size: 12.5px; margin: 4px 0; }
.qitem.done { color: #6b7f95; text-decoration: line-through; }
.qitem.done .qrew { text-decoration: line-through; }
.qrew { color: #aed581; font-weight: 700; margin-left: 4px; }

/* ============ money popups ============ */
.pop {
  position: fixed; z-index: 25; transform: translate(-50%, -50%); pointer-events: none;
  font-weight: 800; font-size: 20px; color: #aed581; text-shadow: 0 2px 6px rgba(0,0,0,.7);
  animation: popup 1.25s ease-out forwards;
}
@keyframes popup {
  0% { opacity: 0; margin-top: 0; transform: translate(-50%, -50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  30% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; margin-top: -70px; transform: translate(-50%, -50%) scale(1); }
}

/* ============ confetti ============ */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; top: -40px; animation: confall 3.2s linear forwards; }
@keyframes confall {
  to { transform: translateY(110vh) rotate(720deg); opacity: .7; }
}

/* ============ phone ============ */
#phone {
  position: fixed; right: -340px; bottom: 20px; width: 320px; height: 560px; max-height: calc(100vh - 60px); z-index: 20;
  background: #0d1220; border: 3px solid #2b3a55; border-radius: 28px; transition: right .3s ease;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#phone.open { right: 20px; }
#phoneNotch { height: 18px; background: #0d1220; position: relative; }
#phoneNotch::after { content: ''; position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: 70px; height: 7px; background: #1d2940; border-radius: 4px; }
#phoneTabs { display: flex; justify-content: space-around; padding: 4px 8px; border-bottom: 1px solid #1f2c44; }
.ptab { background: none; border: none; font-size: 19px; padding: 6px 7px; cursor: pointer; border-radius: 9px; opacity: .55; }
.ptab.on { background: #1c2b47; opacity: 1; }
#phoneBody { flex: 1; overflow-y: auto; padding: 12px 14px; color: #cfe0f2; font-size: 13px; }
#phoneBody h3 { color: #ffd54f; margin-bottom: 8px; font-size: 16px; }
#phoneBody h4 { color: #90caf9; margin: 14px 0 5px; font-size: 13px; }
.prow { margin: 6px 0; }
.prow.bad, .bad { color: #ef9a9a; }
.good { color: #a5d6a7; }
.pinfo { font-size: 11.5px; color: #8aa3c0; background: #131d31; border-radius: 8px; padding: 7px 9px; margin: 6px 0; }
.ptable { width: 100%; border-collapse: collapse; }
.ptable td { padding: 4px 3px; border-bottom: 1px solid #182339; font-size: 12.5px; }
.small { font-size: 11px; color: #7d95b3; }
.pbtn {
  background: #24405f; border: none; color: #dbe8f5; padding: 6px 11px; margin: 3px 2px; border-radius: 8px;
  cursor: pointer; font-size: 12.5px; transition: .12s;
}
.pbtn:hover { background: #2f527a; }
.pbtn.primary { background: #f9a825; color: #201700; font-weight: 700; }
.pbtn.danger { background: #7c2f2b; }
.pbtn.danger:hover { background: #9a3b36; }
.pbtn.on { background: #2e7d32; }
.pbtn:disabled { opacity: .45; cursor: default; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.dot.big { width: 16px; height: 16px; }
#phoneToggle {
  position: fixed; right: 20px; bottom: 20px; z-index: 19; width: 52px; height: 52px; border-radius: 50%;
  border: none; font-size: 24px; background: rgba(20, 32, 54, .9); cursor: pointer; border: 1px solid #3a557d;
}

/* ============ modal ============ */
#modal {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 40;
  background: rgba(5, 8, 15, .55);
}
#modalBox {
  background: #101a2c; border: 1px solid #2e4a6b; border-radius: 16px; padding: 26px 30px; min-width: 340px; max-width: 460px;
  color: #cfe0f2; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#modalBox h3 { color: #ffd54f; margin-bottom: 12px; }
#modalBox input[type=number] { width: 90px; padding: 5px 8px; border-radius: 7px; border: 1px solid #33507a; background: #0d1524; color: #fff; }
.mirrorGrid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 400px; }
.mirrorItem {
  background: #1a2940; border: 2px solid transparent; color: #cfe0f2; border-radius: 10px; padding: 12px 14px; cursor: pointer;
}
.mirrorItem.on { border-color: #ffd54f; }
.mirrorItem:hover { background: #223655; }

/* ============ paint ============ */
#paint { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 45; background: rgba(5, 8, 15, .6); }
#paintBox { background: #101a2c; border-radius: 16px; padding: 24px; border: 1px solid #2e4a6b; }
#paintBox h3 { color: #ffd54f; margin-bottom: 10px; }
#paintCanvas { border-radius: 8px; cursor: crosshair; display: block; width: 640px; max-width: 80vw; }
.paintTools { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
