:root {
  color-scheme: light;
  font-family: "Trebuchet MS", Arial, sans-serif;
  background: #24433a;
  color: #21331f;
  --cross-river-game-width: min(100%, 1024px);
  --cross-river-game-top: 0px;
}

* {
  box-sizing: border-box;
}

body.cross-river-standalone {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 12% 18%, rgba(244, 213, 105, 0.26), transparent 24%),
    linear-gradient(145deg, #183e46 0%, #276248 47%, #6f8844 100%);
}

button {
  font: inherit;
}

.cross-river-game-stage {
  width: 100%;
  padding-top: var(--cross-river-game-top);
  display: flex;
  justify-content: center;
  direction: ltr;
}

.game-shell {
  width: var(--cross-river-game-width);
  max-width: none;
  margin-inline: auto;
  direction: ltr;
}

.rotate-notice {
  display: none;
}

.game-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 715;
  direction: ltr;
  overflow: hidden;
  border: 4px solid #f2f0dc;
  border-radius: 8px;
  background: #b8ddb1;
  box-shadow: 0 22px 55px rgba(5, 22, 18, 0.42);
}

.layer,
.icon-btn img,
.score-frame img,
.framework img,
.start-btn img {
  display: block;
  width: 100%;
  height: 100%;
}

.layer {
  position: absolute;
  left: 0;
  pointer-events: none;
  user-select: none;
}

.top-bar {
  top: 0;
  height: 13.57%;
}

.picture-board {
  top: 12.87%;
  height: 73.57%;
  object-fit: cover;
}

.bottom-bar {
  bottom: 0;
  height: 13.29%;
  object-fit: cover;
  object-position: top;
}

