/* Claymation look: soft pastels, puffy rounded cards, no hard outlines. */
:root {
  --ink: #3a3340; --muted: #7a7180; --paper: #fff6ec; --card: #fffdf9;
  --peach: #ffd8be; --sky: #cfe9ff; --mint: #c9f0d6;
  --red: #e8655a; --blue: #5b9bd5; --green: #5cb85c; --orange: #f0a43a; --purple: #a77bd1; --yellow: #ffd23f;
  --clay-shadow: inset -5px -6px 10px rgba(60, 40, 30, .08), inset 5px 6px 10px rgba(255, 255, 255, .85), 0 10px 22px rgba(90, 60, 50, .16);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif; color: var(--ink);
  background: linear-gradient(170deg, var(--sky) 0%, #fdeedd 55%, var(--peach) 100%) fixed; display: flex; flex-direction: column;
}
.clay { background: var(--card); border-radius: 26px; box-shadow: var(--clay-shadow); }
.small { font-size: 14px; color: var(--muted); }
.foot { margin: 0; padding: 6px 16px 10px; text-align: center; font-size: 12px; color: var(--muted); }

/* Buttons: puffy and squishy */
.btn {
  font: inherit; font-weight: 600; font-size: 18px; color: #fff; background: var(--blue); border: 0; border-radius: 18px;
  padding: 10px 18px; cursor: pointer; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .15), inset 0 3px 0 rgba(255, 255, 255, .35), 0 6px 12px rgba(60, 40, 60, .18);
  transition: transform .12s cubic-bezier(.3, 1.8, .5, 1);
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(2px) scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.go { background: var(--green); font-size: 21px; }
.btn.repair { background: var(--orange); }
.btn.ff { background: var(--purple); }
.btn.pause { background: #9a93a0; }
.btn.ghost { background: #fff; color: var(--ink); }
.iconBtn { font-size: 22px; width: 44px; height: 44px; border: 0; border-radius: 16px; background: #fff; cursor: pointer; box-shadow: var(--clay-shadow); }
.iconBtn.off { opacity: .45; }

/* HUD */
header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px; }
.logo, .bigLogo { font-weight: 700; letter-spacing: .5px; color: var(--ink); }
.logo { font-size: 28px; }
.logo span, .bigLogo span { color: var(--red); }
.chip { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 20px; padding: 4px 14px; font-size: 18px; min-height: 44px; box-shadow: var(--clay-shadow); }
.jarChip { padding: 2px 12px 2px 6px; }
.jar { width: 34px; height: 40px; }
.jarChip.bump { animation: bump .35s cubic-bezier(.3, 1.8, .5, 1); }
.jarChip.drop { animation: drop .35s ease; }
#coinCount { font-size: 22px; }
.happyChip { flex: 1 1 160px; max-width: 280px; }
#face { font-size: 26px; }
.meter { flex: 1; height: 16px; border-radius: 10px; background: #eee6e1; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .12); }
.meter i { display: block; height: 100%; width: 70%; border-radius: 10px; background: var(--green); transition: width .4s, background .4s; }
.hudBtns { display: flex; gap: 8px; margin-left: auto; }
@keyframes bump { 50% { transform: scale(1.18) rotate(-4deg); } }
@keyframes drop { 30% { transform: translateY(4px) scale(.94); } }

.screen { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; }
.view canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }

/* Title */
#title { display: flex; align-items: center; justify-content: center; padding: 16px; }
.titleCard { width: 100%; max-width: 480px; padding: 28px 24px; text-align: center; animation: popIn .6s cubic-bezier(.3, 1.6, .5, 1); }
.bigLogo { font-size: 58px; line-height: 1; animation: wobble 3s ease-in-out infinite; }
.tag { font-size: 19px; color: var(--muted); margin: 8px 0 4px; }
.fran.big { font-size: 84px; animation: hop 1.6s ease-in-out infinite; }
#nameForm { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
#nameForm label { font-size: 22px; font-weight: 600; }
#nameInput { font: inherit; font-size: 24px; text-align: center; padding: 12px; border: 0; border-radius: 18px; background: #f5efe9; box-shadow: inset 0 3px 8px rgba(0, 0, 0, .1); color: var(--ink); }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.04); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scaleY(1); } 40% { transform: translateY(-14px) scaleY(1.06); } 55% { transform: translateY(0) scaleY(.9); } }

/* Map */
#mapScreen { min-height: 420px; }
.mapHint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); padding: 6px 16px; font-size: 16px; white-space: nowrap; }
#siteCard { position: absolute; right: 16px; bottom: 16px; width: min(380px, calc(100% - 32px)); padding: 16px 18px; animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1); }
#siteCard h2 { margin: 0; font-size: 26px; }
#siteCard .region { color: var(--muted); margin: 0 0 8px; }
#siteCard ul { margin: 6px 0 12px; padding-left: 0; list-style: none; }
#siteCard li { padding: 2px 0; }
#siteCard .close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; cursor: pointer; }

/* Play */
#play { display: flex; flex-wrap: wrap; gap: 14px; padding: 0 16px 8px; align-items: flex-start; }
.stageCol { flex: 3 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel { flex: 2 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage { position: relative; height: min(56vh, 520px); min-height: 300px; overflow: hidden; background: linear-gradient(180deg, #d7eeff, #fff3e6); }
#banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; border-radius: 18px; padding: 8px 16px; font-size: 19px; font-weight: 600; text-align: center; max-width: 86%; animation: pulse .5s infinite alternate; box-shadow: 0 6px 14px rgba(0, 0, 0, .2); }
@keyframes pulse { to { transform: translateX(-50%) scale(1.07) rotate(-1deg); } }
.pill { position: absolute; top: 12px; right: 12px; background: #fff; border-radius: 16px; padding: 4px 12px; font-weight: 600; box-shadow: var(--clay-shadow); }
.pill:empty { display: none; }
.iconBtn.peek { position: absolute; left: 12px; bottom: 12px; }
.iconBtn.peek.on { background: var(--yellow); }
#fixPop { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); font-size: 22px; animation: bounce .7s infinite; }
@keyframes bounce { 50% { transform: translateX(-50%) translateY(-8px) scale(1.06); } }
/* People's speech bubbles: float over their heads in the 3D view (placed each frame by main.js) */
.talkLayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.talk {
  --bg: #fff; position: absolute; left: 0; top: 0; background: var(--bg); color: var(--ink); border-radius: 16px;
  padding: 5px 11px; font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap; transform-origin: 50% 100%;
  box-shadow: inset -2px -3px 5px rgba(60, 40, 30, .08), inset 2px 2px 4px rgba(255, 255, 255, .8), 0 5px 12px rgba(90, 60, 50, .22);
  animation: talkPop .35s cubic-bezier(.3, 1.8, .5, 1); will-change: transform;
}
.talk::after { content: ""; position: absolute; left: calc(50% + var(--tail, 0px)); bottom: -9px; margin-left: -7px; border: 7px solid transparent; border-top: 10px solid var(--bg); border-bottom: 0; }
.talk.bad { --bg: #ffe1dc; }
.talk.good { --bg: #dcf5e3; }
.talk.ghost { --bg: #eef0ff; color: #6b6f8f; font-style: italic; }
.talk.bye { opacity: 0; transition: opacity .25s; }
@keyframes talkPop { from { scale: .4; opacity: 0; } }
.status { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#phase { flex: 1; font-size: 19px; font-weight: 600; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.mo { border-radius: 10px; text-align: center; font-size: 12px; padding: 3px 0; background: #f3ece6; min-height: 42px; }
.mo .ev { display: block; font-size: 17px; }
.mo.past { background: var(--mint); }
.mo.now { background: var(--yellow); transform: scale(1.08); transition: transform .2s; }
.mascot { display: flex; gap: 12px; align-items: center; padding: 10px 14px; }
.fran { font-size: 48px; line-height: 1; }
.bubble { flex: 1; background: #fff8dc; border-radius: 18px; padding: 10px 14px; font-size: 17px; position: relative; min-height: 48px; }
.bubble::before { content: ""; position: absolute; left: -12px; top: 16px; border: 8px solid transparent; border-right: 12px solid #fff8dc; border-left: 0; }
.bubble.new { animation: talk .35s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes talk { from { transform: scale(.94); } }

/* Design panel: every section on one screen */
.cash { padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 15px; }
.cash .step { background: #f5efe9; border-radius: 12px; padding: 3px 9px; }
.cash .step b { font-size: 17px; }
.cash .arrow { color: var(--muted); }
.cash .left { background: var(--mint); }
.cash .left.neg { background: #ffd2cc; color: #b3261e; }
.checks { padding: 10px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 12px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 6px; }
.check .bars { display: flex; gap: 2px; }
.check .bars i { width: 12px; height: 12px; border-radius: 4px; background: #e6dfd9; }
.check .bars i.on { background: var(--green); }
.check .bars i.need { outline: 2px dashed var(--red); outline-offset: -2px; }
.check.ok .what::after { content: " ✅"; }
.check.bad .what::after { content: " ⚠️"; }
.secGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.section { padding: 6px 10px 8px; border-left: 7px solid var(--c); min-width: 0; }
.section.wide { grid-column: 1 / -1; }
.section h3 { margin: 0 0 2px; font-size: 15px; }
.item { padding: 2px 0; }
.section.wide .item { display: grid; grid-template-columns: 84px 1fr; gap: 6px; align-items: center; }
.item .nm { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.opts { display: flex; gap: 5px; }
.opt {
  font: inherit; font-size: 12px; flex: 1 1 0; min-width: 0; border: 0; border-radius: 12px; padding: 4px 6px; background: #f5efe9; cursor: pointer; color: var(--ink);
  display: flex; align-items: center; gap: 5px; text-align: left; line-height: 1.15; transition: transform .15s cubic-bezier(.3, 1.8, .5, 1);
}
.opt:hover { transform: translateY(-2px); }
.opt.sel { background: #fff; box-shadow: 0 0 0 3px var(--c), 0 5px 10px rgba(0, 0, 0, .12); transform: scale(1.03); }
.opt { min-height: 38px; }
.opt .ico { font-size: 19px; }
.opt .lb { flex: 1; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.section:not(.wide) .opt { flex-wrap: wrap; gap: 0 4px; padding: 4px 5px; }
.section:not(.wide) .opt .cost { font-size: 11px; }
.opt .cost { font-weight: 700; color: #b8860b; white-space: nowrap; }
.topCard .checks { border-top: 2px dashed #eee6e1; padding-top: 8px; }
.legend { margin: 0 4px; font-size: 12px; color: var(--muted); }
.fxline { white-space: nowrap; font-size: 15px; }
.health .fixes { padding: 6px 0 2px; }
@media (min-width: 1000px) and (min-height: 680px) {
  #play { height: calc(100vh - 92px); overflow: hidden; }
  .stageCol, .panel { max-height: 100%; }
  .stageCol { height: 100%; }
  .panel { overflow: auto; padding: 4px; }
  .stage { flex: 1; height: auto; }
}

/* Run panel */
.runStats { padding: 10px 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.runStats div { background: #f5efe9; border-radius: 14px; padding: 6px 2px; font-size: 13px; }
.runStats b { display: block; font-size: 22px; }
.health { padding: 10px 12px; }
.health .meter i { background: var(--green); }
.fixes { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.fixes h3, .logBox h3 { margin: 0; font-size: 17px; }
.fixes .btn { font-size: 16px; text-align: left; }
.logBox { padding: 10px 12px; max-height: 220px; overflow: auto; }
.logBox ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.logBox li:first-child { font-weight: 600; }

/* Overlays: brief, report card, game over */
.overlay { position: fixed; inset: 0; background: rgba(58, 51, 64, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 20px 22px; animation: popIn .45s cubic-bezier(.3, 1.6, .5, 1); }
.sheet h2 { margin: 0 0 6px; }
.sheet .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.brief .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.brief .facts div { background: #f5efe9; border-radius: 14px; padding: 8px 10px; }
.brief .facts b { display: block; }
.brief .profile { display: flex; flex-direction: column; height: 140px; margin-top: 8px; border-radius: 10px; overflow: hidden; border: 2px solid #d8ccc0; }
.brief .profile span { display: flex; align-items: center; min-height: 16px; padding: 0 8px; font-size: 12px; font-weight: 600; }

.report { background: repeating-linear-gradient(#fffdf6 0 31px, #d7e6f5 31px 32px); font-family: "Fredoka", sans-serif; position: relative; }
.report .school { text-align: center; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); font-size: 13px; }
.report h2 { text-align: center; font-size: 28px; }
.report .who { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid #e1d6cc; padding-bottom: 6px; }
.report table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.report td { padding: 6px 4px; border-bottom: 1px dashed #d8ccc0; font-size: 16px; }
.report td.g { text-align: center; width: 64px; }
.report .gr { display: inline-block; min-width: 44px; font-size: 22px; font-weight: 700; color: #c62828; border: 3px solid #c62828; border-radius: 50%; padding: 2px 6px; transform: rotate(-6deg); }
.gradeRow { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 6px 0; }
.stamp { font-size: 64px; font-weight: 700; color: #c62828; border: 6px solid #c62828; border-radius: 22px; padding: 0 14px; transform: rotate(12deg); animation: stamp .6s cubic-bezier(.3, 1.8, .5, 1) .3s both; background: rgba(255, 255, 255, .7); }
@keyframes stamp { from { transform: rotate(40deg) scale(3); opacity: 0; } }
.stars { text-align: center; font-size: 40px; letter-spacing: 6px; }
.stars span { display: inline-block; animation: popIn .4s cubic-bezier(.3, 1.8, .5, 1) both; }
.comment { background: #fff8dc; border-radius: 16px; padding: 10px 14px; margin-top: 8px; }
.unlock { text-align: center; font-size: 20px; font-weight: 600; color: #2e7d32; margin: 8px 0 0; animation: wobble 1.2s ease-in-out infinite; }

.linkBtn { font: inherit; font-size: 15px; margin-top: 10px; border: 0; background: none; color: var(--blue); cursor: pointer; text-decoration: underline; }
.about .event { font-size: 18px; text-align: center; background: #fff8dc; border-radius: 14px; padding: 8px; }
.about .team { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.about .team li { background: #f5efe9; border-radius: 14px; padding: 8px 12px; display: flex; flex-direction: column; }
.about .team span { color: var(--muted); font-size: 14px; }
.about .team a { color: var(--blue); font-size: 14px; }

.gameover { text-align: center; background: #2f2a36; color: #fff; }
.gameover h2 { font-size: 56px; margin: 6px 0; color: var(--yellow); }
.gameover h2 span { display: inline-block; animation: jiggle .9s ease-in-out infinite; }
.gameover .big { font-size: 72px; }
.gameover ul { text-align: left; }
.gameover .comment { color: var(--ink); text-align: left; }
@keyframes jiggle { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-10px) rotate(-8deg); } 75% { transform: translateY(6px) rotate(8deg); } }

body.quake #play .stage { animation: quake .12s infinite; }
@keyframes quake { 25% { transform: translate(-4px, 2px) rotate(-.4deg); } 75% { transform: translate(4px, -2px) rotate(.4deg); } }

.flycoin { position: fixed; z-index: 60; font-size: 22px; pointer-events: none; transition: transform .7s cubic-bezier(.5, -0.3, .7, 1), opacity .7s; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

@media (max-width: 700px) {
  header { padding: 8px 16px; gap: 6px; }
  .logo { font-size: 22px; }
  .chip { font-size: 15px; padding: 2px 10px; min-height: 40px; }
  .hudBtns { margin-left: 0; }
  #play { padding: 0 16px 8px; }
  .stage { height: 44vh; }
  .secGrid { grid-template-columns: 1fr; }
  .section.wide .item { grid-template-columns: 1fr; }
  .mo { font-size: 10px; }
  .stamp { font-size: 44px; }
  .bigLogo { font-size: 44px; }
  .talk { font-size: 13px; padding: 4px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .talk { animation: none; }
}
