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

.game-root {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #edf0eb;
  color: #344c39;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.adventure-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #edf0eb center / cover no-repeat;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  cursor: url("/static/img/cursors/cursor_cat.54234ab9b215.png") 0 0, auto;
  touch-action: none;
}

.adventure-shell::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(244, 247, 241, 0.26);
  content: "";
  pointer-events: none;
}

.adventure-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

.adventure-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.adventure-shell button,
.adventure-shell a,
.adventure-shell select {
  cursor: url("/static/img/cursors/cursor_hand.7271d4ef0443.png") 12 4, pointer;
}

.adventure-turn {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(470px, calc(100% - 430px));
  min-width: 270px;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 1px 8px;
  border: 2px solid rgba(255, 255, 255, 0.93);
  border-radius: 999px;
  padding: 5px 15px;
  background: rgba(255, 252, 244, 0.94);
  box-shadow: 0 10px 26px rgba(53, 71, 57, 0.16);
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
}

.adventure-turn-dot {
  grid-row: 1 / 3;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #5f95c7;
  box-shadow: 0 2px 7px rgba(53, 76, 91, 0.25);
}

.adventure-turn-dot.is-second {
  background: #d77a68;
}

.adventure-turn strong {
  align-self: end;
  color: #3f5945;
  font-size: clamp(14px, 1.5vw, 18px);
  line-height: 1.05;
}

.adventure-turn > span:last-child {
  align-self: start;
  color: #6b7a6c;
  font-size: clamp(10px, 1.05vw, 13px);
  font-weight: 800;
  line-height: 1.1;
}

.adventure-legend {
  position: absolute;
  z-index: 5;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 5px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 6px 8px;
  background: rgba(255, 252, 244, 0.92);
  box-shadow: 0 9px 24px rgba(53, 71, 57, 0.14);
  backdrop-filter: blur(8px);
}

.adventure-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #526556;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.adventure-legend i {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
}

