/* Shared with Back It In! (TT-GAME/style.css): page, overlay menus, top buttons, title card. Keep in sync. */
/* Fill the iframe or window, never scroll or zoom the host page. */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2b3a2c;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The playfield. main.js letterboxes it if the frame is extremely wide or tall. */
#stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
/* ---------- Menu overlay (tip card, results, level select) ---------- */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 34px 16px 16px; /* room for the ribbon on tall cards */
  box-sizing: border-box;
  background: rgba(20, 28, 34, 0.45);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  color: #26313a;
  overflow-y: auto;
}
#overlay[hidden] { display: none; }

#overlay .card {
  position: relative;
  margin: auto; /* centers when it fits, scrolls from the top when it doesn't */
  flex-shrink: 0;
  width: min(460px, 100%);
  background: #fffaf0;
  border: 4px solid #26313a;
  border-radius: 24px;
  padding: 44px 28px 18px;
  text-align: center;
  box-shadow: 0 8px 0 #26313a;
  box-sizing: border-box;
}
#overlay .card.wide { width: min(760px, 100%); }

/* Ribbon banner title */
#overlay .ribbon {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #f28c28;
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.5px;
  padding: 8px 34px;
  white-space: nowrap;
  border: 4px solid #26313a;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%, 14px 50%);
}
#overlay .ribbon.win { background: #3fae55; }
#overlay .ribbon.lose { background: #e5483b; }

#overlay h1 { margin: 4px 0 8px; font-size: 26px; font-weight: 900; }
#overlay h2 { margin: 18px 0 8px; font-size: 17px; font-weight: 800; text-align: left; color: #4a5866; }
#overlay .tip { font-size: 18px; font-weight: 600; line-height: 1.35; margin: 6px 0 14px; }
#overlay .par { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: 15px; color: #4a5866; }
#overlay .best { margin-top: 10px; font-size: 15px; color: #4a5866; display: flex; gap: 8px; justify-content: center; align-items: center; }
#overlay .hint { margin: 12px 0 0; font-size: 13px; color: #8a96a0; }
#overlay .note { margin: 8px 0 0; font-size: 14px; color: #8a6a20; font-weight: 700; }
#overlay .note.good { color: #2f8f45; }

#overlay .buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
#overlay .btn {
  min-width: 120px;
  min-height: 56px;
  padding: 0 22px;
  font: inherit;
  font-size: 19px;
  font-weight: 900;
  color: #26313a;
  background: #fff;
  border: 4px solid #26313a;
  border-radius: 16px;
  box-shadow: 0 5px 0 #26313a;
  cursor: pointer;
}
#overlay .btn.primary { background: #f28c28; color: #fff; }
#overlay .btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #26313a; }
#overlay .btn:disabled { opacity: 0.45; cursor: default; }
#overlay .btn:focus-visible { outline: 3px solid #3fe0ff; outline-offset: 2px; }

#overlay .stars { display: flex; gap: 6px; justify-content: center; }
#overlay .stars.big { font-size: 54px; margin: 4px 0 6px; }
#overlay .stars.small { font-size: 18px; gap: 2px; }
#overlay .star { color: #d8d2c4; line-height: 1; }
#overlay .star.on { color: #f2c230; text-shadow: 0 2px 0 #b8860b; }

#overlay table.stats { margin: 8px auto 0; border-collapse: collapse; font-size: 18px; }
#overlay table.stats td { padding: 4px 12px; text-align: left; }
#overlay table.stats td.ok { color: #2f8f45; font-weight: 900; }
#overlay table.stats td.miss { color: #c0392b; font-weight: 900; }
#overlay table.stats td.parcol { color: #8a96a0; font-size: 15px; }

#overlay .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
#overlay .level {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 84px;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: #26313a;
  background: #fff;
  border: 3px solid #26313a;
  border-radius: 14px;
  box-shadow: 0 4px 0 #26313a;
  cursor: pointer;
}
#overlay .level .num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #26313a;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
}
#overlay .level .name { font-weight: 800; font-size: 16px; }
#overlay .level.locked { opacity: 0.5; cursor: default; }
#overlay .level:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #26313a; }

/* Debug level jump menu (?debug=1) */
#debugJump {
  position: fixed;
  top: 64px;
  left: 14px;
  z-index: 5;
  font: 13px ui-monospace, Consolas, monospace;
  padding: 4px;
}

/* Results / fail sit low so the parked rig stays visible */
#overlay.low { background: rgba(20, 28, 34, 0.2); padding-bottom: 24px; }
#overlay.low .card { margin: auto auto 0; }
#overlay.title { background: rgba(20, 28, 34, 0.35); }

#overlay .card.narrow { width: min(340px, 100%); }
#overlay .menu { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
#overlay .menu .row { display: flex; gap: 12px; }
#overlay .menu .row .btn { flex: 1; min-width: 0; }
#overlay .btn small { font-size: 12px; font-weight: 700; opacity: 0.7; }
#overlay .btn.danger { background: #e5483b; color: #fff; }
#overlay .rig { margin: -4px 0 6px; font-size: 15px; font-weight: 700; color: #8a6a20; }
#overlay .rules { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
#overlay .rules span { background: #ffe6c7; color: #8a4b0f; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 800; }
#overlay h2 small { display: block; font-size: 13px; font-weight: 600; color: #8a96a0; }
#overlay .select-head { text-align: right; font-weight: 900; color: #b8860b; margin-top: -10px; }

