:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  --ink: #14385a;
  --sky: #08a9e8;
  --yellow: #ffd632;
  --orange: #ff8a1d;
  --green: #4fc44b;
  --cream: #fff8dc;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  display: grid;
  place-items: center;
  background: #06283f;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
button, a { font: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { border: 0; }

.game-shell {
  position: relative;
  width: min(100vw, 500px);
  height: 100dvh;
  max-height: 980px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(#03a9ed, #9ceaff 62%, #ffe47a);
  box-shadow: 0 0 46px #0008;
}
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: flex; }
.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid #fff9;
  border-radius: 50%;
  color: #fff;
  background: #123f61a8;
  box-shadow: 0 4px 10px #06314c45, inset 0 1px #ffffff70;
  text-decoration: none;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.round-button:active { transform: scale(.91); }
.signature { margin: 7px 0 0; color: #6f5124; font: 700 10px/1.1 Georgia, serif; text-align: center; }
.eyebrow { margin: 0; letter-spacing: .14em; font-size: 10px; font-weight: 900; }

/* Start screen */
.menu-screen { flex-direction: column; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom)); }
.menu-art, .menu-shade { position: absolute; inset: 0; z-index: -2; }
.menu-art { background: url("../../assets/game-art/banana-jump-menu.webp") center/cover no-repeat; transform: scale(1.015); }
.menu-shade {
  z-index: -1;
  background: linear-gradient(180deg, #0069a91e 0%, transparent 38%, transparent 61%, #00482a1f 72%, #04251ca8 100%);
}
.menu-top { display: flex; justify-content: space-between; }
.title-lockup { position: absolute; left: 18px; right: 18px; top: 76px; text-align: center; color: #fff; text-shadow: 0 3px 0 #075884, 0 6px 13px #00467c73; }
.title-lockup .eyebrow { margin-bottom: 4px; }
.title-lockup h1 { margin: 0; line-height: .78; font-size: clamp(48px, 14vw, 74px); letter-spacing: -.07em; transform: rotate(-2deg); }
.title-lockup h1 span { display: block; color: var(--yellow); -webkit-text-stroke: 2px #b96813; text-shadow: 0 4px 0 #df851a, 0 8px 0 #91500d, 0 11px 18px #014f7c99; }
.title-lockup h1 { color: #fffdf0; -webkit-text-stroke: 2px #0874a4; }
.title-lockup > p:last-child { margin: 12px 0 0; font-size: 12px; font-weight: 900; letter-spacing: .02em; }
.menu-card {
  padding: 12px 13px 10px;
  border: 2px solid #fffbd4;
  border-radius: 23px;
  background: linear-gradient(145deg, #fffdebfa, #fff2b8f5);
  box-shadow: 0 9px 0 #815321, 0 15px 28px #052d2966, inset 0 2px #fff;
}
.menu-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #6f4a19; font-size: 11px; letter-spacing: .1em; }
.menu-heading span { padding: 3px 8px; border-radius: 99px; color: #fff; background: #22a95b; letter-spacing: 0; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 9px; }
.level-button {
  position: relative;
  height: 39px;
  border: 1px solid #dfb755;
  border-radius: 11px;
  color: #70451b;
  background: linear-gradient(#fffbe1, #f5cd65);
  box-shadow: 0 3px 0 #b27927, inset 0 1px #fff;
  font-weight: 900;
  cursor: pointer;
}
.level-button.selected { color: #fff; background: linear-gradient(#64da60, #2cab4e); box-shadow: 0 3px 0 #147533, 0 0 0 3px #fff6a4; transform: translateY(-1px); }
.level-button.locked { color: #8e835f; filter: saturate(.2); opacity: .62; }
.level-button.completed::after { content: "✓"; position: absolute; right: 3px; top: 2px; color: #168d43; font-size: 9px; }
.primary-button {
  width: 100%;
  min-height: 50px;
  border: 2px solid #fff8a8;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(#ffb831, #f36d17);
  box-shadow: 0 5px 0 #a7400d, 0 7px 14px #9a52114d, inset 0 2px #ffe995;
  text-shadow: 0 2px 0 #a9440c;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: .04em;
  cursor: pointer;
}
.primary-button:active { transform: translateY(3px) scale(.985); box-shadow: 0 2px 0 #a7400d; }
.menu-tip { margin: 8px 4px 0; color: #745624; font-size: 10px; line-height: 1.25; text-align: center; }

/* Play screen */
.play-screen { flex-direction: column; background: #5fdcff; }
.game-header {
  display: grid;
  grid-template-columns: 43px 1fr 43px;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: max(7px, env(safe-area-inset-top)) 11px 5px;
  color: #fff;
  background: linear-gradient(180deg, #048fc8, #06b4e7);
  box-shadow: 0 3px 0 #0577a6;
  z-index: 5;
}
.game-header .round-button { width: 40px; height: 40px; }
.level-title { min-width: 0; text-align: center; text-shadow: 0 2px #087099; }
.level-title small { display: block; font-size: 8px; letter-spacing: .16em; }
.level-title strong { display: block; overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.score-hud { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 6px; padding: 7px 10px 4px; background: #fff4c2; }
.score-hud > div { min-width: 0; padding: 5px 8px; border: 1px solid #f1c757; border-radius: 12px; text-align: center; background: #fffdf0; box-shadow: 0 2px 0 #dfaa3d; }
.score-hud small { display: block; color: #8d6b32; font-size: 8px; letter-spacing: .1em; }
.score-hud strong { display: block; color: #173f5a; font-size: 18px; line-height: 1.05; }
.score-box strong.score-pop { animation: scorePop .34s ease-out; }
.score-box strong.score-hurt { animation: scoreHurt .38s ease-out; color: #db3b33; }
@keyframes scorePop { 50% { color: #f49c12; transform: scale(1.22); } }
@keyframes scoreHurt { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.reward-strip { display: grid; grid-template-columns: 66px 1fr 66px; gap: 8px; align-items: center; padding: 4px 12px 6px; color: #694815; background: #fff4c2; font-size: 10px; }
.reward-strip > span { display: flex; align-items: center; justify-content: center; gap: 4px; }
.mini-banana { width: 17px; height: 11px; border: 4px solid #ffd21d; border-top-color: transparent; border-left-color: transparent; border-radius: 50%; transform: rotate(18deg); filter: drop-shadow(0 1px #a86909); }
.mini-durian { width: 15px; height: 15px; border: 2px dashed #487b25; border-radius: 50%; background: #87c943; }
.level-progress { height: 7px; overflow: hidden; border-radius: 99px; background: #d7c9a6; box-shadow: inset 0 1px 2px #765e3959; }
.level-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #62d757, #ffd327, #ff9a22); transition: width .3s ease-out; }
.arena-wrap { position: relative; flex: 1; min-height: 0; margin: 0 9px; overflow: hidden; border: 2px solid #fff9b5; border-radius: 20px; background: #57d7ff; box-shadow: 0 4px 0 #1586a6, inset 0 0 22px #0066a130; touch-action: none; }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.level-banner {
  position: absolute;
  left: 50%; top: 14px;
  padding: 5px 13px;
  border-radius: 99px;
  color: #fff;
  background: #113e59bf;
  box-shadow: 0 3px 9px #06364c43;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.level-banner.show { opacity: 1; transform: translateX(-50%) translateY(3px); }
.impact-word { position: absolute; left: 50%; top: 38%; color: #fff; font-size: 28px; font-weight: 1000; text-shadow: 0 4px 0 #b43a26, 0 7px 12px #69251b80; opacity: 0; pointer-events: none; }
.impact-word.show { animation: impactDrop .7s ease-out; }
.impact-word.good { color: #fff36e; text-shadow: 0 4px 0 #e8900a, 0 7px 12px #7c4d0a80; }
@keyframes impactDrop { 0% { opacity: 0; transform: translate(-50%, -45px) rotate(-8deg) scale(1.4); } 35% { opacity: 1; transform: translate(-50%, 2px) rotate(4deg) scale(.95); } 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, 18px) scale(.82); } }
.charge-panel { padding: 7px 10px max(9px, env(safe-area-inset-bottom)); background: #fff4c2; }
.charge-button {
  display: grid;
  grid-template-columns: 105px 1fr 39px;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 63px;
  padding: 8px 10px;
  border: 2px solid #fff9a6;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(#ff9e28, #ef631c);
  box-shadow: 0 5px 0 #a64013, inset 0 2px #ffd472;
  text-shadow: 0 2px #a13b10;
  font-weight: 1000;
  cursor: pointer;
  touch-action: none;
}
.charge-button.charging { transform: translateY(2px); box-shadow: 0 3px 0 #a64013, inset 0 2px #ffd472; }
.charge-button:disabled { filter: saturate(.55); opacity: .78; }
.charge-button > span:first-child { font-size: 11px; line-height: 1.05; }
.charge-button b { font-size: 12px; }
.power-track { position: relative; height: 16px; overflow: hidden; border: 3px solid #fff5c1; border-radius: 99px; background: #9e3c20; box-shadow: inset 0 2px 4px #5b160f88; }
.power-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5ad75c 0 42%, #ffd633 62%, #ff4d31 100%); }
.power-track em { position: absolute; left: 71%; top: -3px; width: 3px; height: 18px; background: #fff; box-shadow: 0 0 5px #fff; }
.flying-fruit { position: absolute; z-index: 20; font-size: 28px; line-height: 1; pointer-events: none; filter: drop-shadow(0 3px 3px #b16b0e75); }

/* Result screens */
.result-screen, .fail-screen { flex-direction: column; align-items: center; justify-content: center; padding: max(22px, env(safe-area-inset-top)) 30px max(18px, env(safe-area-inset-bottom)); text-align: center; }
.result-screen { color: #fff; background: radial-gradient(circle at 50% 35%, #ffe966 0 16%, #ffae25 45%, #f1691b 100%); }
.result-screen .eyebrow, .fail-screen .eyebrow { color: #fff6be; text-shadow: 0 2px #a54912; }
.result-screen h2, .fail-screen h2 { margin: 8px 0 14px; color: #fff; font-size: clamp(37px, 11vw, 56px); line-height: .9; letter-spacing: -.05em; text-shadow: 0 5px 0 #b75214, 0 9px 20px #7c2c1666; }
.result-rays { position: absolute; width: 430px; height: 430px; border-radius: 50%; background: repeating-conic-gradient(#ffffff20 0 8deg, transparent 8deg 20deg); animation: slowTurn 18s linear infinite; }
@keyframes slowTurn { to { transform: rotate(1turn); } }
.result-banana { position: relative; width: 160px; height: 150px; margin: 4px auto 10px; filter: drop-shadow(0 12px 7px #8f430c55); animation: bananaBounce 1.6s ease-in-out infinite; }
.result-banana i { position: absolute; inset: 20px 19px 26px 18px; border: 30px solid #ffe02a; border-top-color: transparent; border-left-color: transparent; border-radius: 50%; transform: rotate(12deg); box-shadow: inset -7px -7px #ef9e12; }
.result-banana b { position: absolute; right: 7px; top: 28px; width: 20px; height: 12px; border-radius: 5px; background: #6e4b18; transform: rotate(-30deg); }
@keyframes bananaBounce { 50% { transform: translateY(-9px) rotate(4deg) scale(1.04); } }
.result-score { position: relative; width: 100%; margin-bottom: 15px; padding: 10px; border-radius: 17px; color: #744316; background: #fff8c9e8; box-shadow: 0 5px 0 #b55a13; }
.result-score small { display: block; font-size: 9px; letter-spacing: .12em; }
.result-score strong { display: block; font-size: 34px; }
.result-screen .primary-button, .fail-screen .primary-button { position: relative; max-width: 330px; }
.text-button { margin-top: 10px; color: #fff; background: transparent; text-decoration: underline; text-underline-offset: 3px; font-size: 12px; font-weight: 800; cursor: pointer; }
.result-screen .signature, .fail-screen .signature { color: #fff2be; margin-top: 18px; }
.fail-screen { color: #6d391a; background: linear-gradient(#83dcff, #fff1ae 62%, #e6bd62); }
.fail-screen h2 { color: #fff7cc; }
.fail-character { position: relative; width: 190px; height: 210px; margin-bottom: 8px; }
.fail-character .head { position: absolute; left: 48px; top: 35px; width: 96px; height: 102px; border: 5px solid #7e451b; border-radius: 48% 48% 44% 44%; background: #f2a963; box-shadow: inset -9px -8px #df864b; }
.fail-character .hair { position: absolute; left: 48px; top: 26px; width: 96px; height: 45px; border-radius: 50% 54% 30% 20%; background: #4a2819; transform: rotate(-4deg); }
.fail-character .eye { position: absolute; z-index: 2; top: 78px; width: 15px; height: 4px; border-radius: 4px; background: #47231a; }
.fail-character .eye.left { left: 72px; transform: rotate(15deg); }.fail-character .eye.right { right: 70px; transform: rotate(-15deg); }
.fail-character .mouth { position: absolute; z-index: 2; left: 82px; top: 108px; width: 29px; height: 14px; border: 4px solid #72341f; border-bottom: 0; border-radius: 18px 18px 0 0; }
.fail-character .body { position: absolute; left: 31px; top: 128px; width: 130px; height: 78px; border: 5px solid #165f6d; border-radius: 48px 48px 18px 18px; background: #21a9b0; }
.fail-character b { position: absolute; z-index: 3; left: 57px; top: 146px; color: #fff; font-size: 23px; transform: rotate(-8deg); text-shadow: 0 3px #166a72; }
.fail-screen > p:not(.eyebrow):not(.signature) { margin: 0 0 16px; }

@media (max-height: 720px) {
  .menu-screen { padding-top: 8px; padding-bottom: 7px; }
  .round-button { width: 39px; height: 39px; }
  .title-lockup { top: 58px; }
  .title-lockup h1 { font-size: 47px; }
  .title-lockup > p:last-child { margin-top: 7px; font-size: 10px; }
  .menu-card { padding-top: 9px; }
  .level-button { height: 35px; }
  .primary-button { min-height: 44px; }
  .game-header { min-height: 49px; padding-top: 4px; }
  .game-header .round-button { width: 36px; height: 36px; }
  .score-hud { padding-top: 5px; }
  .score-hud > div { padding: 3px 7px; }
  .score-hud strong { font-size: 16px; }
  .reward-strip { padding-top: 2px; padding-bottom: 4px; }
  .charge-panel { padding-top: 5px; padding-bottom: 7px; }
  .charge-button { min-height: 53px; }
  .result-banana { width: 130px; height: 120px; margin-bottom: 0; }
  .result-banana i { inset: 14px; }
  .result-screen h2, .fail-screen h2 { margin-bottom: 8px; }
  .fail-character { transform: scale(.82); margin: -15px 0 -15px; }
}

@media (min-width: 560px) {
  .game-shell { border-radius: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
