:root {
  color-scheme: light;
  --navy: #17364d;
  --sky: #4bc9ea;
  --cream: #fff8df;
  --yellow: #ffd34d;
  --orange: #ef773c;
  --brown: #6f371d;
  --green: #60ba5a;
  --red: #ee5c50;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #073b52;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
button, a { font: inherit; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }

.game-shell {
  position: relative;
  isolation: isolate;
  width: min(100vw, 500px);
  height: 100dvh;
  min-height: 600px;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(#32bde4, #d7f5e8 61%, #70b84d 62%);
  box-shadow: 0 0 70px rgba(0, 20, 33, .58);
}

.screen { position: absolute; inset: 0; display: none; opacity: 0; }
.screen.active { display: flex; animation: screenIn .28s ease-out both; }
@keyframes screenIn { from { opacity: 0; transform: scale(.988); } to { opacity: 1; transform: none; } }

.round-button {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  padding: 0;
  border: 2px solid rgba(255,255,255,.76);
  border-radius: 50%;
  color: #fff;
  text-decoration: none;
  background: rgba(20, 63, 77, .62);
  box-shadow: inset 0 1px rgba(255,255,255,.25), 0 4px 0 rgba(10,47,60,.55);
  backdrop-filter: blur(7px);
  cursor: pointer;
}
.round-button:active { translate: 0 3px; box-shadow: inset 0 1px rgba(255,255,255,.25), 0 1px 0 rgba(10,47,60,.55); }
.eyebrow { margin: 0 0 7px; color: #fff2a9; font-size: 9px; font-weight: 900; letter-spacing: .22em; text-shadow: 0 2px 8px rgba(0,0,0,.24); }
.signature { margin: 13px 0 0; color: #71563e; font: 700 9px/1.2 Georgia, serif; letter-spacing: .05em; }

/* Menu */
.menu-screen { flex-direction: column; padding: max(17px, env(safe-area-inset-top)) 18px max(17px, env(safe-area-inset-bottom)); }
.menu-art { position: absolute; inset: 0; z-index: -3; background: url("../../assets/game-art/poop-duel-menu.webp") center/cover no-repeat; transform: scale(1.01); }
.menu-shade { position: absolute; inset: 0; z-index: -2; background: linear-gradient(rgba(3,49,70,.1), rgba(8,47,47,.04) 45%, rgba(8,44,35,.72) 77%, rgba(4,31,27,.88)); }
.menu-top { display: flex; justify-content: space-between; }
.title-lockup { margin-top: clamp(24px, 7vh, 72px); text-align: center; filter: drop-shadow(0 5px 0 rgba(86,42,25,.5)); }
.title-lockup h1 { margin: 0; color: #fff8d7; font: 1000 clamp(46px, 14vw, 72px)/.83 Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; letter-spacing: -.03em; transform: rotate(-2deg); }
.title-lockup h1 span { display: block; color: var(--yellow); font-size: 1.13em; -webkit-text-stroke: 2px #74371e; paint-order: stroke fill; }
.tagline { margin: 13px 0 0; color: #fff; font-size: 12px; font-weight: 900; letter-spacing: .055em; text-shadow: 0 2px 8px #17364d; }
.menu-card { width: 100%; margin-top: auto; padding: 15px; border: 2px solid rgba(255,255,255,.84); border-radius: 23px; color: var(--navy); background: linear-gradient(150deg, rgba(255,253,231,.97), rgba(246,222,157,.96)); box-shadow: inset 0 2px #fff, 0 9px 0 #743f27, 0 17px 30px rgba(8,26,31,.36); }
.menu-card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.menu-card-heading > span { font-size: 10px; font-weight: 1000; letter-spacing: .17em; }
.menu-card-heading b { display: flex; align-items: center; gap: 5px; color: #6e4421; font-size: 13px; }
.coin-dot { display: inline-grid; flex: 0 0 auto; width: 16px; height: 16px; border: 2px solid #c37b18; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8a5, #ffd43b 50%, #e3901c); box-shadow: inset 0 0 0 2px #ffeb72, 0 2px 3px rgba(102,55,14,.22); vertical-align: -3px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.level-button { position: relative; min-width: 0; aspect-ratio: .9; padding: 5px 2px; border: 1px solid #cb8e46; border-radius: 13px; color: #5e351f; background: linear-gradient(#fff8cb, #e9a74c); box-shadow: inset 0 1px #fff, 0 4px 0 #9d592e; cursor: pointer; }
.level-button strong { display: block; font: 1000 21px/1 Impact, sans-serif; }
.level-button small { display: block; margin-top: 3px; font-size: 6px; font-weight: 900; line-height: 1.05; text-transform: uppercase; }
.level-button.locked { color: #8c7c68; background: linear-gradient(#e9e3ce, #bfb39e); border-color: #a89d8c; box-shadow: inset 0 1px #fff, 0 4px 0 #776d62; filter: saturate(.4); cursor: not-allowed; }
.level-button.locked::after { content: "LOCKED"; position: absolute; inset: auto 2px 5px; font-size: 5px; font-weight: 1000; letter-spacing: .04em; }
.level-button.completed::before { content: "✓"; position: absolute; right: 4px; top: 3px; display: grid; place-items: center; width: 13px; height: 13px; border-radius: 50%; color: #fff; background: #46a857; font-size: 8px; }
.level-button:active:not(.locked) { translate: 0 3px; box-shadow: inset 0 1px #fff, 0 1px 0 #9d592e; }
.menu-tip { margin: 13px 1px 0; color: #795c3f; font-size: 9px; line-height: 1.42; }

/* Battle */
.play-screen { flex-direction: column; gap: 6px; padding: max(9px, env(safe-area-inset-top)) 10px max(9px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(9,67,88,.12), rgba(16,56,45,.04)); }
.game-header { display: grid; grid-template-columns: 43px 1fr 43px; align-items: center; gap: 8px; flex: 0 0 auto; }
.level-heading { text-align: center; color: #fff; text-shadow: 0 2px 8px rgba(4,46,58,.46); }
.level-heading small, .top-hud small { display: block; color: #fff4ad; font-size: 8px; font-weight: 1000; letter-spacing: .16em; }
.level-heading strong { display: block; margin-top: 1px; font-size: 16px; font-weight: 1000; }
.top-hud { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; min-height: 44px; padding: 5px 9px; border: 1px solid rgba(255,255,255,.45); border-radius: 14px; color: #fff; background: rgba(15,66,76,.66); box-shadow: inset 0 1px rgba(255,255,255,.19); backdrop-filter: blur(7px); }
.coin-score { display: flex; align-items: center; gap: 6px; }
.top-hud > div:nth-child(2) { text-align: center; }
.top-hud > div:last-child { text-align: right; }
.top-hud strong { display: block; margin-top: 1px; font-size: 14px; font-weight: 1000; font-variant-numeric: tabular-nums; }
.wind-readout strong { font-size: 11px; }
.enemy-roster { display: flex; justify-content: center; gap: 5px; min-height: 42px; flex: 0 0 auto; }
.enemy-card { flex: 1 1 0; min-width: 0; max-width: 160px; padding: 5px 7px; border: 2px solid rgba(255,255,255,.52); border-radius: 12px; color: #fff; background: rgba(105,50,27,.73); box-shadow: inset 0 1px rgba(255,255,255,.18); cursor: pointer; transition: .16s; }
.enemy-card.selected { border-color: #ffe46b; transform: translateY(-2px); box-shadow: 0 0 0 2px rgba(255,210,55,.32), inset 0 1px rgba(255,255,255,.2); }
.enemy-card.defeated { opacity: .42; filter: grayscale(1); }
.enemy-card div { display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.enemy-card strong { overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.enemy-card span { font-size: 7px; font-weight: 900; }
.enemy-card .health-track { margin-top: 4px; height: 6px; }

.arena-wrap { position: relative; flex: 1 1 auto; min-height: 275px; overflow: hidden; border: 2px solid rgba(255,255,255,.6); border-radius: 22px; background: #7adcf0; box-shadow: inset 0 0 30px rgba(14,88,104,.17), 0 7px 18px rgba(7,48,57,.18); touch-action: none; }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.turn-banner { position: absolute; left: 50%; top: 10px; transform: translate(-50%, -6px); padding: 5px 11px; border: 1px solid rgba(255,255,255,.7); border-radius: 99px; color: #fff; background: rgba(23,54,77,.68); box-shadow: 0 4px 10px rgba(13,49,60,.18); font-size: 8px; font-weight: 1000; letter-spacing: .13em; opacity: 0; transition: .18s; pointer-events: none; white-space: nowrap; }
.turn-banner.show { opacity: 1; transform: translate(-50%, 0); }
.speech-bubble { position: absolute; left: 50%; top: 21%; transform: translate(-50%, 10px) scale(.9); max-width: 76%; padding: 7px 12px; border: 2px solid #764225; border-radius: 14px; color: #60311b; background: #fff8d9; box-shadow: 0 5px 0 rgba(99,54,27,.3); font-size: 11px; font-weight: 1000; opacity: 0; transition: .16s; pointer-events: none; text-align: center; }
.speech-bubble.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.player-health-row { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-height: 42px; padding: 5px 10px; border: 1px solid rgba(255,255,255,.5); border-radius: 13px; color: #fff; background: rgba(20,66,76,.71); }
.avatar-mini { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid #fff0b4; border-radius: 50%; color: #fff; background: #ef5a3c; box-shadow: inset 0 3px #ffad6f; font-weight: 1000; }
.health-copy { flex: 1; }
.health-copy > div:first-child { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 8px; }
.health-track { height: 8px; overflow: hidden; border: 1px solid rgba(80,27,20,.45); border-radius: 99px; background: rgba(42,28,25,.42); box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.health-track i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(#8aee6c, #3ea844); box-shadow: inset 0 1px rgba(255,255,255,.45); transition: width .32s ease, background .2s; }
.health-track i.danger { background: linear-gradient(#ff8a5d, #db3f38); }

.throw-panel { flex: 0 0 auto; padding: 6px; border: 1px solid rgba(255,255,255,.5); border-radius: 16px; background: rgba(253,244,204,.94); box-shadow: inset 0 1px #fff, 0 4px 12px rgba(55,44,29,.19); }
.item-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 5px; }
.item-button { display: grid; grid-template-columns: 25px 1fr; grid-template-rows: auto auto; align-items: center; min-width: 0; min-height: 39px; padding: 3px 4px; border: 1px solid #b9854e; border-radius: 10px; color: #6b3b24; background: #f7dd9f; box-shadow: inset 0 1px #fff; cursor: pointer; }
.item-button.active { border-color: #e35435; box-shadow: 0 0 0 2px rgba(230,88,47,.25), inset 0 1px #fff; background: #ffeab5; }
.item-button:disabled { opacity: .5; filter: grayscale(.7); }
.item-button > i:first-child { grid-row: 1 / 3; }
.item-button span { overflow: hidden; text-align: left; font-size: 7px; font-weight: 1000; text-overflow: ellipsis; }
.item-button > b { text-align: left; font-size: 6px; white-space: nowrap; }
.item-button .coin-dot { width: 12px; height: 12px; border-width: 1px; }
.poop-icon { position: relative; display: block; width: 22px; height: 18px; border-radius: 45% 55% 48% 52%; background: linear-gradient(145deg, #9a5a2d, #5a2c18); box-shadow: inset 4px 3px rgba(255,190,102,.32); }
.poop-icon::before { content: ""; position: absolute; left: 5px; top: -7px; width: 14px; height: 12px; border-radius: 70% 30% 60% 40%; background: inherit; transform: rotate(-8deg); }
.poop-icon.mega { width: 27px; height: 22px; }
.poop-icon.ultra { width: 28px; height: 23px; background: linear-gradient(145deg, #ffd85a, #7e3a1d 58%, #452012); box-shadow: inset 4px 3px rgba(255,244,136,.7), 0 0 8px rgba(255,207,54,.72); transform: scale(.83); }
.ultra-button:not(:disabled) { color: #65351e; border-color: #df9d1e; background: linear-gradient(#fff4a6, #f3b332); animation: ultraReady .9s ease-in-out infinite alternate; }
@keyframes ultraReady { to { box-shadow: 0 0 10px rgba(255,205,49,.85), inset 0 1px #fff; transform: translateY(-1px); } }
.heart-icon { display: grid; place-items: center; width: 24px; height: 22px; border: 2px solid #9c3136; border-radius: 50% 50% 46% 46%; color: #fff; background: linear-gradient(#ff7b72, #d83e49); box-shadow: inset 0 2px rgba(255,255,255,.35); font-style: normal; font-size: 16px; font-weight: 1000; line-height: 1; }
.heal-button:not(:disabled) { background: linear-gradient(#fff2c2, #f3c587); }
.charge-button { position: relative; display: grid; grid-template-columns: 104px 1fr 34px; align-items: center; gap: 7px; width: 100%; min-height: 49px; padding: 6px 9px; border: 2px solid #82411f; border-radius: 13px; color: #fff8d5; background: linear-gradient(#e66a39, #a83e27); box-shadow: inset 0 2px rgba(255,255,255,.27), 0 4px 0 #5d2c1f; cursor: pointer; touch-action: none; }
.charge-button:active, .charge-button.charging { translate: 0 2px; box-shadow: inset 0 2px rgba(255,255,255,.22), 0 2px 0 #5d2c1f; }
.charge-button:disabled { opacity: .62; filter: saturate(.5); cursor: default; }
.charge-copy { font-size: 9px; font-weight: 1000; letter-spacing: .07em; }
.power-track { position: relative; height: 15px; overflow: hidden; border: 2px solid #6f341f; border-radius: 99px; background: #f6d8a2; box-shadow: inset 0 2px 3px rgba(80,47,23,.22); }
.power-track > i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7ddd59, #ffd747 58%, #ff6546); transition: width .03s linear; }
.power-track > em { position: absolute; top: -2px; bottom: -2px; left: 70%; width: 10%; border: 2px solid rgba(255,255,255,.9); border-radius: 4px; background: rgba(255,255,255,.1); box-shadow: 0 0 7px #fff; pointer-events: none; }
.charge-button small { font-size: 10px; font-weight: 1000; font-variant-numeric: tabular-nums; }

.flying-coin { position: absolute; z-index: 20; width: 17px; height: 17px; border: 2px solid #c77e18; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff9a7, #ffd634 52%, #df8b17); box-shadow: 0 0 8px rgba(255,216,53,.75); pointer-events: none; }

/* Win and lose */
.result-screen, .fail-screen { flex-direction: column; align-items: center; justify-content: center; padding: max(28px, env(safe-area-inset-top)) 26px max(22px, env(safe-area-inset-bottom)); text-align: center; background: radial-gradient(circle at 50% 30%, #5edbf1, #167991 58%, #0d4a5c); }
.result-screen h2, .fail-screen h2 { position: relative; z-index: 2; margin: 0; color: #fff8d6; font: 1000 clamp(44px, 13vw, 68px)/.92 Impact, sans-serif; letter-spacing: -.025em; text-shadow: 0 5px 0 #703921, 0 9px 18px rgba(0,0,0,.25); transform: rotate(-2deg); }
.result-burst { position: absolute; width: 280px; height: 280px; top: 18%; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255,229,75,.4) 0 9deg, transparent 9deg 18deg); animation: slowSpin 18s linear infinite; }
@keyframes slowSpin { to { transform: rotate(1turn); } }
.winner-character { position: relative; z-index: 1; width: 130px; height: 150px; margin: 24px 0 11px; }
.winner-character > span { position: absolute; left: 27px; top: 16px; width: 78px; height: 76px; border: 4px solid #743f29; border-radius: 48% 48% 44% 44%; background: #f1ad72; box-shadow: inset -10px -7px rgba(170,76,48,.12); }
.winner-character > span::before, .winner-character > span::after { content: ""; position: absolute; top: 29px; width: 12px; height: 16px; border-radius: 50%; background: #17364d; box-shadow: inset 3px 3px #fff; }
.winner-character > span::before { left: 18px; } .winner-character > span::after { right: 18px; }
.winner-character > i { position: absolute; left: 21px; top: 2px; width: 88px; height: 32px; border-radius: 50% 55% 28% 20%; background: #ef5539; transform: rotate(-8deg); }
.winner-character > b { position: absolute; left: 17px; bottom: 0; width: 98px; height: 71px; border: 4px solid #743f29; border-radius: 45% 45% 15% 15%; background: #f65f3f; }
.result-stats { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 310px); margin: 5px 0 23px; }
.result-stats > div + div { border-left: 1px solid rgba(255,255,255,.35); }
.result-stats small { display: block; color: #ffef94; font-size: 8px; font-weight: 1000; letter-spacing: .15em; }
.result-stats strong { display: block; margin-top: 3px; color: #fff; font-size: 24px; }
.primary-button { position: relative; z-index: 2; width: min(100%, 310px); min-height: 55px; border: 2px solid #fff3a1; border-radius: 15px; color: #60301f; background: linear-gradient(#ffe96e, #eeb02d); box-shadow: inset 0 2px #fff, 0 6px 0 #8a4a24, 0 12px 23px rgba(0,0,0,.2); font-size: 11px; font-weight: 1000; letter-spacing: .09em; cursor: pointer; }
.primary-button span { float: right; font-size: 20px; }
.primary-button:active { translate: 0 4px; box-shadow: inset 0 2px #fff, 0 2px 0 #8a4a24; }
.text-button { position: relative; z-index: 2; margin-top: 14px; padding: 3px 6px; border: 0; color: #fff; background: none; font-size: 9px; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.text-button + .text-button { margin-top: 7px; }
.result-signature { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); color: rgba(255,255,255,.68); }

.fail-screen { background: radial-gradient(circle at 50% 28%, #e0c777, #9b6136 59%, #50301f); }
.failure-character { position: relative; width: 230px; height: 220px; margin: 17px 0 4px; }
.failure-character .head { position: absolute; z-index: 3; left: 69px; top: 29px; width: 94px; height: 99px; border: 4px solid #713d2a; border-radius: 48% 49% 43% 45%; background: #eda975; box-shadow: inset -12px -9px rgba(158,70,43,.13); }
.failure-character .cap { position: absolute; z-index: 5; left: 59px; top: 18px; width: 107px; height: 38px; border: 4px solid #713d2a; border-radius: 62% 55% 18% 14%; background: #e74e36; transform: rotate(-13deg); }
.failure-character .cap::after { content: ""; position: absolute; right: -29px; bottom: -4px; width: 48px; height: 13px; border: 3px solid #713d2a; border-radius: 60%; background: #e74e36; transform: rotate(12deg); }
.failure-character .eye { position: absolute; z-index: 6; top: 71px; width: 13px; height: 15px; border-radius: 50%; background: #233846; }
.failure-character .eye::after { content: ""; position: absolute; left: 3px; top: 3px; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.failure-character .eye.left { left: 96px; transform: rotate(22deg); } .failure-character .eye.right { left: 129px; transform: rotate(-22deg); }
.failure-character .mouth { position: absolute; z-index: 6; left: 105px; top: 102px; width: 28px; height: 9px; border: 3px solid #753927; border-width: 3px 0 0; border-radius: 50%; }
.failure-character .shirt { position: absolute; z-index: 2; left: 59px; top: 115px; width: 119px; height: 100px; border: 4px solid #713d2a; border-radius: 43% 43% 13% 13%; background: #f2e2b7; }
.failure-character .arm { position: absolute; z-index: 1; top: 139px; width: 79px; height: 28px; border: 4px solid #713d2a; border-radius: 99px; background: #eda975; }
.failure-character .arm.left { left: 1px; transform: rotate(-23deg); } .failure-character .arm.right { right: 0; transform: rotate(23deg); }
.failure-character .arm::after { content: ""; position: absolute; top: -12px; width: 30px; height: 32px; border: 4px solid #713d2a; border-radius: 45%; background: #eda975; }
.failure-character .arm.left::after { left: -8px; } .failure-character .arm.right::after { right: -8px; }
.failure-character .splat { position: absolute; z-index: 7; width: 24px; height: 18px; border-radius: 46% 54%; background: #6c371d; box-shadow: 0 0 0 4px #814725; }
.failure-character .splat::before, .failure-character .splat::after { content: ""; position: absolute; width: 7px; height: 10px; border-radius: 50%; background: inherit; }
.failure-character .splat::before { left: -8px; top: 4px; transform: rotate(50deg); } .failure-character .splat::after { right: -9px; top: -3px; transform: rotate(-42deg); }
.failure-character .splat.one { left: 73px; top: 64px; transform: rotate(18deg); }
.failure-character .splat.two { right: 51px; top: 121px; transform: scale(.72) rotate(-20deg); }
.failure-character .splat.three { left: 95px; top: 149px; transform: scale(.63) rotate(40deg); }
.fail-line { position: relative; z-index: 2; margin: 0 0 21px; color: #fff4ca; font: italic 700 13px Georgia, serif; }

@media (min-width: 501px) { body { background: radial-gradient(circle, #1b7892, #052936 66%); } .game-shell { border-inline: 1px solid rgba(255,255,255,.17); } }
@media (max-height: 710px) {
  .game-shell { min-height: 560px; }
  .title-lockup { margin-top: 9px; transform: scale(.88); }
  .menu-card { padding: 11px; }
  .menu-tip { margin-top: 8px; }
  .signature { margin-top: 8px; }
  .play-screen { gap: 4px; padding-top: max(6px, env(safe-area-inset-top)); }
  .top-hud { min-height: 38px; }
  .enemy-roster { min-height: 35px; }
  .enemy-card { padding-block: 3px; }
  .arena-wrap { min-height: 230px; }
  .player-health-row { min-height: 36px; padding-block: 3px; }
  .throw-panel { padding: 4px; }
  .item-row { margin-bottom: 3px; }
  .item-button { min-height: 30px; }
  .charge-button { min-height: 43px; }
  .winner-character { margin: 12px 0 3px; transform: scale(.82); height: 125px; }
  .failure-character { margin: 5px 0 -10px; transform: scale(.8); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
