@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --navy: #14204A;
  --panel: #23356F;
  --rim: #3A52A0;
  --deep: #0B1030;
  --cream: #FFF4DC;
  --lip: #E8C98F;
  --gold: #FFC93C;
  --goldRim: #E39B12;
  --green: #3DDC84;
  --greenLip: #1FA45E;
  --coral: #FF5A4E;
  --playW: 100vw;
  --panelW: 0px;
  --keyTop: 70vh;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--navy);
  font-family: "Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif; color: var(--cream);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#game, #tap { position: fixed; inset: 0; }
#game canvas { display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#ui button, .panel, .resultCard, .boardWrap, .menuCard, .durs { pointer-events: auto; }
button { font-family: inherit; color: inherit; border: 0; cursor: pointer; }
.hidden { display: none !important; }

/* keycap lip buttons */
.lipbtn {
  position: relative; border-radius: 16px; padding: 10px 18px; font-weight: 700; font-size: 17px;
  background: var(--panel); box-shadow: 0 5px 0 #17245A, 0 9px 16px rgba(6, 10, 36, .45);
  transition: transform .06s, box-shadow .06s;
}
.lipbtn:active, .lipbtn.down { transform: translateY(4px); box-shadow: 0 1px 0 #17245A, 0 3px 8px rgba(6, 10, 36, .45); }
.lipbtn.navy { background: linear-gradient(#2E4488, #23356F); border: 2px solid var(--rim); }
.lipbtn.green { background: linear-gradient(#5BEA9B, #3DDC84); color: #0E3B25; box-shadow: 0 5px 0 var(--greenLip), 0 9px 16px rgba(6, 10, 36, .45); }
.lipbtn.green:active { box-shadow: 0 1px 0 var(--greenLip); }

.iconbtn {
  position: absolute; top: 12px; width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(#2E4488, #23356F); border: 2px solid var(--rim);
  box-shadow: 0 4px 0 #17245A, 0 8px 14px rgba(6, 10, 36, .45);
  display: grid; place-items: center; z-index: 5;
}
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #17245A; }
.iconbtn svg { width: 24px; height: 24px; fill: var(--cream); }
.iconbtn svg .w { fill: none; stroke: var(--cream); stroke-width: 2.2; stroke-linecap: round; }
#homeBtn { left: 12px; }
#muteBtn { right: 12px; }
body.wide #muteBtn { right: auto; left: 66px; }
#muteBtn .off { display: none; }
#muteBtn.muted .on { display: none; }
#muteBtn.muted .off { display: block; }

.screen { position: absolute; inset: 0; }

/* MENU */
#menu { display: flex; align-items: center; justify-content: center; height: var(--keyTop); bottom: auto; padding: 64px 14px 10px; }
.menuCard { text-align: center; width: min(640px, 100%); pointer-events: none; }
.menuCard button { pointer-events: auto; }
.title { margin: 0; line-height: .95; font-weight: 700; font-size: clamp(40px, min(11vw, 12vh), 86px); letter-spacing: .5px;
  color: var(--cream); text-shadow: 0 4px 0 var(--lip), 0 8px 0 #17245A, 0 14px 22px rgba(6, 10, 36, .6); }
.title span { display: inline-block; margin: 0 .12em; }
.title span:last-child { color: var(--gold); text-shadow: 0 4px 0 var(--goldRim), 0 8px 0 #17245A, 0 14px 22px rgba(6, 10, 36, .6); }
.sub { margin: clamp(6px, 2vh, 14px) 0 clamp(10px, 3vh, 24px); font-size: clamp(14px, 2.4vh, 19px); opacity: .85; font-weight: 500; }
.menuBtns { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.bigbtn {
  min-width: 220px; flex: 0 1 260px; border-radius: 22px; padding: clamp(10px, 2.2vh, 18px) 20px clamp(12px, 2.6vh, 20px);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .06s, box-shadow .06s;
}
.bigbtn .bt { font-size: clamp(24px, 4.6vh, 34px); font-weight: 700; }
.bigbtn .bs { font-size: clamp(12px, 2vh, 15px); font-weight: 500; opacity: .8; }
.bigbtn.cream { background: linear-gradient(#FFFBEF, var(--cream)); color: #2A2F5E; box-shadow: 0 8px 0 var(--lip), 0 14px 24px rgba(6, 10, 36, .55); }
.bigbtn.gold { background: linear-gradient(#FFE07A, var(--gold)); color: #4A2A00; box-shadow: 0 8px 0 var(--goldRim), 0 14px 24px rgba(6, 10, 36, .55); }
.bigbtn:active { transform: translateY(6px); }
.bigbtn.cream:active { box-shadow: 0 2px 0 var(--lip); }
.bigbtn.gold:active { box-shadow: 0 2px 0 var(--goldRim); }
.menuNote { margin: clamp(12px, 3vh, 22px) 0 0; font-size: 15px; opacity: .8; }
.menuNote b { color: var(--gold); }

/* CLICKER HUD */
.hudTop {
  position: absolute; top: 10px; left: 0; width: var(--playW); padding: 0 66px;
  display: flex; justify-content: center; align-items: flex-start; gap: 10px; flex-wrap: wrap;
}
body.wide .hudTop { padding-left: 118px; padding-right: 12px; }
.pill {
  background: linear-gradient(#2E4488, #23356F); border: 2px solid var(--rim); border-radius: 20px;
  box-shadow: 0 5px 0 #17245A, 0 10px 18px rgba(6, 10, 36, .5);
}
.coinPill { display: flex; align-items: center; gap: 8px; padding: 5px 16px 5px 7px; min-width: 150px; }
.coinPill img { width: 42px; height: 42px; }
.pillText { display: flex; flex-direction: column; line-height: 1; }
.lbl { font-size: 13px; font-weight: 600; opacity: .8; }
.num { font-weight: 700; font-size: 28px; color: var(--cream); text-shadow: 0 2px 0 rgba(10, 16, 50, .6); }
.coinPill.bump { animation: bump .18s ease-out; }
@keyframes bump { 50% { transform: scale(1.08); } }
.distPill { padding: 6px 12px 8px; min-width: 170px; }
.distRow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.distRow .num { font-size: 22px; }
.distRow.small { font-size: 12px; font-weight: 500; opacity: .85; margin-top: 1px; }
.bar { height: 7px; border-radius: 6px; background: rgba(8, 14, 44, .6); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--gold), #FF9A2E); }

.combo, .autoTag {
  position: absolute; left: calc(var(--playW) / 2); transform: translateX(-50%);
  font-weight: 700; font-size: 15px; text-align: center; text-shadow: 0 2px 0 rgba(10, 16, 50, .7);
}
.combo { top: var(--comboTop, 120px); width: 140px; }
.combo .bar i { background: linear-gradient(90deg, #5FE3C0, var(--gold), var(--coral)); }
.combo.hot #comboTxt { color: var(--gold); }
.autoTag { top: var(--autoTop, 150px); display: flex; align-items: center; gap: 4px; font-size: 14px; opacity: .9; }
.autoTag img { width: 22px; height: 22px; }

.hint {
  position: absolute; left: calc(var(--playW) / 2); top: calc(var(--keyTop) - 14px); transform: translate(-50%, -100%);
  background: rgba(11, 16, 48, .72); border: 2px solid var(--rim); border-radius: 16px; padding: 7px 14px;
  font-size: 16px; font-weight: 600; white-space: nowrap; transition: opacity .6s;
  max-width: calc(var(--playW) - 24px);
}
.hint b { color: var(--gold); }
.hint.fade { opacity: 0; }
.hint.quiet { opacity: .55; background: transparent; border-color: transparent; font-size: 14px; }

.upToggle { position: absolute; right: 12px; bottom: 14px; padding: 10px 14px; font-size: 15px; }
.upToggle.ready { animation: glowBtn 1.4s ease-in-out infinite; }
.upToggle.ready::after { content: ""; position: absolute; top: -5px; right: -5px; width: 16px; height: 16px; border-radius: 50%; background: var(--gold); border: 2px solid #4A2A00; }
body.wide .upToggle { display: none; }

/* PANEL */
.panel {
  position: absolute; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(rgba(42, 62, 128, .95), rgba(31, 47, 102, .95)); border: 3px solid var(--rim); border-radius: 24px;
  box-shadow: 0 6px 0 #17245A, 0 14px 30px rgba(6, 10, 36, .6);
}
body.wide .panel { right: 14px; top: 14px; bottom: 14px; width: var(--panelW); }
body:not(.wide) .panel { left: 8px; right: 8px; bottom: 8px; max-height: 74%; transform: translateY(115%); transition: transform .25s ease; z-index: 6; }
body:not(.wide) .panel.open { transform: none; }
.panelHead { display: flex; align-items: center; justify-content: center; position: relative; padding: 10px 12px 4px; }
.panelHead h2 { margin: 0; font-size: 26px; font-weight: 700; text-shadow: 0 3px 0 #17245A; }
.closeBtn { position: absolute; right: 10px; top: 8px; width: 36px; height: 36px; border-radius: 50%; font-size: 26px; line-height: 1; background: #1A2862; border: 2px solid var(--rim); }
body.wide .closeBtn { display: none; }
.panelBody { overflow-y: auto; padding: 4px 10px 12px; touch-action: pan-y; }
.panelBody h3 { margin: 12px 4px 6px; font-size: 17px; font-weight: 700; opacity: .9; }
.card {
  display: grid; grid-template-columns: 52px 1fr auto; grid-template-rows: auto auto; gap: 2px 10px; align-items: center;
  background: linear-gradient(#2F468C, #283D7E); border: 2px solid var(--rim); border-radius: 18px; padding: 8px 10px; margin-bottom: 10px;
  box-shadow: 0 4px 0 #1A2862;
}
.card .ic { grid-row: 1 / 3; width: 52px; height: 52px; border-radius: 50%; background: #1A2862; border: 2px solid var(--rim); display: grid; place-items: center; }
.card .ic img { width: 40px; height: 40px; }
.card .nm { font-weight: 700; font-size: 16px; line-height: 1.1; }
.card .lv { font-size: 12.5px; font-weight: 500; opacity: .85; line-height: 1.2; }
.card .buy { grid-row: 1 / 3; grid-column: 3; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 76px; padding: 6px 10px 7px; font-size: 15px;
  background: #3A4A80; color: rgba(255, 244, 220, .6); box-shadow: 0 4px 0 #1A2862; border-radius: 14px; }
.card .buy .cost { display: flex; align-items: center; gap: 3px; font-size: 14px; font-weight: 700; }
.card .buy .cost img { width: 16px; height: 16px; }
.card .buy .lock { width: 14px; height: 14px; fill: currentColor; }
.card.afford .buy { background: linear-gradient(#5BEA9B, #3DDC84); color: #0E3B25; box-shadow: 0 4px 0 var(--greenLip); }
.card.afford .buy:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--greenLip); }
.card.afford { border-color: #6FE7B0; }
.card.glow { animation: glowCard 1.5s ease-in-out infinite; }
@keyframes glowCard { 50% { box-shadow: 0 4px 0 #1A2862, 0 0 22px 4px rgba(255, 201, 60, .65); border-color: var(--gold); } }
@keyframes glowBtn { 50% { box-shadow: 0 5px 0 #17245A, 0 0 22px 6px rgba(255, 201, 60, .7); } }

.skins { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.skin { display: flex; flex-direction: column; align-items: center; padding: 6px 4px 7px; border-radius: 16px; background: #283D7E; border: 2px solid var(--rim); box-shadow: 0 4px 0 #1A2862; font-size: 12.5px; font-weight: 600; }
.skin img { height: 44px; width: auto; }
.skin .cost { display: flex; align-items: center; gap: 2px; }
.skin .cost img { width: 13px; height: 13px; }
.skin.on { border-color: var(--gold); background: #34509A; }
.skin.locked { opacity: .55; }
.skin.afford { border-color: #6FE7B0; }

/* SPEED */
.speedTop { position: absolute; top: 66px; left: 50%; transform: translateX(-50%); width: min(520px, 94vw); text-align: center; }
.durs { display: flex; gap: 10px; justify-content: center; }
.dur { min-width: 66px; }
.dur.sel { background: linear-gradient(#FFE07A, var(--gold)); color: #4A2A00; border-color: var(--goldRim); box-shadow: 0 5px 0 var(--goldRim); }
.durs.locked .dur:not(.sel) { opacity: .4; }
.speedLive { margin-top: clamp(6px, 2.2vh, 18px); }
.bigCount { font-size: clamp(56px, 15vh, 128px); font-weight: 700; line-height: 1; color: var(--cream); text-shadow: 0 5px 0 var(--lip), 0 10px 0 #17245A, 0 16px 24px rgba(6, 10, 36, .6); }
.spRow { margin-top: 6px; font-size: 19px; font-weight: 600; display: flex; justify-content: center; gap: 10px; }
.spRow .dot { opacity: .5; }
.timeBar { width: min(320px, 80%); margin: 8px auto 0; height: 10px; }
.spBest { margin-top: 6px; font-size: 14px; opacity: .8; }

.resultWrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 12, 38, .55); padding: 10px; z-index: 4; }
.resultCard { width: min(420px, 100%); max-height: 100%; overflow-y: auto; text-align: center; padding: 14px 18px 18px;
  background: linear-gradient(#2E4488, #23356F); border: 3px solid var(--rim); border-radius: 26px; box-shadow: 0 7px 0 #17245A, 0 16px 34px rgba(6, 10, 36, .7);
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.newRec { display: inline-block; background: linear-gradient(#FFE07A, var(--gold)); color: #4A2A00; font-weight: 700; font-size: 20px; padding: 4px 16px; border-radius: 14px; box-shadow: 0 4px 0 var(--goldRim); animation: wob .8s ease-in-out infinite; }
@keyframes wob { 50% { transform: rotate(-3deg) scale(1.06); } }
.rankPic img { height: clamp(70px, 22vh, 160px); width: auto; margin-top: 6px; }
.rankName { font-size: clamp(28px, 6vh, 40px); font-weight: 700; color: var(--gold); text-shadow: 0 3px 0 #17245A; }
.resStats { display: flex; justify-content: center; gap: 26px; margin: 4px 0; }
.resStats div { display: flex; flex-direction: column; }
.resStats .num { font-size: 34px; }
.resBest { font-size: 14px; opacity: .8; margin-bottom: 12px; }
.resBtns { display: flex; gap: 12px; justify-content: center; }

.banner { position: absolute; left: calc(var(--playW) / 2); top: 30%; transform: translate(-50%, -50%); text-align: center; z-index: 4; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); white-space: nowrap; }
.bTitle { font-size: clamp(30px, 6vw, 54px); font-weight: 700; color: var(--cream); text-shadow: 0 4px 0 var(--lip), 0 8px 0 #17245A, 0 12px 20px rgba(6, 10, 36, .6); }
.bSub { display: inline-block; margin-top: 8px; font-size: 20px; font-weight: 700; color: #4A2A00; background: linear-gradient(#FFE07A, var(--gold)); padding: 4px 14px; border-radius: 14px; box-shadow: 0 4px 0 var(--goldRim); }
.banner.out { opacity: 0; transition: opacity .5s; }
.toast { position: absolute; left: calc(var(--playW) / 2); top: var(--toastTop, 130px); transform: translateX(-50%); background: rgba(11, 16, 48, .85); border: 2px solid var(--gold); border-radius: 14px; padding: 7px 14px; font-weight: 600; font-size: 15px; z-index: 4; max-width: calc(var(--playW) - 24px); text-align: center; }

@media (max-width: 520px) {
  .num { font-size: 24px; }
  .coinPill { min-width: 130px; padding-right: 12px; }
  .coinPill img { width: 36px; height: 36px; }
  .distPill { min-width: 150px; }
  .distRow .num { font-size: 18px; }
  .hint { font-size: 14px; }
  .bigbtn { min-width: 0; flex: 1 1 100%; }
  .menuBtns { flex-direction: column; align-items: stretch; max-width: 320px; margin: 0 auto; }
}
@media (max-height: 460px) {
  .speedTop { top: 10px; }
  .spRow { font-size: 16px; }
  .spBest { display: none; }
  .bigbtn .bs { display: none; }
  .menuNote { display: none; }
  #menu { padding-top: 20px; }
}

.card .buy:active, .skin:active { transform: translateY(3px); box-shadow: 0 1px 0 #1A2862; }
.nope { animation: nope .4s ease; }
.card.nope .buy { background: #7A3A55; color: #FFD9D9; }
@keyframes nope { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.toast { z-index: 7; }

/* leaderboard */
.boardBtn { margin-top: clamp(12px, 3vh, 20px); display: inline-flex; align-items: center; gap: 8px; }
.boardBtn svg { width: 22px; height: 22px; fill: var(--gold); }
.boardWrap { z-index: 6; }
.boardCard { width: min(460px, 100%); display: flex; flex-direction: column; text-align: left; }
.boardCard .panelHead { padding: 2px 40px 6px; }
body.wide .boardCard .closeBtn, .boardCard .closeBtn { display: grid; place-items: center; right: 0; top: 0; }
.boardCard h2 { margin: 2px 0 4px; font-size: 26px; color: var(--gold); text-shadow: 0 3px 0 #17245A; }
.boardTabs { display: flex; gap: 6px; flex-wrap: wrap; }
.boardTabs .tab { padding: 6px 12px; font-size: 15px; border-radius: 12px; flex: 1 1 auto; }
.boardTabs .tab.sel { background: linear-gradient(#FFE07A, var(--gold)); color: #4A2A00; border-color: var(--goldRim); box-shadow: 0 4px 0 var(--goldRim); }
.boardSub { margin: 10px 0 4px; font-size: 14px; opacity: .8; }
.boardList { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 60px; flex: 1 1 auto; }
.boardList li, .boardMine { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; font-size: 17px; }
.boardList li:nth-child(odd) { background: rgba(10, 16, 50, .35); }
.boardList li.mine, .boardMine { background: rgba(255, 201, 60, .2) !important; border: 2px solid var(--gold); }
.boardList .rk { width: 30px; font-weight: 700; color: var(--gold); text-align: right; flex: none; }
.boardList li:nth-child(-n+3) .rk { font-size: 20px; }
.boardList .who, .boardMine .who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boardList a, .boardMine a { color: var(--cream); text-decoration: underline; text-decoration-color: rgba(255, 244, 220, .35); }
.boardList .val, .boardMine .val { font-weight: 700; flex: none; }
.boardList .empty { justify-content: center; opacity: .8; background: none !important; }
.boardMine { margin-top: 8px; }
.boardMine:empty { display: none; }
.resBtns { flex-wrap: wrap; }
@media (max-height: 460px) { .boardCard h2 { font-size: 20px; margin: 0 0 4px; } .boardSub { margin: 6px 0 2px; } .boardList li { padding: 4px 10px; font-size: 15px; } .boardBtn { margin-top: 8px; padding: 6px 14px; } }
