.game-root,
.game-root * {
  box-sizing: border-box;
}

.game-root {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #edf4f1;
  color: #294861;
}

.story-sequencing-game {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background-color: #edf4f1;
  background-image:
    linear-gradient(rgba(237, 244, 241, 0.76), rgba(237, 244, 241, 0.83)),
    var(--story-sequencing-background-image, none);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  cursor: url("/static/img/cursors/cursor_cat.54234ab9b215.png") 0 0, auto;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.story-sequencing-title {
  position: absolute;
  top: max(13px, calc(env(safe-area-inset-top) + 10px));
  left: 50%;
  z-index: 2;
  max-width: min(calc(100% - 230px), 1200px);
  margin: 0;
  overflow: hidden;
  color: #294861;
  font-size: clamp(16px, 2vw, 28px);
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.story-navigation {
  position: absolute;
  right: max(10px, calc(env(safe-area-inset-right) + 8px));
  bottom: max(10px, calc(env(safe-area-inset-bottom) + 8px));
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 0.45vw, 6px);
  max-width: calc(100% - 20px);
  padding: 4px 7px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 25px rgba(37, 55, 64, 0.11);
  backdrop-filter: blur(8px);
}

.story-navigation button,
.story-level-switcher button,
.story-review-arrow,
.story-review-close,
.story-sequencing-card button,
.story-sequencing-card a {
  cursor: url("/static/img/cursors/cursor_hand.7271d4ef0443.png") 12 4, pointer;
}

.story-navigation button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: clamp(29px, 2.5vw, 38px);
  height: clamp(29px, 2.5vw, 38px);
  border: 2px solid #c6d4de;
  border-radius: 999px;
  padding: 0;
  background: #f8fbfc;
  color: #587087;
  font: inherit;
  font-size: clamp(12px, 1.1vw, 16px);
  font-weight: 900;
  line-height: 1;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.story-navigation button:hover {
  border-color: #80a6ca;
  transform: translateY(-2px);
}

.story-navigation button.is-current {
  border-color: #4e89c9;
  background: #4e89c9;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(78, 137, 201, 0.16);
  transform: scale(1.08);
}

.story-navigation button.is-complete {
  border-color: #5baa83;
  background: #e0f5e9;
  color: #247052;
}

.story-navigation button.is-current.is-complete {
  border-color: #4e89c9;
  background: #4e89c9;
  color: #fff;
}

.story-stage {
  position: absolute;
  inset: max(66px, calc(env(safe-area-inset-top) + 58px))
    max(8px, env(safe-area-inset-right))
    max(62px, calc(env(safe-area-inset-bottom) + 54px))
    max(8px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  padding: 0;
}

.story-live-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-board-viewport {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.story-board {
  --story-board-gap: clamp(2px, 0.28vw, 5px);
  display: grid;
  grid-template-columns: repeat(var(--story-columns, 2), minmax(0, 1fr));
  grid-template-rows: repeat(var(--story-rows, 1), minmax(0, 1fr));
  gap: var(--story-board-gap);
  width: 1px;
  height: 1px;
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  border: clamp(3px, 0.42vw, 6px) solid rgba(255, 255, 255, 0.84);
  border-radius: clamp(14px, 1.6vw, 22px);
  background: rgba(255, 255, 255, 0.38);
  box-shadow: 0 18px 38px rgba(37, 55, 64, 0.15);
  transition: opacity 220ms ease, transform 220ms ease;
}

.story-board[hidden] {
  display: none;
}

.story-board.is-entering .story-panel {
  animation: story-panel-arrive 520ms cubic-bezier(.22, .7, .25, 1) var(--story-panel-delay, 0ms) both;
}

.story-board[data-layout="triangle"] .story-panel:nth-child(3) {
  grid-row: 2;
  grid-column: 1 / -1;
  justify-self: center;
  width: calc((100% - var(--story-board-gap)) / 2);
}

.story-panel {
  position: relative;
  display: block;
  z-index: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: clamp(9px, 1vw, 15px);
  padding: 0;
  background-color: #f1ece4;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02), rgba(47, 71, 80, 0.08)), var(--story-panel-image);
  background-position: var(--story-panel-position, 0 0);
  background-repeat: no-repeat;
  background-size: var(--story-background-size, 200% 100%);
  box-shadow: 0 8px 18px rgba(37, 55, 64, 0.14);
  touch-action: manipulation;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, filter 180ms ease;
}

.story-panel:not(:disabled):hover {
  border-color: #80a6ca;
  box-shadow: 0 13px 23px rgba(37, 55, 64, 0.2);
  transform: translateY(-3px);
  z-index: 2;
}

.story-panel.is-selected {
  border-color: #4e89c9;
  box-shadow: 0 0 0 3px rgba(78, 137, 201, 0.18), 0 13px 24px rgba(37, 55, 64, 0.2);
}

.story-panel.is-placed {
  border-color: #65aa82;
  box-shadow: 0 0 0 3px rgba(101, 170, 130, 0.16), 0 10px 20px rgba(73, 136, 102, 0.18);
}

.story-panel.is-solved {
  border-color: #65aa82;
  box-shadow: 0 8px 20px rgba(73, 136, 102, 0.18);
  filter: saturate(1.04);
}

.story-panel.is-wrong {
  border-color: #dc7770;
  box-shadow: 0 0 0 3px rgba(220, 119, 112, 0.18), 0 12px 24px rgba(220, 119, 112, 0.19);
  animation: story-calm-shake 420ms ease;
}

@media (pointer: coarse) {
  .story-panel:not(:disabled):hover {
    transform: none;
  }
}

.story-panel-number {
  position: absolute;
  top: clamp(7px, 1vw, 13px);
  right: clamp(7px, 1vw, 13px);
  display: grid;
  place-items: center;
  width: clamp(31px, 4vw, 52px);
  height: clamp(31px, 4vw, 52px);
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: #4e89c9;
  color: #fff;
  font-size: clamp(17px, 2.1vw, 28px);
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 6px 15px rgba(37, 55, 64, 0.24);
  pointer-events: none;
}

.story-panel.is-solved .story-panel-number {
  background: #5baa83;
}

.story-panel.is-placed .story-panel-number {
  background: #5baa83;
}

.story-panel-number[hidden] {
  display: none;
}

.story-review-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  color: #44627f;
  font-size: 15px;
  font-weight: 850;
}

.story-review-bar[hidden] {
  display: none;
}

.story-review-arrow,
.story-review-close {
  min-width: 42px;
  min-height: 40px;
  border: 2px solid #d4e0e7;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.86);
  color: #3d6688;
  font: inherit;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
}

.story-review-close {
  min-height: 40px;
  border-radius: 12px;
  font-size: 13px;
}

.story-review-arrow:disabled {
  opacity: 0.4;
  cursor: default;
}

.story-level-switcher {
  position: absolute;
  bottom: max(10px, calc(env(safe-area-inset-bottom) + 8px));
  left: max(10px, calc(env(safe-area-inset-left) + 8px));
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 20px);
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 15px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 25px rgba(37, 55, 64, 0.14);
  backdrop-filter: blur(8px);
}

.story-level-switcher button {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0 11px;
  background: transparent;
  color: #536e83;
  font: 800 13px/1 system-ui, sans-serif;
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.story-level-switcher button:hover {
  color: #294861;
  transform: translateY(-1px);
}

.story-level-switcher button.is-current {
  background: #4e89c9;
  color: #fff;
}

.story-sequencing-start,
.story-sequencing-final {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(47, 71, 80, 0.2);
  backdrop-filter: blur(4px);
}

.story-sequencing-start[hidden],
.story-sequencing-final[hidden],
.story-empty[hidden] {
  display: none !important;
}

.story-sequencing-card {
  width: min(100%, 570px);
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 24px;
  padding: clamp(24px, 4vw, 43px);
  background: rgba(255, 253, 248, 0.97);
  color: #294861;
  text-align: center;
  box-shadow: 0 24px 60px rgba(23, 54, 74, 0.24);
}

.story-card-kicker {
  margin: 0 0 8px;
  color: #4f986f;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story-sequencing-card h2 {
  margin: 0;
  font-size: clamp(27px, 4.2vw, 43px);
  font-weight: 950;
  line-height: 1.05;
}

.story-sequencing-card > p:not(.story-card-kicker) {
  margin: 15px auto 0;
  color: #5b7283;
  font-size: clamp(15px, 1.7vw, 19px);
  font-weight: 700;
  line-height: 1.45;
}

.story-sequencing-card button,
.story-sequencing-card a {
  display: inline-flex;
  min-height: 49px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 13px;
  padding: 12px 20px;
  background: #4e89c9;
  color: #fff;
  font: 900 15px/1 system-ui, sans-serif;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(78, 137, 201, 0.24);
}

.story-sequencing-card > button {
  margin-top: 23px;
}

.story-sequencing-final {
  z-index: 11;
}

.story-final-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 23px;
}

.story-final-actions button,
.story-final-actions a {
  margin: 0;
}

.story-final-actions button:nth-child(2) {
  background: #5baa83;
  box-shadow: 0 10px 20px rgba(91, 170, 131, 0.23);
}

.story-final-actions a {
  background: #e6edf4;
  color: #294861;
  box-shadow: none;
}

.story-empty {
  position: absolute;
  inset: 50% 12px auto;
  z-index: 20;
  width: min(600px, calc(100% - 24px));
  margin: auto;
  border-radius: 13px;
  padding: 15px;
  background: #fff;
  color: #a83f35;
  font-weight: 800;
  text-align: center;
  transform: translateY(-50%);
}

@keyframes story-panel-arrive {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes story-calm-shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-2px); }
}