.adventure-legend .is-extra i { background: #75b96b; }
.adventure-legend .is-skip i { background: #e5bd52; }
.adventure-legend .is-back i { background: #d97769; }

.adventure-pairs {
  position: absolute;
  z-index: 12;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 6px;
  background: rgba(255, 252, 244, 0.95);
  box-shadow: 0 10px 25px rgba(53, 71, 57, 0.17);
  backdrop-filter: blur(8px);
}

.adventure-pairs-label {
  padding: 0 4px;
  color: #4c624f;
  font-size: clamp(11px, 1.2vw, 15px);
  font-weight: 900;
}

.adventure-pair-buttons {
  display: flex;
  gap: 6px;
}

.adventure-pair,
.adventure-pair-select {
  min-width: 52px;
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  padding: 4px 10px;
  background: rgba(99, 137, 82, 0.13);
  color: #405747;
  font: 900 clamp(14px, 1.7vw, 20px)/1 "Arial Rounded MT Bold", system-ui, sans-serif;
}

.adventure-pair[aria-pressed="true"],
.adventure-pair-select {
  background: #617d52;
  color: #fff;
  box-shadow: 0 6px 14px rgba(70, 97, 62, 0.24);
}

.adventure-pair-select {
  display: none;
  min-width: 84px;
  padding-right: 28px;
  font-size: 14px;
}

.adventure-dice-button {
  position: absolute;
  z-index: 6;
  top: calc(var(--adventure-dice-y, 70%) - var(--adventure-dice-size, 80px) / 2);
  left: calc(var(--adventure-dice-x, 85%) - var(--adventure-dice-size, 80px) / 2);
  width: var(--adventure-dice-size, 80px);
  height: var(--adventure-dice-size, 80px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
}

.adventure-dice-button span {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 252, 244, 0.94);
  color: #4f6653;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(53, 71, 57, 0.14);
  transform: translateX(-50%);
}

.adventure-dice-button:disabled {
  cursor: url("/static/img/cursors/cursor_cat.54234ab9b215.png") 0 0, default;
}

.adventure-dice-button:disabled span {
  opacity: 0.58;
}

.adventure-phone-portrait .adventure-dice-button span,
.adventure-low-landscape .adventure-dice-button span {
  display: none;
}

.adventure-picture-layer {
  position: absolute;
  z-index: 9;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.adventure-picture {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(45vw, 440px);
  height: min(52vh, 390px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  padding: clamp(10px, 2vw, 18px);
  background: #fffdf7;
  box-shadow: 0 24px 65px rgba(40, 49, 40, 0.3);
  transform: translate(-50%, -50%);
  will-change: left, top, opacity, transform, clip-path;
}

.adventure-picture img,
.adventure-picture-fallback {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.adventure-picture-fallback {
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #e5edcc;
  color: #46604a;
  font-size: clamp(82px, 17vw, 170px);
  font-weight: 900;
}

.adventure-picture figcaption {
  color: #48654d;
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  overflow-wrap: anywhere;
}

.adventure-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 76px 18px 70px;
  background: rgba(54, 68, 58, 0.25);
  backdrop-filter: blur(7px);
}

.adventure-overlay[hidden] {
  display: none;
}

.adventure-card {
  width: min(100%, 620px);
  max-height: 100%;
  overflow: auto;
  border: 3px solid #fff;
  border-radius: 28px;
  padding: clamp(23px, 3.5vw, 38px);
  background: #fffbf3;
  color: #4e6350;
  text-align: center;
  box-shadow: 0 24px 65px rgba(46, 61, 49, 0.25);
  scrollbar-width: thin;
}

.adventure-setup-card {
  width: min(100%, 760px);
}

.adventure-card h1,
.adventure-card > h2 {
  margin: 0;
  color: #35513d;
  font-size: clamp(25px, 4vw, 40px);
  line-height: 1.08;
  text-wrap: balance;
}

.adventure-card p {
  max-width: 590px;
  margin: 10px auto 0;
  color: #68776a;
  font-size: clamp(13px, 1.7vw, 17px);
  font-weight: 700;
  line-height: 1.35;
}

.adventure-setup-section {
  margin-top: 17px;
}

.adventure-setup-section h2,
.adventure-piece-pickers h2 {
  margin: 0 0 8px;
  color: #526555;
  font-size: clamp(14px, 1.8vw, 18px);
}

.adventure-mode-choices {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.adventure-mode-choices button {
  min-height: 43px;
  border: 2px solid #d8e1d0;
  border-radius: 13px;
  padding: 7px 17px;
  background: #f5f3e9;
  color: #4e6350;
  font: 900 14px/1.1 "Arial Rounded MT Bold", system-ui, sans-serif;
}

.adventure-mode-choices button[aria-pressed="true"] {
  border-color: #6f9163;
  background: #6f9163;
  color: #fff;
}

.adventure-piece-pickers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: min(100%, 620px);
  margin: 17px auto 0;
}

.adventure-piece-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  gap: 6px;
}

.adventure-piece-choice {
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid #dce4d6;
  border-radius: 13px;
  padding: 4px;
  background: #f6f4ea;
  box-shadow: 0 4px 10px rgba(70, 85, 70, 0.08);
}

.adventure-piece-choice img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.adventure-piece-choice[aria-pressed="true"] {
  border-color: #69885d;
  background: #e8f0df;
  box-shadow: 0 0 0 2px #69885d, 0 7px 15px rgba(70, 97, 62, 0.18);
  transform: translateY(-2px);
}

.adventure-piece-choice:disabled {
  opacity: 0.26;
}

.adventure-primary,
.adventure-link {
  min-height: 49px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  padding: 0 23px;
  background: #648154;
  color: #fff;
  font: 900 16px/1 "Arial Rounded MT Bold", system-ui, sans-serif;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(75, 106, 64, 0.25);
}

.adventure-setup-card > .adventure-primary {
  margin-top: 20px;
}

.adventure-primary:disabled {
  opacity: 0.46;
}

.adventure-link {
  background: #72838a;
}

.adventure-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.adventure-shell button:focus-visible,
.adventure-shell a:focus-visible,
.adventure-shell select:focus-visible {
  outline: 3px solid #e5b84d;
  outline-offset: 3px;
}

.adventure-error {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #edf0eb;
  color: #8a453c;
  font: 800 18px/1.45 system-ui, sans-serif;
  text-align: center;
}

@media (orientation: portrait) and (max-width: 800px) {
  .adventure-turn {
    right: max(105px, calc(env(safe-area-inset-right) + 100px));
    left: max(62px, calc(env(safe-area-inset-left) + 58px));
    width: auto;
    min-width: 0;
    transform: none;
  }

  .adventure-legend {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    flex-direction: column;
    gap: 2px;
    padding: 5px 7px;
  }

  .adventure-pairs {
    left: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .adventure-pair-buttons,
  .adventure-pairs-label {
    display: none;
  }

  .adventure-pair-select {
    display: block;
  }

  .adventure-picture {
    width: min(84vw, 390px);
    height: min(42vh, 350px);
  }

  .adventure-overlay {
    padding: 72px 8px 62px;
  }

  .adventure-piece-pickers {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (orientation: portrait) and (max-width: 500px) {
  .adventure-turn {
    min-height: 45px;
    padding: 4px 8px;
  }

  .adventure-turn-dot {
    width: 15px;
    height: 15px;
  }

  .adventure-turn strong {
    font-size: 13px;
  }

  .adventure-turn > span:last-child {
    max-width: 175px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .adventure-dice-button span {
    top: calc(100% + 4px);
    padding: 4px 7px;
    font-size: 9px;
  }

  .adventure-card {
    border-radius: 22px;
    padding: 17px 12px;
  }

  .adventure-card h1 {
    font-size: clamp(21px, 6.5vw, 28px);
  }

  .adventure-intro {
    font-size: 12px !important;
  }

  .adventure-setup-section,
  .adventure-piece-pickers {
    margin-top: 12px;
  }

  .adventure-piece-grid {
    gap: 5px;
  }

  .adventure-piece-choice {
    border-radius: 11px;
  }

  .adventure-setup-card > .adventure-primary {
    min-height: 44px;
    margin-top: 14px;
  }
}

@media (orientation: landscape) and (max-width: 1100px) and (max-height: 500px) {
  .adventure-turn {
    top: max(10px, env(safe-area-inset-top));
    width: min(410px, calc(100% - 250px));
    min-width: 260px;
    min-height: 43px;
    padding: 3px 10px;
  }

  .adventure-turn strong {
    font-size: 14px;
  }

  .adventure-turn > span:last-child {
    font-size: 9px;
  }

  .adventure-legend {
    right: max(6px, env(safe-area-inset-right));
    bottom: max(6px, env(safe-area-inset-bottom));
    flex-direction: column;
    gap: 2px;
    padding: 4px 6px;
  }

  .adventure-pairs {
    left: max(7px, env(safe-area-inset-left));
    bottom: max(7px, env(safe-area-inset-bottom));
    padding: 5px;
  }

  .adventure-pair-buttons,
  .adventure-pairs-label {
    display: none;
  }

  .adventure-pair-select {
    display: block;
    min-width: 80px;
    min-height: 32px;
    font-size: 12px;
  }

  .adventure-dice-button span {
    top: calc(100% + 4px);
    padding: 4px 7px;
    font-size: 9px;
  }

  .adventure-picture {
    width: min(43vw, 350px);
    height: min(67vh, 260px);
    padding: 9px;
  }

  .adventure-picture figcaption {
    font-size: clamp(20px, 5.5vh, 28px);
  }

  .adventure-overlay {
    padding: 58px 72px 8px;
  }

  .adventure-card {
    width: min(100%, 720px);
    border-radius: 20px;
    padding: 11px 18px;
  }

  .adventure-card h1,
  .adventure-card > h2 {
    font-size: clamp(21px, 5.5vh, 28px);
  }

  .adventure-intro {
    display: none;
  }

  .adventure-setup-section {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    align-items: center;
    margin-top: 8px;
  }

  .adventure-setup-section h2,
  .adventure-piece-pickers h2 {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .adventure-mode-choices button {
    min-height: 36px;
    padding: 5px 12px;
    font-size: 12px;
  }

  .adventure-piece-pickers {
    grid-template-columns: 1fr;
    gap: 5px;
    margin-top: 8px;
  }

  .adventure-piece-pickers > section {
    display: grid;
    grid-template-columns: 125px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
  }

  .adventure-piece-pickers h2 {
    margin: 0;
  }

  .adventure-piece-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: center;
    gap: 4px;
  }

  .adventure-piece-choice {
    width: 100%;
    height: 52px;
    max-height: 52px;
    aspect-ratio: auto;
    overflow: hidden;
    border-radius: 9px;
    padding: 3px;
  }

  .adventure-piece-choice img {
    width: min(100%, 46px);
    height: min(100%, 46px);
    max-width: 46px;
    max-height: 46px;
  }

  .adventure-setup-card > .adventure-primary {
    min-height: 38px;
    margin-top: 9px;
    font-size: 13px;
  }

  .adventure-card p {
    margin-top: 6px;
    font-size: 12px;
  }

  .adventure-actions {
    margin-top: 10px;
  }

  .adventure-actions .adventure-primary,
  .adventure-actions .adventure-link {
    min-height: 38px;
    font-size: 13px;
  }
}

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