/* Title card */
#overlay .title-card { width: min(420px, 100%); padding-top: 28px; }
#overlay .logo { line-height: 0.9; margin: 6px 0 4px; }
#overlay .logo-top { font-size: 30px; font-weight: 900; letter-spacing: 4px; color: #26313a; }
#overlay .logo-big {
  font-size: 92px;
  font-weight: 900;
  color: #f28c28;
  text-shadow: 0 5px 0 #26313a;
  -webkit-text-stroke: 3px #26313a;
}
#overlay .tagline { margin: 10px 0 14px; font-size: 15px; font-weight: 600; color: #4a5866; }
#overlay .icon-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  font-size: 22px;
  background: #fff;
  border: 3px solid #26313a;
  border-radius: 14px;
  cursor: pointer;
}

/* Settings */
#overlay .settings .setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 2px dashed #e6dccb;
  text-align: left;
}
#overlay .settings .label { font-weight: 800; font-size: 16px; }
#overlay .settings .label small { display: block; font-weight: 600; font-size: 12px; color: #8a96a0; }
#overlay .seg { display: flex; flex-shrink: 0; border: 3px solid #26313a; border-radius: 12px; overflow: hidden; }
#overlay .seg-btn {
  min-height: 44px;
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: #26313a;
  background: #fff;
  border: 0;
  border-left: 3px solid #26313a;
  cursor: pointer;
}
#overlay .seg-btn:first-child { border-left: 0; }
#overlay .seg-btn.on { background: #f28c28; color: #fff; }
@media (max-width: 560px) {
  #overlay .settings .setting { flex-direction: column; align-items: stretch; }
  #overlay .seg { justify-content: stretch; }
  #overlay .seg-btn { flex: 1; }
}

/* ---------- Top bar buttons (pause, zoom, guide, fullscreen, rig) ---------- */
#topbtns {
  position: absolute;
  top: 8px;
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 2;
}
#topbtns[hidden] { display: none; }
#topbtns .hbtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #dfe6eb;
  background: #3a464f;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  touch-action: none;
}
#topbtns .hbtn[hidden] { display: none; }
#topbtns .hbtn svg { width: 22px; height: 22px; }
#topbtns .hbtn .g { font: 900 18px ui-rounded, "Segoe UI", system-ui, sans-serif; }
#topbtns .hbtn.on { color: #26313a; background: #f2c230; }
#topbtns .hbtn.pause { color: #fff; background: #f28c28; }
#topbtns .hbtn:active { transform: translateY(1px); filter: brightness(0.9); }
#topbtns.touch { top: 4px; }
#topbtns.touch .hbtn { width: 56px; height: 56px; border-radius: 14px; }
#topbtns.touch .hbtn svg { width: 28px; height: 28px; }
/* ---------- GreetRV brand: title lockup ---------- */
#overlay.title { background: rgba(31, 58, 39, 0.82); }
#overlay .title-card {
  width: min(460px, 100%);
  background: #fbf3e6;
  border-color: #1d1a15;
  box-shadow: 0 8px 0 #1d1a15;
  padding-top: 22px;
}
#overlay .presents { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 10px; }
#overlay .presents img { width: 144px; height: auto; }
#overlay .presents span { font: 800 12px/1 ui-rounded, "Segoe UI", system-ui, sans-serif; letter-spacing: 3px; color: #6b5f4a; }
#overlay .lockup { display: flex; align-items: center; justify-content: center; gap: 16px; }
#overlay .app-icon { width: 112px; height: 112px; flex-shrink: 0; }
#overlay .wordmark { text-align: left; line-height: 0.86; }
#overlay .wordmark .w1, #overlay .wordmark .w2 {
  font-family: "Arial Black", "Segoe UI Black", ui-rounded, system-ui, sans-serif;
  font-weight: 900;
  letter-spacing: -2px;
}
#overlay .wordmark .w1 { font-size: 54px; color: #1d1a15; }
#overlay .wordmark .w2 { font-size: 64px; color: #c54818; }
#overlay .tagline { margin: 14px 0 14px; font-size: 16px; font-weight: 700; color: #3b3c37; }
#overlay .tag-stars { color: #f6a146; letter-spacing: 2px; -webkit-text-stroke: 0.6px #6b4a1a; }
#overlay .title-card .btn.primary { background: #c54818; }
@media (max-width: 420px) {
  #overlay .app-icon { width: 84px; height: 84px; }
  #overlay .wordmark .w1 { font-size: 40px; }
  #overlay .wordmark .w2 { font-size: 48px; }
}

/* ---------- Results: stars pop in ---------- */
#overlay .stars.pop .star.on { animation: star-pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
#overlay .stars.pop .star.on:nth-child(1) { animation-delay: 0.25s; }
#overlay .stars.pop .star.on:nth-child(2) { animation-delay: 0.53s; }
#overlay .stars.pop .star.on:nth-child(3) { animation-delay: 0.81s; }
@keyframes star-pop {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

/* ---------- Garage ---------- */
#overlay .garage .preview { display: flex; align-items: center; justify-content: center; gap: 8px; }
#overlay .garage canvas {
  width: min(560px, 100%);
  height: auto;
  aspect-ratio: 560 / 220;
  min-width: 0;
  flex: 1;
  background: #4a5059;
  border: 3px solid #26313a;
  border-radius: 14px;
}
#overlay .nav-btn {
  flex-shrink: 0;
  width: 48px;
  height: 56px;
  font: 900 32px/1 ui-rounded, system-ui, sans-serif;
  color: #26313a;
  background: #fff;
  border: 3px solid #26313a;
  border-radius: 12px;
  cursor: pointer;
}
#overlay .swatches { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
#overlay .swatch {
  width: 44px;
  height: 44px;
  background: var(--c);
  border: 3px solid #26313a;
  border-radius: 50%;
  cursor: pointer;
}
#overlay .swatch.on { outline: 4px solid #f28c28; outline-offset: 2px; }
#overlay .paint-name { margin: 8px 0 0; font-weight: 800; color: #4a5866; }
