:root {
  color-scheme: only light;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  background: #263624;
  touch-action: none;
  --green: #659900;
  --green-dark: #315d08;
  --cream: #ffffcc;
  --paper: #fffde5;
  --green-cta: #78a91f;
  --green-cta-dark: #426f05;
}

* { box-sizing: border-box; }

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #6b8c50, #263624 75%);
}

#game-shell {
  position: relative;
  container-type: size;
  width: min(100vw, calc(100svh * .45));
  height: min(100svh, calc(100vw / .45));
  overflow: hidden;
  background: #a7bd55;
  box-shadow: 0 0 45px rgba(0,0,0,.45);
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 699px) {
  #game-shell {
    width: 100vw;
    height: 100svh;
  }
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #a7bd55 url("assets/base-map.webp") center bottom / 100% auto no-repeat;
  touch-action: none;
}

.flow-screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  overflow: hidden;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(rgba(41,70,29,.16),rgba(29,53,25,.42)), url("assets/base-map.webp") center bottom / cover no-repeat;
}

.flow-screen.visible { display: grid; }

.flow-card {
  width: min(92%, 470px);
  max-height: 96%;
  overflow: hidden;
  padding: clamp(16px, 4.4cqw, 24px);
  border: clamp(3px, .9cqw, 5px) solid var(--green);
  border-radius: clamp(25px, 7.5cqw, 40px);
  background: rgba(255,255,213,.97);
  color: var(--green-dark);
  text-align: center;
  box-shadow: 0 clamp(7px, 1.8cqw, 10px) 0 rgba(38,79,5,.42), 0 18px 44px rgba(22,42,15,.24);
}

.eyebrow {
  display: block;
  color: #538500;
  font-size: clamp(11px, 2.9cqw, 13px);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.flow-card h1 {
  margin: clamp(5px, 1.4cqw, 8px) 0;
  color: var(--green);
  font-size: clamp(34px, 10cqw, 50px);
  line-height: .96;
  letter-spacing: -.035em;
  text-shadow: 0 .09em 0 #173e00;
}

.intro-copy {
  max-width: 35ch;
  margin: 0 auto clamp(4px, 1cqw, 7px);
  color: #4b6f23;
  font-size: clamp(12px, 3.3cqw, 15px);
  font-weight: 700;
  line-height: 1.3;
}

.screen-character {
  margin: clamp(3px, 1cqw, 7px) auto;
  background-repeat: no-repeat;
}

.setup-character {
  width: min(33%, 140px);
  aspect-ratio: .71;
  background-image: url("assets/sample-demo-screen.webp");
  background-size: 386% auto;
  background-position: 50% 36.7%;
}

.end-character {
  position: relative;
  width: min(52%, 225px);
  aspect-ratio: 1025 / 1535;
}

.end-character-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.end-character-photo-mask {
  position: absolute;
  top: 26.38%;
  left: 72.93%;
  z-index: 0;
  display: none;
  width: 32.68%;
  height: 19.93%;
  border-radius: 50%;
  overflow: hidden;
  clip-path: ellipse(50% 50% at 50% 50%);
}

.end-character-photo {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 125%;
  height: 125%;
  object-fit: cover;
  object-position: center;
  transform: translate(-50%, -50%);
  transform-origin: center;
}

.end-character-frame { display: none; }
.end-character.has-photo .end-character-drawn { display: none; }
.end-character.has-photo .end-character-photo-mask,
.end-character.has-photo .end-character-frame { display: block; }

.name-fields {
  display: block;
  text-align: left;
}

.name-fields label {
  display: block;
}

.name-fields label + label {
  margin-top: 13px;
}

.name-fields label span,
.language-fields legend {
  display: block;
  margin-bottom: clamp(4px, 1.1cqw, 6px);
  color: var(--green-dark);
  font-size: clamp(12px, 3.2cqw, 15px);
  font-weight: 900;
}

.name-fields input {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  border: 2px solid var(--green);
  border-radius: 14px;
  outline: 0;
  background: #fffef4;
  color: #2d4f0c;
  font-family: inherit;
  font-size: clamp(13px, 3.4cqw, 16px);
  font-weight: 700;
  line-height: 1.1;
}

.name-fields input:focus {
  border-color: #397d10;
  box-shadow: 0 0 0 3px rgba(101,153,0,.16);
}

.language-fields {
  margin: clamp(10px, 2.5cqw, 14px) 0;
  padding: 0;
  border: 0;
  text-align: left;
}

.language-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(8px, 2.2cqw, 12px);
}

.language-button {
  min-width: 0;
  padding: clamp(10px, 2.7cqw, 13px) 6px;
  border: 2px solid #8caf4f;
  border-radius: clamp(12px, 3.6cqw, 17px);
  background: #fffef4;
  color: var(--green-dark);
  font-family: inherit;
  font-size: clamp(12px, 3.15cqw, 15px);
  font-weight: 900;
  line-height: 1.1;
  cursor: pointer;
}

.language-button.selected {
  border-color: #397d10;
  background: #eaf5d5;
  box-shadow: inset 0 0 0 2px rgba(101,153,0,.13);
}