.icon-btn {
  position: absolute;
  z-index: 8;
  width: 3.71%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-btn:focus-visible,
.mode-btn:focus-visible,
.info-close:focus-visible,
.start-btn:focus-visible {
  outline: 3px solid #ffdf5e;
  outline-offset: 3px;
}

.answers button:focus,
.answers button:focus-visible,
.answers button:active {
  outline: none;
}

.sound-btn {
  left: 4%;
  top: 2.94%;
}

.info-btn {
  left: 95.7%;
  top: 2.94%;
}

.replay-btn {
  left: 91.11%;
  top: 2.94%;
}

.mode-btn {
  position: absolute;
  z-index: 9;
  top: 0.56%;
  width: 15.43%;
  height: 11.05%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.mode-btn img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.mode-btn.is-selected {
  filter: saturate(1.08) brightness(0.98);
  transform: translateY(1px);
}

.mode-btn.is-hidden {
  display: none;
}

.mode-add {
  left: 8.5%;
}

.mode-add:not(.is-selected) {
  left: 8.99%;
}

.mode-times {
  left: 75.68%;
  top: 0.98%;
}

.score-frame {
  position: absolute;
  z-index: 7;
  width: 9.96%;
  height: 6.43%;
  top: 2.94%;
  display: grid;
  place-items: center;
  color: #284024;
  font-weight: 400;
  font-size: clamp(12px, 2.1vw, 24px);
}

.score-frame img,
.framework img {
  grid-area: 1 / 1;
}

.score-frame span,
.framework span {
  grid-area: 1 / 1;
  z-index: 1;
}

.left-score {
  left: 12.3%;
}

.right-score {
  left: 77.73%;
}

.framework {
  position: absolute;
  z-index: 7;
  left: 24.51%;
  top: 0.28%;
  width: 50.68%;
  height: 10.77%;
  display: grid;
  place-items: center;
  color: #32542d;
  font-weight: 400;
  font-size: clamp(16px, 3.2vw, 34px);
  text-align: center;
}

.squirrel {
  --sx: 0.1%;
  --sy: 48.39%;
  --sw: 12.21%;
  --sh: 16.36%;
  position: absolute;
  z-index: 6;
  left: var(--sx);
  top: var(--sy);
  width: var(--sw);
  height: var(--sh);
  transition: transform 260ms ease;
}

.squirrel.is-jumping {
  transition: none;
}

.squirrel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.squirrel.wet {
  transform: translateY(18%) rotate(-10deg);
}

.math-panel {
  position: absolute;
  z-index: 9;
  left: 23.5%;
  bottom: 0.95%;
  width: 53%;
  height: 12.25%;
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 1.35fr;
  grid-template-rows: minmax(18px, 0.35fr) minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 0;
  align-items: center;
  padding: 6px 15px 8px;
  border: 2px solid rgba(80, 130, 68, 0.52);
  border-radius: 8px;
  background: rgba(248, 255, 236, 0.89);
  box-shadow: 0 8px 18px rgba(29, 58, 36, 0.18);
  direction: ltr;
  text-align: left;
}

.question-meta {
  grid-column: 1 / -1;
  color: #5c6f3d;
  font-size: clamp(11px, 1.4vw, 15px);
  font-weight: 400;
  line-height: 1;
}

.question {
  align-self: center;
  color: #263b24;
  font-size: clamp(19px, 3.1vw, 34px);
  font-weight: 400;
  line-height: 1;
}

.answers {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.answers button {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border: 2px solid #5e954f;
  border-radius: 8px;
  color: #23361f;
  background: #fff6b7;
  box-shadow: inset 0 -4px 0 rgba(129, 99, 30, 0.13);
  font-size: clamp(18px, 2.5vw, 29px);
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.answers button:hover {
  background: #ffe382;
}

.answers button:disabled {
  cursor: default;
  opacity: 0.72;
}

.start-btn {
  position: absolute;
  z-index: 10;
  left: 39.94%;
  top: 74.69%;
  width: 19.92%;
  height: 11.75%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #27401d;
  font-size: clamp(16px, 2.7vw, 30px);
  font-weight: 400;
  cursor: pointer;
}

.start-btn span {
  position: absolute;
  inset: 0 0 8%;
  display: grid;
  place-items: center;
}

.start-btn.is-hidden {
  display: none;
}

.status-line {
  display: none;
}

.info-modal {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 46, 39, 0.48);
}

.info-modal.is-hidden {
  display: none;
}

.info-card {
  position: relative;
  width: min(72%, 610px);
  padding: 24px 30px 26px;
  border: 3px solid rgba(87, 139, 71, 0.72);
  border-radius: 8px;
  background: rgba(250, 255, 237, 0.96);
  color: #263b24;
  box-shadow: 0 18px 40px rgba(12, 39, 31, 0.36);
}

.info-card h2 {
  margin: 0 44px 14px 0;
  color: #2f5f34;
  font-size: clamp(24px, 3.3vw, 38px);
  line-height: 1.05;
}

.info-card p {
  margin: 0 0 10px;
  font-size: clamp(15px, 1.9vw, 21px);
  font-weight: 700;
  line-height: 1.35;
}

.info-card[dir="rtl"] {
  text-align: right;
}

.info-card[dir="rtl"] h2 {
  margin: 0 0 14px 44px;
}

.info-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  aspect-ratio: 1;
  border: 2px solid #6a9a59;
  border-radius: 50%;
  color: #2d4b25;
  background: #fff4aa;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 720px) {
  body.cross-river-standalone {
    padding: 8px;
  }

  .math-panel {
    left: 14%;
    width: 72%;
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 7px 9px;
  }

  .answers button {
    min-height: 30px;
  }

  .status-line {
    display: none;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  body.cross-river-standalone {
    min-height: 100dvh;
    padding: 4px;
    overflow: hidden;
  }

  .game-shell {
    width: min(var(--cross-river-game-width), 100vw - 8px, calc((100dvh - 8px) * 1024 / 715));
  }

  .game-canvas {
    border-width: 2px;
    border-radius: 4px;
    box-shadow: none;
  }

  .icon-btn {
    min-width: 0;
  }

  .mode-btn {
    min-width: 0;
    width: 13.2%;
  }

  .mode-add {
    left: 8.99%;
  }

  .mode-add:not(.is-selected) {
    left: 9.48%;
  }

  .mode-times {
    left: 77.35%;
  }

  .score-frame {
    font-size: clamp(12px, 2.6vw, 18px);
  }

  .framework {
    font-size: clamp(15px, 3.2vw, 24px);
  }

  .math-panel {
    left: 17.5%;
    width: 65%;
    bottom: 0.89%;
    height: 12.25%;
    grid-template-columns: minmax(138px, 1.15fr) 1.35fr;
    grid-template-rows: 12px 1fr;
    padding: 1px 10px 6px;
  }

  .question-meta {
    font-size: clamp(10px, 1.6vw, 13px);
  }

  .question {
    transform: translateY(-2px);
    font-size: clamp(18px, 3.5vw, 26px);
  }

  .answers {
    transform: translateY(-4px);
    gap: 5px;
  }

  .answers button {
    min-height: 24px;
    border-radius: 6px;
    font-size: clamp(16px, 2.8vw, 22px);
  }

  .start-btn {
    font-size: clamp(15px, 3.2vw, 23px);
  }

  .info-card {
    width: min(78%, 560px);
    max-height: 86dvh;
    overflow: auto;
    padding: 18px 24px 18px;
  }

  .info-card h2 {
    font-size: clamp(22px, 4vw, 30px);
  }

  .info-card p {
    font-size: clamp(14px, 2.3vw, 18px);
  }
}

@media (orientation: landscape) {
  body.mobile-layout {
    width: 100vw;
    min-height: 100dvh;
    margin: 0;
    overflow: hidden;
  }

  body.mobile-layout #navHeader {
    position: fixed;
    top: 14.4dvh;
    right: 0;
    z-index: 30;
    width: auto;
    height: auto;
    background: transparent;
  }

  body.mobile-layout #navHeader > div,
  body.mobile-layout #portriatMenu,
  body.mobile-layout #navbar_comp {
    position: static;
    width: auto;
    height: auto;
    background: transparent !important;
  }

  body.mobile-layout #navHeader .row,
  body.mobile-layout #nuvHeSpace,
  body.mobile-layout #logoPlace,
  body.mobile-layout #navbar_comp .navbar-brand {
    display: none;
  }

  body.mobile-layout #toggler {
    position: fixed !important;
    top: 14.4dvh;
    right: 0 !important;
    left: auto !important;
    width: 38px !important;
    height: 38px;
    padding: 4px;
    border: 2px solid rgba(60, 105, 48, 0.85);
    border-radius: 8px;
    background: rgba(247, 255, 223, 0.88);
    box-shadow: 0 2px 8px rgba(18, 45, 18, 0.24);
  }

  body.mobile-layout #collapsibleNavbar {
    position: fixed !important;
    top: calc(14.4dvh + 44px);
    right: 0 !important;
    left: auto !important;
    width: 190px;
    padding: 10px 12px;
    border: 2px solid rgba(78, 126, 58, 0.7);
    border-radius: 8px;
    background: rgba(247, 255, 223, 0.96);
    box-shadow: 0 8px 22px rgba(18, 45, 18, 0.28);
  }

  body.mobile-layout #collapsibleNavbar,
  body.mobile-layout #collapsibleNavbar #siteLinks,
  body.mobile-layout #collapsibleNavbar #langPlace,
  body.mobile-layout #collapsibleNavbar .navbar-nav {
    background: rgba(222, 250, 188, 0.96) !important;
  }

  body.mobile-layout #siteLinks,
  body.mobile-layout #langPlace {
    position: static;
    display: block;
    width: 100%;
    margin: 0;
  }

  body.mobile-layout #collapsibleNavbar .A {
    display: block;
    padding: 4px 0;
    color: #294724;
  }

  body.mobile-layout #collapsibleNavbar .demoNav {
    color: #e5332f !important;
  }

  body.mobile-layout #langPlace select {
    position: static !important;
    width: 100% !important;
    margin-top: 6px;
  }

  body.mobile-layout .cross-river-game-stage {
    position: fixed;
    inset: 0;
    z-index: 1;
    width: 100vw;
    height: 100dvh;
    padding-top: 0;
  }

  body.mobile-layout .game-shell {
    width: 100vw;
    height: 100dvh;
    margin: 0;
  }

  body.mobile-layout .game-canvas {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
  }

  body.mobile-layout .top-bar,
  body.mobile-layout .picture-board,
  body.mobile-layout .bottom-bar {
    object-fit: fill;
  }

  body.mobile-layout .score-frame {
    top: 1.35%;
    height: 5.9%;
    font-size: clamp(16px, 3.2vw, 26px);
  }

  body.mobile-layout:not(.game-started) .score-frame {
    display: none;
  }

  body.mobile-layout.game-started .score-frame {
    display: grid;
  }

  body.mobile-layout .framework {
    left: 33.2%;
    top: 1.2%;
    width: 33.6%;
    height: 3.28%;
    font-size: clamp(18px, 3.4vw, 28px);
    line-height: 1;
  }

  body.mobile-layout .framework img {
    object-fit: fill;
  }

  body.mobile-layout .math-panel {
    grid-template-rows: 1fr;
  }

  body.mobile-layout .question-meta {
    display: none;
  }

  body.mobile-layout .question {
    transform: none;
    font-size: clamp(24px, 4.4vw, 38px);
  }

  body.mobile-layout .answers {
    transform: none;
  }

  body.mobile-layout .answers button {
    font-size: clamp(22px, 3.8vw, 34px);
  }

  body.mobile-layout #calTaitel {
    display: none;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  body.cross-river-standalone {
    padding: 0;
    overflow: hidden;
  }

  .game-shell {
    width: min(var(--cross-river-game-width), 100vw);
    height: 100dvh;
    display: grid;
    place-items: center;
  }

  .game-canvas {
    width: min(92vw, 52vh);
    opacity: 0.28;
    pointer-events: none;
  }

  .rotate-notice {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(20, 57, 45, 0.82);
  }

  .rotate-card {
    width: min(86vw, 360px);
    padding: 22px 24px;
    border: 3px solid rgba(255, 239, 143, 0.88);
    border-radius: 8px;
    background: #f8ffed;
    color: #284024;
    text-align: center;
    box-shadow: 0 18px 38px rgba(6, 28, 22, 0.34);
  }

  .rotate-card strong,
  .rotate-card span {
    display: block;
  }

  .rotate-card strong {
    margin-bottom: 8px;
    font-size: 25px;
    line-height: 1.1;
  }

  .rotate-card span {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.35;
  }
}
