/* Layout scales with --s (set from JS) so the overlays line up with the 672x840 canvas. */
:root { --s: 1; --pink: #ff5d8f; --pink2: #ff8fb8; --lav: #7a4fd6; --ink: #4a3552; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  background: #ffe9f3 radial-gradient(ellipse at 50% 30%, #fff6fb 0%, #ffe0ef 45%, #e9ddff 100%) fixed;
  color: var(--ink);
  font-family: 'Fredoka', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  font-weight: 600;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

#stage {
  position: relative;
  flex: none;
  background: #fff;
  border-radius: calc(14px * var(--s));
  overflow: hidden;
  box-shadow: 0 0 0 calc(4px * var(--s)) #fff, 0 calc(10px * var(--s)) calc(40px * var(--s)) rgba(178, 58, 120, .3);
}

#game { display: block; width: 100%; height: 100%; }

#hudButtons { position: absolute; top: calc(9px * var(--s)); right: calc(12px * var(--s)); display: none; }
#stage.ingame #hudButtons { display: block; }
.icon-btn {
  font: inherit;
  font-size: max(11px, calc(14px * var(--s)));
  width: max(32px, calc(40px * var(--s)));
  height: max(30px, calc(38px * var(--s)));
  padding: 0;
  color: #fff;
  background: var(--pink2);
  border: 2px solid #fff;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(178, 58, 120, .4);
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--pink); outline: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(11px * var(--s));
  padding: calc(22px * var(--s)) calc(18px * var(--s));
  text-align: center;
  background: rgba(255, 240, 248, .9);
  font-size: max(11px, calc(14px * var(--s)));
  overflow-y: auto;
  touch-action: pan-y;
}
#menu.overlay { background: linear-gradient(rgba(255, 240, 248, .55), rgba(255, 240, 248, .88)); }
.hidden { display: none !important; }

h1.logo {
  margin: 0;
  display: flex;
  align-items: center;
  gap: calc(10px * var(--s));
  font-weight: 700;
  font-size: calc(72px * var(--s));
  line-height: 1;
  color: var(--pink);
  -webkit-text-stroke: calc(3px * var(--s)) #fff;
  paint-order: stroke fill;
  text-shadow: 0 calc(5px * var(--s)) 0 #ffb3d6, 0 calc(10px * var(--s)) calc(18px * var(--s)) rgba(178, 58, 120, .35);
  letter-spacing: -.01em;
}
.paw {
  width: calc(54px * var(--s));
  height: calc(54px * var(--s));
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cellipse cx='16' cy='20' rx='7.5' ry='6.5' fill='%23ff5d8f' stroke='white' stroke-width='1.5'/%3E%3Ccircle cx='8.5' cy='12' r='3.4' fill='%23ff5d8f' stroke='white' stroke-width='1.5'/%3E%3Ccircle cx='13.5' cy='7.5' r='3.4' fill='%23ff5d8f' stroke='white' stroke-width='1.5'/%3E%3Ccircle cx='19.5' cy='7.5' r='3.4' fill='%23ff5d8f' stroke='white' stroke-width='1.5'/%3E%3Ccircle cx='24.5' cy='12' r='3.4' fill='%23ff5d8f' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E");
  transform: rotate(-12deg);
}

h2 {
  margin: 0 0 calc(4px * var(--s));
  font-weight: 700;
  font-size: max(22px, calc(34px * var(--s)));
  color: var(--pink);
  -webkit-text-stroke: calc(2px * var(--s)) #fff;
  paint-order: stroke fill;
  text-shadow: 0 calc(3px * var(--s)) 0 #ffc2dc;
}
#goTitle.win { color: var(--lav); text-shadow: 0 calc(3px * var(--s)) 0 #d9c9ff; }
h3 { margin: 0 0 calc(10px * var(--s)); font-size: max(13px, calc(16px * var(--s))); color: var(--lav); }
p { margin: 0; }

