/* Swept Away: crayon-and-paper menus over a photo floor */
/* Gochi Hand (SIL Open Font License), kept with the game so it works offline and asks no other site */
@font-face { font-family: "Gochi Hand"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/gochi-hand.woff2") format("woff2"); }
:root {
  --paper: #fff7e0;
  --ink: #3a2a22;
  --sun: #ffd23a;
  --red: #e8343a;
  --teal: #2bb3c0;
  --card: #fffdf6;
  --font: "Gochi Hand", "Comic Sans MS", "Chalkboard SE", cursive;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c99a5b; font-family: var(--font); color: var(--ink); }
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: var(--font); color: var(--ink); cursor: pointer; touch-action: manipulation; }

/* top bar */
#hud[hidden] { display: none; }
#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: linear-gradient(rgba(255, 247, 224, 0.95), rgba(255, 247, 224, 0.85));
  border-bottom: 3px solid var(--ink);
}
.btn {
  width: 44px; height: 44px; flex: none; font-size: 22px; line-height: 1;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--wobble);
  box-shadow: 2px 3px 0 rgba(58, 42, 34, 0.35);
}
.btn:active { transform: translate(1px, 2px); box-shadow: 0 1px 0 rgba(58, 42, 34, 0.35); }
#jobBox { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; align-self: stretch; }
#jobName { font-size: 20px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar { display: block; height: 10px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; overflow: hidden; }
#bar[hidden] { display: none; }
#bar b { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--teal), #6fe0a0); transition: transform 0.2s; }
#coins { font-size: 20px; white-space: nowrap; flex: none; }
.bin { width: 56px; height: 66px; padding: 0; position: relative; display: grid; place-items: center; }
#binCv { width: 46px; height: 58px; display: block; }
#binTxt { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); font-size: 14px; background: var(--sun); border: 2px solid var(--ink); border-radius: 8px; padding: 0 4px; line-height: 1.1; white-space: nowrap; }
.bin.full { animation: shake 0.4s 8; border-color: var(--red); }
.bin.full #binTxt { background: var(--red); color: #fff; }
.bin.dumping { animation: tip 0.7s ease-in-out; }
.bin.gulp { animation: gulp 0.14s ease-out; }
@keyframes gulp { 50% { transform: scale(1.1) translateY(1px); } }
#binTap {
  position: absolute; right: calc(max(8px, env(safe-area-inset-right)) + 62px); top: calc(env(safe-area-inset-top) + 74px);
  font-size: 20px; padding: 2px 10px; background: var(--red); color: #fff; border: 3px solid var(--ink); border-radius: var(--wobble);
  animation: nudge 0.6s ease-in-out 8; pointer-events: none; white-space: nowrap;
}
#binTap[hidden] { display: none; }
@keyframes nudge { 50% { transform: translate(6px, -4px); } }
@keyframes shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes tip { 40% { transform: rotate(-35deg) translateY(4px); } 100% { transform: none; } }

/* free-vacuum spill buttons */
#zenBar {
  position: absolute; z-index: 2; left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + 78px);
  display: flex; gap: 6px; align-items: center;
  padding: 4px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: rgba(255, 247, 224, 0.8); border-bottom: 2px solid var(--ink);
}
#zenBar[hidden] { display: none; }
#zenChips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; flex: 1; }
#zenChips::-webkit-scrollbar { display: none; }
.chip { flex: none; width: 42px; height: 42px; padding: 3px; border: 2px solid var(--ink); border-radius: 12px; background: var(--card); display: grid; place-items: center; font-size: 20px; }
.chip:active { transform: scale(0.9); }
.chip img, .chip canvas { width: 100%; height: 100%; object-fit: contain; }
.dot { display: block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); background-image: radial-gradient(rgba(0,0,0,0.25) 1.5px, transparent 2px); background-size: 6px 6px; }

#toast {
  position: absolute; z-index: 3; left: 50%; top: calc(env(safe-area-inset-top) + 92px); transform: translate(-50%, -10px);
  font-size: 24px; padding: 6px 18px; background: var(--card); border: 3px solid var(--ink); border-radius: var(--wobble);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; text-align: center; max-width: 90vw;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* screens */