@media (max-width: 620px) {
  .story-sequencing-title {
    display: -webkit-box;
    max-width: calc(100% - 184px);
    max-height: 30px;
    font-size: 13px;
    line-height: 1.08;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .story-navigation {
    right: max(7px, calc(env(safe-area-inset-right) + 5px));
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 6px));
    gap: 2px;
    padding: 3px 5px;
  }

  .story-navigation button {
    width: 24px;
    height: 24px;
    border-width: 1.5px;
    font-size: 10px;
  }

  .story-stage {
    inset: max(62px, calc(env(safe-area-inset-top) + 55px))
      max(7px, env(safe-area-inset-right))
      max(52px, calc(env(safe-area-inset-bottom) + 46px))
      max(7px, env(safe-area-inset-left));
    gap: 3px;
  }

  .story-board {
    gap: 2px;
    border-width: 3px;
    border-radius: 13px;
  }

  .story-panel {
    border-width: 2px;
    border-radius: 8px;
  }

  .story-panel-number {
    top: 5px;
    right: 5px;
    width: 32px;
    height: 32px;
    border-width: 2px;
    font-size: 17px;
  }

  .story-level-switcher {
    bottom: max(8px, calc(env(safe-area-inset-bottom) + 6px));
    left: max(7px, calc(env(safe-area-inset-left) + 5px));
    gap: 2px;
    border-radius: 12px;
    padding: 3px;
  }

  .story-level-switcher button {
    min-height: 30px;
    padding-inline: 4px;
    font-size: 10px;
  }

  .story-sequencing-card {
    border-radius: 20px;
    padding: 23px 17px;
  }

  .story-sequencing-card > p:not(.story-card-kicker) {
    margin-top: 11px;
    font-size: 15px;
  }

  .story-sequencing-card > button {
    margin-top: 18px;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 620px) {
  .story-sequencing-title {
    top: max(8px, calc(env(safe-area-inset-top) + 6px));
    max-width: calc(100% - 190px);
    font-size: 14px;
  }

  .story-navigation {
    right: max(7px, calc(env(safe-area-inset-right) + 5px));
    bottom: max(5px, calc(env(safe-area-inset-bottom) + 4px));
    gap: 2px;
    padding: 3px 5px;
  }

  .story-navigation button {
    width: 25px;
    height: 25px;
    font-size: 10px;
  }

  .story-stage {
    inset: max(49px, calc(env(safe-area-inset-top) + 43px))
      max(8px, env(safe-area-inset-right))
      max(44px, calc(env(safe-area-inset-bottom) + 38px))
      max(8px, env(safe-area-inset-left));
    gap: 3px;
  }

  .story-board {
    gap: 2px;
    border-width: 3px;
    border-radius: 12px;
  }

  .story-panel {
    border-width: 2px;
    border-radius: 8px;
  }

  .story-panel-number {
    top: 4px;
    right: 4px;
    width: 29px;
    height: 29px;
    border-width: 2px;
    font-size: 15px;
  }

  .story-review-bar {
    min-height: 30px;
    gap: 5px;
    font-size: 12px;
  }

  .story-review-arrow,
  .story-review-close {
    min-width: 32px;
    min-height: 29px;
    padding-inline: 9px;
  }

  .story-review-arrow {
    font-size: 20px;
  }

  .story-review-close {
    font-size: 11px;
  }

  .story-level-switcher {
    bottom: max(5px, calc(env(safe-area-inset-bottom) + 4px));
    left: max(7px, calc(env(safe-area-inset-left) + 5px));
    padding: 3px;
  }

  .story-level-switcher button {
    min-height: 28px;
    padding-inline: 8px;
    font-size: 11px;
  }

  .story-sequencing-card {
    width: min(100%, 590px);
    padding: 17px 23px;
  }

  .story-card-kicker {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .story-sequencing-card h2 {
    font-size: clamp(22px, 5.8vh, 31px);
  }

  .story-sequencing-card > p:not(.story-card-kicker) {
    margin-top: 7px;
    font-size: 13px;
    line-height: 1.3;
  }

  .story-sequencing-card > button,
  .story-final-actions {
    margin-top: 12px;
  }

  .story-sequencing-card button,
  .story-sequencing-card a {
    min-height: 38px;
    padding: 9px 14px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-sequencing-game * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