.tag { font-size: max(11px, calc(15px * var(--s))); color: var(--lav); letter-spacing: .06em; margin-bottom: calc(6px * var(--s)); }
.hi { font-size: max(12px, calc(16px * var(--s))); color: var(--pink); min-height: 1.2em; }
.big { font-size: max(18px, calc(26px * var(--s))); color: var(--lav); }
.saved { font-size: max(12px, calc(15px * var(--s))); color: #2e9e6a; min-height: 1.2em; max-width: calc(560px * var(--s)); line-height: 1.4; }
.note { max-width: calc(580px * var(--s)); font-size: max(12px, calc(15px * var(--s))); font-weight: 500; line-height: 1.4; color: #6b5776; }

.btn {
  font: inherit;
  font-weight: 700;
  font-size: max(14px, calc(19px * var(--s)));
  letter-spacing: .03em;
  color: var(--lav);
  background: #fff;
  border: calc(3px * var(--s)) solid #d9c9ff;
  border-radius: 999px;
  padding: max(7px, calc(10px * var(--s))) max(12px, calc(18px * var(--s)));
  min-width: calc(300px * var(--s));
  cursor: pointer;
  box-shadow: 0 calc(4px * var(--s)) 0 #d9c9ff;
  transition: transform .08s, border-color .1s, color .1s;
}
.btn:hover, .btn:focus-visible { outline: none; border-color: var(--pink2); color: var(--pink); transform: translateY(-1px); box-shadow: 0 calc(4px * var(--s)) 0 var(--pink2); }
.btn:active { transform: translateY(calc(3px * var(--s))); box-shadow: 0 calc(1px * var(--s)) 0 #d9c9ff; }
.btn.primary { background: var(--pink); color: #fff; border-color: #fff; box-shadow: 0 calc(4px * var(--s)) 0 #c23c6e; }
.btn.primary:hover, .btn.primary:focus-visible { background: #ff4a82; color: #fff; box-shadow: 0 calc(4px * var(--s)) 0 #c23c6e; }
.btn.small { min-width: 0; font-size: max(12px, calc(15px * var(--s))); }
.btn:disabled { opacity: .5; cursor: default; }

.menu-buttons { display: flex; flex-direction: column; align-items: stretch; gap: calc(11px * var(--s)); width: max(240px, calc(330px * var(--s))); }
.row { display: flex; gap: calc(10px * var(--s)); justify-content: center; }
.row .btn { flex: 1; }

/* help */
.help-grid { display: grid; grid-template-columns: 1fr 1.35fr; gap: calc(12px * var(--s)); width: 100%; text-align: left; }
.panel { background: #fff; border: 2px solid #ffd6ea; border-radius: calc(16px * var(--s)); padding: calc(14px * var(--s)); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: calc(7px * var(--s)) calc(10px * var(--s)); margin: 0; }
.keys dt { color: var(--pink); }
.keys dd { margin: 0; font-weight: 500; }
.facts { margin: 0; padding-left: 1.1em; display: grid; gap: calc(6px * var(--s)); font-weight: 500; line-height: 1.35; }
.facts b { color: var(--pink); }

/* level select: one row per zone */
.level-grid { display: grid; grid-template-columns: repeat(11, calc(46px * var(--s))); gap: calc(5px * var(--s)); align-items: center; }
.zone-label { font-size: max(9px, calc(12px * var(--s))); text-align: right; padding-right: calc(6px * var(--s)); color: var(--lav); white-space: nowrap; }
.lbtn {
  font: inherit;
  font-weight: 700;
  font-size: max(10px, calc(14px * var(--s)));
  height: calc(46px * var(--s));
  padding: 0;
  color: #fff;
  border: 2px solid #fff;
  border-radius: calc(12px * var(--s));
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.lbtn:disabled { opacity: .3; cursor: default; }
.lbtn:not(:disabled):hover, .lbtn:focus-visible { outline: 3px solid var(--pink); outline-offset: 1px; }
.lbtn.stage-barrels { background: #e0658f; } .lbtn.stage-factory { background: #c98f6a; } .lbtn.stage-elevators { background: #3fae95; } .lbtn.stage-rivets { background: #7a5ad6; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(10px * var(--s)); margin: 0; font-size: max(11px, calc(13px * var(--s))); }
.legend span::before { content: ""; display: inline-block; width: .9em; height: .9em; border-radius: 4px; margin-right: .35em; vertical-align: -.1em; }
.legend .stage-barrels::before { background: #e0658f; } .legend .stage-factory::before { background: #c98f6a; } .legend .stage-elevators::before { background: #3fae95; } .legend .stage-rivets::before { background: #7a5ad6; }

/* scores */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(8px * var(--s)); }
.tab {
  font: inherit;
  font-size: max(11px, calc(14px * var(--s)));
  padding: max(5px, calc(7px * var(--s))) max(10px, calc(14px * var(--s)));
  color: var(--lav);
  background: #fff;
  border: 2px solid #d9c9ff;
  border-radius: 999px;
  cursor: pointer;
}
.tab:hover, .tab:focus-visible { outline: none; border-color: var(--pink2); }
.tab.active { color: #fff; background: var(--pink); border-color: #fff; }
.score-wrap { min-height: calc(440px * var(--s)); }
table.scores { border-collapse: collapse; font-size: max(12px, calc(16px * var(--s))); min-width: calc(420px * var(--s)); background: #fff; border-radius: calc(14px * var(--s)); overflow: hidden; }
.scores th { color: var(--pink); padding: calc(7px * var(--s)) calc(12px * var(--s)); border-bottom: 2px solid #ffd6ea; }
.scores td { padding: calc(5px * var(--s)) calc(12px * var(--s)); font-weight: 500; }
.scores td:nth-child(3) { text-align: right; font-weight: 700; color: var(--lav); }
.scores tbody tr:nth-child(even) td { background: #fff6fa; }
.scores tbody tr:first-child td { color: var(--pink); font-weight: 700; }
.scores tr.hl td { background: #ffe066 !important; animation: blink 1s steps(2) infinite; }
.scores td.won { color: #2e9e6a; font-weight: 700; }
.status { font-size: max(11px, calc(14px * var(--s))); color: var(--lav); min-height: 1.2em; }
.status.bad, .saved.bad { color: #d6336c; }

/* game over */
.entry { display: flex; flex-direction: column; align-items: center; gap: calc(8px * var(--s)); color: var(--pink); }
.entry input {
  font: inherit;
  font-size: max(16px, calc(20px * var(--s)));
  width: max(170px, calc(240px * var(--s)));
  padding: calc(8px * var(--s)) calc(12px * var(--s));
  text-align: center;
  text-transform: uppercase;
  color: var(--lav);
  background: #fff;
  border: 3px solid #d9c9ff;
  border-radius: 999px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.entry input:focus { border-color: var(--pink2); }

@keyframes blink { 50% { opacity: .6; } }

.overlay { overflow-x: hidden; justify-content: safe center; }   /* tall content scrolls from the top instead of being cut off */


.compact .lbtn { height: calc(46px * var(--s)); }

@media (max-width: 520px) {
  .help-grid { grid-template-columns: 1fr; }
  #help.overlay { justify-content: flex-start; }
}

/* on-screen controls for touch screens */
#touchPad {
  position: absolute;
  left: 0; right: 0; bottom: calc(10px * var(--s));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(12px * var(--s));
  pointer-events: none;
}
#stage.touch.playing #touchPad { display: flex; }
#touchPad button {
  pointer-events: auto;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: rgba(122, 79, 214, .45);
  border: 2px solid rgba(255, 255, 255, .8);
  border-radius: 999px;
  width: max(46px, calc(64px * var(--s)));
  height: max(46px, calc(64px * var(--s)));
  font-size: max(14px, calc(20px * var(--s)));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#touchPad button.down { background: rgba(255, 93, 143, .75); }
#touchPad .pad-left { display: flex; align-items: center; gap: calc(6px * var(--s)); }
#touchPad .pad-col { display: flex; flex-direction: column; gap: calc(6px * var(--s)); }
#touchPad .jump { width: max(70px, calc(96px * var(--s))); height: max(70px, calc(96px * var(--s))); background: rgba(255, 93, 143, .55); }