.overlay {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) max(12px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(12px, env(safe-area-inset-left));
  background: rgba(58, 42, 34, 0.35); overflow-y: auto; touch-action: pan-y;
}
.overlay.hidden { display: none; }
.card-big {
  width: min(420px, 100%); text-align: center; padding: 18px 18px 14px;
  background: var(--paper); border: 4px solid var(--ink); border-radius: var(--wobble);
  box-shadow: 5px 7px 0 rgba(58, 42, 34, 0.35);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.logo { width: 110px; height: 110px; margin: 0 auto; border-radius: 26px; border: 3px solid var(--ink); animation: wiggle 2.4s ease-in-out 3; }
h1 { font-size: clamp(44px, 12vw, 60px); line-height: 1; margin: 2px 0; color: var(--red); -webkit-text-stroke: 1.5px var(--ink); }
h2 { font-size: 36px; margin: 0; line-height: 1.05; }
.card-big p { font-size: 20px; margin: 0; line-height: 1.25; }
.card-big button { font-size: 22px; padding: 8px 12px; background: var(--card); border: 3px solid var(--ink); border-radius: var(--wobble); box-shadow: 2px 3px 0 rgba(58, 42, 34, 0.35); }
.card-big button:active { transform: translate(1px, 2px); box-shadow: none; }
.card-big button.big { font-size: 26px; background: var(--sun); }
.card-big button.big.alt { background: #9be3e8; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; min-width: 0; }
.row.small button { font-size: 18px; padding: 4px 6px; }
.coins { font-size: 22px !important; }
.tip { font-size: 16px !important; opacity: 0.7; }
.stars { font-size: 56px; color: #ffb400; -webkit-text-stroke: 2px var(--ink); letter-spacing: 4px; line-height: 1; min-height: 56px; }
.stars span { display: inline-block; animation: starpop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.stars span.not { color: #e6dcc4; }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.tally { font-size: 18px !important; opacity: 0.85; }

.panel {
  width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 5px 7px 0 rgba(58, 42, 34, 0.35);
  overflow: hidden;
}
.panel header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 3px solid var(--ink); }
.panel header h2 { flex: 1; font-size: 30px; }
.panel header span { font-size: 20px; }
.panel .sub { margin: 8px 12px 0; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 12px; overflow-y: auto; touch-action: pan-y; }
.card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; text-align: center; }
.card.on { background: #e5f9e0; }
.card img { height: 110px; width: 100%; object-fit: contain; }
.card .bigicon { font-size: 70px; line-height: 110px; }
.card b { font-size: 22px; line-height: 1; }
.card .about { font-size: 16px; line-height: 1.15; flex: 1; }
.stats { width: 100%; display: grid; gap: 2px; }
.stat { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 4px; font-size: 14px; text-align: left; }
.stat i { display: block; height: 8px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
.stat b { display: block; height: 100%; background: var(--teal); font-size: 0; }
.card .buy { font-size: 20px; padding: 4px 14px; background: var(--sun); border: 3px solid var(--ink); border-radius: var(--wobble); }
.card .buy:disabled { background: #eee; opacity: 0.7; cursor: default; }
.snd { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; }
.snd img { width: 56px; height: 56px; object-fit: contain; }
.snd .pile { width: 56px; height: 56px; }
.snd b { font-size: 20px; line-height: 1; }
.snd span { font-size: 14px; opacity: 0.75; }
.snd.hit { animation: bop 0.3s; }
@keyframes bop { 40% { transform: scale(0.92) rotate(-3deg); } }
@keyframes wiggle { 50% { transform: rotate(-5deg) scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .logo, .bin.full { animation: none; } }
@media (max-height: 700px) { .logo { width: 80px; height: 80px; } .card-big { gap: 7px; padding: 12px; } .card-big p { font-size: 18px; } }
/* sideways phones: menu in two columns, slimmer top bar */
@media (orientation: landscape) and (max-height: 500px) {
  #menu .card-big { width: min(720px, 100%); display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: center; }
  #menu .card-big > .logo, #menu .card-big > h1, #menu .card-big > p:first-of-type { grid-column: 1; }
  #menu .card-big > :not(.logo):not(h1):not(p:first-of-type) { grid-column: 2; }
  #menu .logo { width: 64px; height: 64px; grid-row: 1; }
  #menu h1 { font-size: 40px; grid-row: 2; }
  #menu .card-big > p:first-of-type { grid-row: 3 / span 4; align-self: start; }
  .bin { width: 46px; height: 52px; } #binCv { width: 38px; height: 46px; }
  #jobName { font-size: 16px; }
  .chip { width: 36px; height: 36px; }
}
@media (max-width: 360px) { #coins { font-size: 16px; } #jobName { font-size: 17px; } }
