:root{
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Noto Sans TC", system-ui, sans-serif;
  background: #9fe1ff;
  color: #183126;
}

*{
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden{
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html, body{
  min-height: 100%;
  overscroll-behavior: none;
}

body{
  margin: 0;
  background:
    radial-gradient(circle at 82% 10%, rgba(255, 230, 96, 0.88), transparent 12rem),
    linear-gradient(180deg, #8bdcff 0%, #f8e7a1 48%, #89d66d 100%);
  overflow-x: hidden;
  user-select: none;
}

button, select{
  font: inherit;
}

.safari-game{
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar{
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.home-link, .soft-btn, .hint-btn, .result-card button, .result-card a{
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: #234033;
  box-shadow: 0 8px 18px rgba(46, 83, 64, 0.18);
  font-weight: 900;
  text-decoration: none;
}

.home-link{
  width: 58px;
  min-height: 44px;
  display: grid;
  grid-template-columns: 16px 28px;
  gap: 4px;
  place-items: center;
  padding: 4px;
  font-size: 1.4rem;
}

.home-link img{
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.title-block p, .title-block h1{
  margin: 0;
}

.title-block p{
  font-size: 0.74rem;
  font-weight: 900;
  color: rgba(24, 49, 38, 0.68);
}

.title-block h1{
  font-size: clamp(1.18rem, 4.4vw, 2.25rem);
  line-height: 1.02;
}

.language-picker{
  min-width: 112px;
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 900;
  color: rgba(24, 49, 38, 0.72);
}

.language-picker select{
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.9);
  color: #183126;
  font-weight: 900;
}

.menu-panel{
  flex: 1;
  display: grid;
  align-content: start;
  gap: 14px;
}

.cover{
  width: min(100%, 42vh);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  object-fit: contain;
  justify-self: center;
  box-shadow: 0 18px 38px rgba(37, 78, 58, 0.22);
}

.menu-copy{
  display: grid;
  gap: 4px;
}

.menu-copy strong{
  font-size: 1.35rem;
}

.menu-copy span{
  color: rgba(24, 49, 38, 0.72);
  font-weight: 800;
}

/* Keep the primary Main action in a short desktop viewport. */
@media (min-width: 800px) and (max-height: 800px){
  .main-panel {
    gap: 10px;
  }

  .main-panel .cover {
    width: min(100%, 42vh, 410px);
    aspect-ratio: 1 / 1;
    object-fit: contain;
    object-position: center;
  }

  .main-panel .menu-copy {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
  }

  .main-panel .menu-copy strong {
    font-size: 1.1rem;
    white-space: nowrap;
  }

  .main-panel .menu-copy span {
    font-size: 0.9rem;
  }
}
.stage-entry-btn{ min-height:44px; border:0; border-radius:12px; background:linear-gradient(180deg,#fff9d6,#ffd56d); font-weight:900; }

.stage-animal, .chip-animal, .target-animal{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-animal{
  filter: drop-shadow(0 6px 8px rgba(30, 64, 44, 0.24));
}

.pause-btn, .hint-btn){
  align-self: center;
  justify-self: center;
  flex: 0 0 auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .85), 0 3px 0 rgba(35, 64, 51, .2);
}

.pause-btn):focus-visible, body.safari-playing .hint-btn:focus-visible, body.safari-playing .result-card button:focus-visible{
  outline: 3px solid #0d7657;
  outline-offset: 2px;
}

.pause-btn{
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #e8f7eb;
  color: #245b39;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 1000;
  line-height: 1;
}

.soft-btn, .hint-btn{
  padding: 0 13px;
}

.hint-btn{
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fff9d6, #ffd56d);
}

.hint-btn:disabled{
  opacity: 0.48;
}

.progress-card{
  display: grid;
  gap: 5px;
  font-weight: 900;
}

.progress-card div, .loading-card div{
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.progress-card i, .loading-card i{
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffcf48, #58c56c);
  transition: width 0.28s ease;
}

.scene{
  position: relative;
  width: 100%;
  aspect-ratio: 1.34 / 1;
  min-height: 410px;
  overflow: hidden;
  border: 5px solid rgba(67, 88, 38, 0.55);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(24, 88, 62, 0.04), rgba(24, 88, 62, 0.04)),
    url("../../assets/animal-hidden-safari/sunny-background-block-v1.png") center / cover no-repeat,
    #84d75f;
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.24),
    0 18px 34px rgba(48, 82, 63, 0.2);
}

.scene[data-theme="river"]{
  background:
    linear-gradient(180deg, rgba(27, 99, 122, 0.02), rgba(27, 99, 122, 0.04)),
    url("../../assets/animal-hidden-safari/river-background-block-v1.png") center / cover no-repeat,
    #84d75f;
}

.scene[data-theme="pond"]{
  background:
    linear-gradient(180deg, rgba(28, 118, 116, 0.02), rgba(60, 142, 89, 0.04)),
    url("../../assets/animal-hidden-safari/pond-background-block-v1.png") center / cover no-repeat,
    #86d879;
}

.scene[data-theme="sunset"]{
  background:
    linear-gradient(180deg, rgba(142, 82, 35, 0.02), rgba(92, 78, 28, 0.04)),
    url("../../assets/animal-hidden-safari/sunset-background-block-v1.png") center / cover no-repeat,
    #f2b94e;
}

.scene[data-theme="jungle"]{
  background:
    linear-gradient(180deg, rgba(18, 75, 39, 0.04), rgba(12, 57, 31, 0.08)),
    url("../../assets/animal-hidden-safari/jungle-background-block-v1.png") center / cover no-repeat,
    #367d49;
}

.scene[data-theme="lookout"]{
  background:
    linear-gradient(180deg, rgba(34, 98, 143, 0.02), rgba(159, 103, 34, 0.08)),
    url("../../assets/animal-hidden-safari/lookout-background-block-v1.png") center / cover no-repeat,
    #c89948;
}

.float-layer{
  position: absolute;
  pointer-events: none;
}

.targets-layer{
  position: absolute;
  pointer-events: none;
}

.targets-layer, .float-layer{
  inset: 0;
}

.target{
  position: absolute;
  width: var(--size);
  height: var(--size);
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #1e3228;
  transform: translate(-50%, -50%);
  opacity: 0.76;
  filter: drop-shadow(0 6px 5px rgba(31, 68, 41, 0.22)) saturate(0.92);
  overflow: visible;
  pointer-events: auto;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  isolation: isolate;
}

.target-hit-area{
  position: absolute;
  inset: -6px;
  border-radius: inherit;
}

.target:focus-visible{
  outline: 3px solid #fff4a8;
  outline-offset: 4px;
}

.target-animal{
  position: relative;
  z-index: 1;
  filter: saturate(0.95) contrast(0.96);
}

.target-cover{
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: -9%;
  width: 118%;
  height: 58%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform: translateX(-50%);
  opacity: 0.9;
  filter: drop-shadow(0 4px 4px rgba(31, 68, 41, 0.16));
}

.target-cover-leaf{
  top: -7%;
  bottom: auto;
  width: 108%;
  height: 52%;
  opacity: 0.84;
}

.target-cover-water{
  bottom: -5%;
  height: 50%;
  opacity: 0.82;
}

.target-cover-dust{
  bottom: -8%;
  height: 48%;
  opacity: 0.72;
}

.target:active{
  transform: translate(-50%, -50%) scale(0.92);
  opacity: 1;
}

.target.found{
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.55) rotate(12deg);
}

.target.hint{
  animation: hint-pulse 0.72s ease-in-out infinite alternate;
}

.hint-feedback{
  display: none;
  position: absolute;
  z-index: 4;
  left: -48%;
  top: -48%;
  width: 196%;
  height: 196%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 4px 8px rgba(117, 76, 10, 0.28));
}

.target.hint .hint-feedback{
  display: block;
  animation: hint-ring-turn 4.8s linear infinite;
}

.scene.is-ordered .target.is-current:not(.found){
  box-shadow: 0 0 0 3px rgba(255, 244, 168, 0.94), 0 0 18px rgba(255, 214, 77, 0.72);
}

.scene.is-ordered .target.is-waiting:not(:focus-visible){
  opacity: 0.82;
}

.target.wrong-order{
  animation: safari-wrong-order 0.34s ease-in-out;
}

.target.is-decoy:not(.found) .target-animal{
  filter: saturate(0.72) contrast(0.9);
}

.scene.is-camouflage .target:not(:focus-visible):not(.hint) .target-animal{
  opacity: 0.76;
  filter: saturate(0.78) contrast(0.9);
}

.scene.is-camouflage .target-cover{
  width: 110%;
  height: 56%;
  opacity: 0.92;
}

.scene.is-drift .target:not(.found):not(.hint){
  animation: safari-drift 3.4s ease-in-out var(--drift-delay, 0s) infinite alternate;
}

@keyframes safari-drift {
  from{ transform: translate(calc(-50% - 5px), calc(-50% + 2px)); }
  to{ transform: translate(calc(-50% + 5px), calc(-50% - 2px)); }
}

@keyframes safari-wrong-order {
  0%, 100%{ transform: translate(-50%, -50%); }
  33%{ transform: translate(calc(-50% - 5px), -50%); }
  66%{ transform: translate(calc(-50% + 5px), -50%); }
}

.image-feedback{
  position: absolute;
  z-index: 18;
  width: var(--feedback-size);
  height: var(--feedback-size);
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.image-feedback-found{
  animation: found-burst 0.72s ease-out forwards;
}

.float-text{
  position: absolute;
  z-index: 20;
  transform: translate(-50%, -50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #234033;
  font-weight: 1000;
  pointer-events: none;
  animation: float-up 0.9s ease-out forwards;
}

.target-panel{
  border-radius: 22px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 22px rgba(54, 91, 69, 0.16);
}

.target-panel > div:first-child{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
}

.target-status{
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  color: rgba(35, 64, 51, 0.72);
}

.target-status b{
  min-width: 58px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 207, 72, 0.34);
  color: #234033;
  font-size: 0.78rem;
}

.target-list{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.target-chip{
  min-height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  gap: 2px;
  background: linear-gradient(180deg, #fff9db, #e7f7d6);
  box-shadow: inset 0 -4px rgba(48, 105, 54, 0.1);
  font-weight: 900;
  text-align: center;
}

.target-chip b{
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}

.chip-animal{
  filter: drop-shadow(0 3px 4px rgba(41, 80, 48, 0.18));
}

.target-chip span{
  font-size: 0.8rem;
  line-height: 1;
}

.target-chip.done{
  opacity: 0.46;
  text-decoration: line-through;
}

.result-panel, .loading-panel{
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(35, 64, 51, 0.44);
  backdrop-filter: blur(8px);
}

.safari-pause-panel{
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(35, 64, 51, 0.52);
  backdrop-filter: blur(8px);
}

.safari-pause-panel.hidden{ display: none !important; }

.safari-pause-card{
  width: min(100%, 330px);
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 24px;
  background: #fff9df;
  color: #234033;
  box-shadow: 0 22px 48px rgba(25, 52, 40, 0.28);
  text-align: center;
}

.safari-pause-card strong{ font-size: 1.45rem; }
.safari-pause-card p{ margin: 0; font-weight: 800; line-height: 1.4; }
.safari-pause-actions{ display: grid; gap: 10px; }
.safari-pause-card button{ min-height: 50px; border: 0; border-radius: 12px; background: #ffd56d; color: #234033; font: inherit; font-weight: 1000; }
.safari-pause-card #leaveHabitatBtn{ background: #e8efe7; }

.result-card, .loading-card{
  width: min(100%, 430px);
  border-radius: 26px;
  padding: 22px;
  display: grid;
  gap: 12px;
  text-align: center;
  background: #fff9df;
  color: #234033;
  box-shadow: 0 22px 48px rgba(25, 52, 40, 0.28);
}

.result-card strong{
  font-size: 1.5rem;
}

.result-celebration{
  display: block;
  width: min(68vw, 188px);
  max-height: 156px;
  margin: -18px auto -8px;
  object-fit: contain;
  pointer-events: none;
}

.stars{
  font-size: 2rem;
  color: #ffb91f;
  letter-spacing: 0;
}

.skill-report{
  display: grid;
  gap: 7px;
  border-radius: 18px;
  padding: 12px;
  background: rgba(89, 183, 99, 0.15);
  text-align: left;
}

.skill-report > b{
  text-align: center;
}

.skill-report dl{
  display: grid;
  gap: 5px;
  margin: 0;
}

.skill-report dl div{
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 8px;
  align-items: center;
}

.skill-report dt{
  font-weight: 800;
}

.skill-report dd{
  margin: 0;
  text-align: right;
}

.skill-report p{
  margin: 0;
  padding-top: 6px;
  border-top: 1px solid rgba(35, 64, 51, 0.22);
  font-weight: 800;
  text-align: center;
}

.result-card button, .result-card a{
  display: grid;
  place-items: center;
}

.result-card .result-primary-action{
  background: linear-gradient(#ffe98a, #ffc43d);
  color: #3d2b08;
  box-shadow: 0 6px 0 #a96f18, 0 10px 22px rgba(84, 55, 8, 0.24);
}

.result-card button:disabled{
  cursor: not-allowed;
  opacity: 0.52;
  box-shadow: none;
}

.loading-card i{
  width: 0%;
}

.hidden{
  display: none !important;
}

@keyframes float-up {
  from{
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  to{
    opacity: 0;
    transform: translate(-50%, -140%);
  }
}

@keyframes hint-pulse {
  from{
    transform: translate(-50%, -50%) scale(1);
  }
  to{
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@keyframes hint-ring-turn {
  to{
    transform: rotate(360deg);
  }
}

@keyframes found-burst {
  0%{
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45) rotate(-8deg);
  }
  24%{
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(0deg);
  }
  100%{
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35) rotate(8deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .target.hint, .target.hint .hint-feedback, .image-feedback-found, .scene.is-drift .target:not(.found):not(.hint), .target.wrong-order{
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}

@media (max-width: 560px) {
  html:has(body.safari-playing), body.safari-playing{ overflow: hidden !important; touch-action: none; }
  body.safari-playing .topbar, body.safari-playing .menu-panel, body.safari-playing .game-page-info{ display: none !important; }
  body.safari-playing .progress-card{ grid-column:auto; grid-row:auto; }
  body.safari-playing .scene{ min-height:0; height:auto; }
  body.safari-playing .target-panel{ padding: 8px; gap: 6px; }
  body.safari-playing .target-list{ grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  body.safari-playing .target-chip{ min-height: 46px; grid-template-columns:32px minmax(0,1fr); gap:4px; padding:4px; text-align:left; }
  body.safari-playing .target-chip b{ width:32px; height:32px; }
  body.safari-playing .target-chip span{ font-size:0.7rem; overflow-wrap:anywhere; }
  .topbar{
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .language-picker{
    grid-column: 1 / -1;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .scene{
    min-height: 360px;
  }

  .target-list{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Final fixed-ratio override remains after legacy responsive rules. */
html:has(body.safari-playing), body.safari-playing{ width:100%; height:100dvh; overflow:hidden !important; }
body.safari-playing .topbar, body.safari-playing .menu-panel, body.safari-playing .game-page-info{ display:none !important; }

/* Battle Canvas geometry is independent from the ratio-sensitive seek scene. */
html:has(body.safari-playing), body.safari-playing{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  overflow: hidden !important;
  touch-action: none;
}

body.safari-playing .progress-card{
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 14px;
}

body.safari-playing .progress-card span{
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.safari-playing .progress-card div{
  height: 8px;
}

body.safari-playing .hint-btn{
  width: 72px;
  min-width: 72px;
  height: 40px;
  min-height: 48px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

body.safari-playing .scene{
  width: min(100%, 430px);
  height: auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  align-self: center;
  justify-self: center;
}

body.safari-playing .target-panel{
  height: 160px;
  min-height: 160px;
  padding: 6px;
  gap: 5px;
  overflow: hidden;
}

body.safari-playing .target-panel > div:first-child{
  height: 22px;
  min-height: 22px;
  font-size: 11px;
  line-height: 14px;
}

body.safari-playing .target-status, body.safari-playing .target-status b{
  font-size: 10px;
  line-height: 13px;
}

body.safari-playing .target-list{
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  min-height: 0;
}

body.safari-playing .target-chip{
  grid-template-columns: 32px minmax(0, 1fr);
  min-width: 0;
  min-height: 54px;
  height: 54px;
  padding: 4px;
  gap: 4px;
  text-align: left;
}

body.safari-playing .target-chip b{
  width: 32px;
  height: 32px;
}

body.safari-playing .target-chip span{
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 14px;
  overflow-wrap: anywhere;
}

body.safari-playing .weightplay-version-badge, body.safari-playing .sound-toggle, body.safari-playing .wp-tutorial-button, body.safari-playing .wp-shell-settings, body.safari-playing .wp-generated-main-header, body.safari-playing.safari-result .wp-generated-battle-header{
  display: none !important;
}

/* Kids keeps one logical Battle composition in every orientation. */
@media (max-height: 430px){
  body.safari-playing .scene,
  body.safari-playing .target-panel {
    grid-area: auto !important;
  }

  body.safari-playing .target-chip b {
    width: 32px !important;
    height: 32px !important;
  }

  body.safari-playing .target-chip span {
    font-size: 11px !important;
    line-height: 14px !important;
  }
}

body.safari-playing .result-panel{
  position: fixed !important;
  inset: auto !important;
  left: var(--safari-frame-left, 0) !important;
  top: 0 !important;
  width: var(--safari-logical-width, 390px) !important;
  height: var(--safari-logical-height, 693.333px) !important;
  max-height: none !important;
  padding: 18px !important;
  overflow: hidden !important;
  transform: scale(var(--safari-frame-scale, 1)) !important;
  transform-origin: top left !important;
}

body.safari-playing .result-card{
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 12px;
  gap: 7px;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  overflow-x: hidden;
  overflow-y: hidden;
}

body.safari-playing .result-card strong{
  font-size: 1.25rem;
}

body.safari-playing #resultText{
  max-height: min(18vh, 108px);
  overflow: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
  padding-inline: 4px;
}

body.safari-playing .result-celebration{
  width: 104px;
  max-height: 72px;
  margin: -6px auto -3px;
}

body.safari-playing .stars{
  font-size: 1.65rem;
}

body.safari-playing .skill-report{
  gap: 4px;
  padding: 8px;
  align-self: start;
}

body.safari-playing .result-actions{
  display: grid;
  grid-template-rows: repeat(3, minmax(48px, 1fr));
  gap: 7px;
}

body.safari-playing .result-card button, body.safari-playing .result-card a{
  min-height: 48px;
}

@media (max-height: 430px) {

  body.safari-playing .pause-btn{
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    font-size: 10px !important;
  }

  body.safari-playing .hint-btn{
    width: 72px !important;
    min-width: 72px !important;
    height: 44px !important;
    min-height: 44px !important;
    font-size: 11px !important;
    line-height: 14px !important;
  }

  body.safari-playing .progress-card{
    font-size: 11px !important;
    line-height: 14px !important;
  }

  body.safari-playing .progress-card div{
    height: 8px !important;
  }

  body.safari-playing .target-panel > div:first-child{
    height: 22px !important;
    min-height: 22px !important;
    font-size: 11px !important;
    line-height: 14px !important;
  }

  body.safari-playing .target-status, body.safari-playing .target-status b{
    font-size: 10px !important;
    line-height: 13px !important;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  body.safari-playing .result-panel{
    padding: 10px !important;
  }

  body.safari-playing .result-card{
    position: absolute;
    inset: 10px;
    width: auto;
    height: auto;
    grid-template-columns: 170px minmax(0, 1fr) 170px;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 7px 12px;
    padding: 12px;
    align-content: center;
    overflow: hidden;
  }

  body.safari-playing .result-celebration{
    grid-column: 1;
    grid-row: 1 / 5;
    width: 160px;
    max-height: 210px;
    margin: auto;
  }

  body.safari-playing #resultTitle{ grid-column: 2; grid-row: 1; }
  body.safari-playing .stars{ grid-column: 2; grid-row: 2; }
  body.safari-playing #resultText{ grid-column: 2; grid-row: 3; }
  body.safari-playing .skill-report{ grid-column: 2; grid-row: 4; min-height: 0; }
  body.safari-playing .result-actions{
    position: absolute;
    right: 12px;
    top: 50%;
    width: 170px;
    transform: translateY(-50%);
    grid-template-rows: repeat(3, 48px);
  }

  body.safari-playing .result-card button, body.safari-playing .result-card a{
    min-height: 48px;
    font-size: 15px;
  }
}

/* Battle gameplay lives inside the shared frame's logical Canvas. */
body.safari-playing #battleContent {
  display:grid;
  grid-template-rows:minmax(0,1fr) 160px;
  gap:6px;
  min-width:0;
  min-height:0;
  overflow:hidden;
}
body.safari-playing.safari-result #battleContent { visibility:hidden; }
body.safari-playing.safari-result [data-wp-frame-header="battle"] { visibility:hidden; }
body:is(.wp-frame-stage-active,.wp-frame-battle-active) .game-page-info,
body:is(.wp-frame-stage-active,.wp-frame-battle-active) .wp-tutorial-button { display:none!important; }
body.safari-playing #scene {
  width:min(100%,430px);
  height:auto;
  min-width:0;
  min-height:0;
  max-width:100%;
  max-height:100%;
  aspect-ratio:1;
  justify-self:center;
  align-self:end;
}
body.safari-playing #resultPanel {
  position:absolute!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  max-height:none!important;
  padding:18px!important;
  overflow:hidden!important;
  transform:none!important;
  z-index:90;
}
@media (max-height:430px) and (orientation:landscape) {
  body.safari-playing #battleContent {
    grid-template-columns:minmax(0,1fr) 220px;
    grid-template-rows:minmax(0,1fr);
    align-items:stretch;
  }
  body.safari-playing #scene {
    width:min(100%, calc(100vh - 106px)) !important;
    height:auto !important;
    justify-self:center;
    align-self:center;
  }
  body.safari-playing .target-panel { height:100%; min-height:0; }
  body.safari-playing .target-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body.safari-playing .target-chip { min-height:44px; height:44px; grid-template-columns:26px minmax(0,1fr); }
  body.safari-playing .target-chip b { width:26px; height:26px; }
}
/* The Battle Canvas shared stylesheet has legacy direct-child tracks for
   older Hidden Safari markup. The I9 content is now nested under #battleContent. */
body.wp-logical-battle-active.safari-playing #battleContent > #scene,
body.wp-logical-battle-active.safari-playing #battleContent > .target-panel {
  grid-area:auto!important;
  grid-column:auto!important;
  grid-row:auto!important;
}
body.wp-logical-battle-active.safari-playing #battleContent > #scene { align-self:end!important; }