.primary-button,
.purchase-button,
.store-button {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: clamp(12px, 3.2cqw, 15px) 12px;
  color: white;
  font-family: inherit;
  font-size: clamp(15px, 4.2cqw, 19px);
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  background: var(--green);
  box-shadow: 0 clamp(4px, 1.2cqw, 6px) 0 #365f00;
  cursor: pointer;
}

.purchase-button {
  margin-top: clamp(10px, 2.6cqw, 13px);
  background: var(--green-cta);
  box-shadow: 0 clamp(4px, 1.2cqw, 6px) 0 var(--green-cta-dark);
}

.purchase-button[aria-disabled="true"] {
  opacity: .76;
  cursor: default;
}

.store-button {
  margin-top: clamp(10px, 2.6cqw, 13px);
  border: 2px solid var(--green);
  background: #fffef1;
  color: var(--green-dark);
  box-shadow: 0 clamp(3px, .9cqw, 5px) 0 #9ebd67;
}

.primary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #365f00; }
.purchase-button:not([aria-disabled="true"]):active { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-cta-dark); }
.store-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #6f9630; }

.product-status,
.safe-note {
  display: block;
  margin-top: clamp(8px, 2cqw, 11px);
  color: #64813c;
  font-size: clamp(10px, 2.65cqw, 12px);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.safe-note { margin-top: 4px; }

.complete-card h2 {
  margin: clamp(6px, 1.5cqw, 9px) 0 4px;
  color: var(--green-dark);
  font-size: clamp(20px, 5.8cqw, 28px);
  line-height: 1.05;
}

.complete-card > p {
  max-width: 34ch;
  margin: 0 auto;
  color: #4e682d;
  font-size: clamp(13px, 3.5cqw, 16px);
  font-weight: 700;
  line-height: 1.35;
}

#complete-from {
  display: block;
  margin-top: clamp(6px, 1.5cqw, 9px);
  color: #5d7a34;
  font-size: clamp(11px, 3cqw, 14px);
}

#complete-from[hidden] { display: none; }
.end-actions { margin-top: clamp(13px, 3.3cqw, 18px); }

@media (max-height: 680px) {
  .flow-card { max-height: 97%; padding-block: 13px; }
  .setup-character { width: min(28%, 120px); }
  .end-character { width: min(34%, 150px); }
  .intro-copy { display: none; }
}
.language-select{width:100%;padding:12px 14px;border:2px solid #5a9e00;border-radius:14px;background:#fffdf0;color:#31591f;font:inherit;font-weight:800}.language-select:focus{outline:3px solid rgba(90,158,0,.2)}

/* v14: Gift Grab-style compact setup template. */
.setup-card { width: min(92%, 420px); padding: 20px; border-width: 3px; }
.misi-title-logo { display:block; width:min(60%,240px); max-height:105px; margin:5px auto 2px; object-fit:contain; }
.intro-copy { margin-bottom: 4px; font-size: 13px; }
.setup-mascot { display:block; width:auto; height:115px; margin:3px auto 7px; object-fit:contain; }
.name-fields label + label { margin-top: 7px; }
.name-fields label span, .language-fields > span { display:block; margin-bottom:4px; font-size:13px; font-weight:900; text-align:left; }
.name-fields input, .language-select { min-height:39px; padding:9px 11px; border-radius:12px; font-size:14px; }
.language-fields { margin: 7px 0; }
#demo-photo-mount .kdp-photo-row { grid-template-columns:1fr; margin:7px 0; }
#demo-photo-mount .kdp-photo-adjust { display:none !important; }
#demo-photo-mount .kdp-photo-button { min-height:38px; border-radius:12px; }
.setup-actions { display:grid; grid-template-columns:1fr; gap:9px; width:100%; margin-top:12px; }
.setup-actions .primary-button,
.setup-actions .purchase-button,
.setup-actions .intro-home-button { display:grid; place-items:center; width:100%; height:41px; min-height:41px; margin:0; padding:0 14px; border:0; border-radius:999px; font-family:inherit; font-size:14px; font-weight:900; line-height:1.1; text-align:center; text-decoration:none; }
.setup-actions .primary-button { box-shadow:0 5px 0 #365f00; }
.setup-actions .purchase-button { box-shadow:0 5px 0 var(--green-cta-dark); }
.intro-home-button { color:#fff; background:#985b32; box-shadow:0 5px 0 #69391f; }
.product-status, .safe-note { display:none !important; }
@media (max-height:700px) {
  .setup-card { padding-block:14px; }
  .misi-title-logo { width:min(55%,205px); max-height:82px; margin-top:2px; }
  .setup-mascot { height:90px; margin-block:1px 5px; }
  .intro-copy { display:none; }
}
/* v49: prevent the paid recipient photo from blowing up/cropping to a single eye on the end card. */
.end-character-photo-mask { background: #f5d4bd; }
.end-character-photo { object-fit: contain !important; max-width: none; }

/* v50: end-character mask coordinates are CENTER coordinates, matching the editor. */
.end-character-photo-mask {
  transform: translate(-50%, -50%);
}
.end-character-photo {
  max-width: none;
  object-fit: contain !important;
}
