#adventure {
  width: 100vw;
  height: 100vh;
  padding: var(--scene-gap);
  position: relative;
  display: none;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 1fr);
  grid-template-rows:
    minmax(0, 1fr)
    minmax(0, 1fr);
  gap: var(--scene-gap);

  overflow: hidden;
  background: var(--bg);
}

#adventure.is-active {
  display: grid;
}

#adventure.is-hidden {
  display: none;
}

/* 左上 cardinfo */
#adventure #cardinfo {
  grid-column: 1;
  grid-row: 1;

  min-width: 0;
  min-height: 0;

  position: relative;
  overflow: visible;

  border: var(--border-thick) solid var(--black);
  background: #fff;
  width: calc(100% - 100px);
  justify-self: start;
  box-sizing: border-box;
}

#adventure #cardinfo-content {
  min-height: 100%;
  padding: 16px 70px 16px 16px;
}

#adventure #cardinfo-content h3 {
  margin-bottom: 10px;
}

#adventure #cardinfo-content p + p {
  margin-top: 8px;
}

/* 右下角 action 区 */
#adventure #cardinfo-button {
  width: auto;
  height: auto;
  padding: 0;

  position: absolute;
  right: 5px;
  bottom: 5px;

  border: 0;
  background: transparent;

  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 8px;

  overflow: visible;
  z-index: 20;
}

#adventure #cardinfo-button:hover,
#adventure #cardinfo-button:focus-visible {
  box-shadow: none;
}

#adventure #cardinfo-button .cardinfo-action {
  width: auto;
  height: auto;
  padding: 0;

  border: 0;
  background: transparent;

  display: block;
  overflow: visible;
  position: relative;
  cursor: pointer;

  appearance: none;
  -webkit-appearance: none;
}
#adventure #cardinfo-button .cardinfo-action img {
  width: auto;
  height: auto;
  max-width: none;
  display: block;
  border: 0;
  pointer-events: none;
}
#adventure #cardinfo-button .cardinfo-action-badge {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  padding: 0;
  color: #000;
  background: none;
  font-size: 16px;
  line-height: 1;
  text-align: left;
  z-index: 10;
  pointer-events: none;
}
#adventure #cardinfo-button .cardinfo-action:hover,
#adventure #cardinfo-button .cardinfo-action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-color);
}

/* 右上 nextcards */
#adventure #nextcards {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  box-sizing: border-box;
  width: calc(100% - 100px);
  height: 100%;

  min-width: 0;
  min-height: 0;

  padding: clamp(12px, 3vw, 40px);

  border: 0;
  background: transparent;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--scene-gap);
  position: relative;
  overflow: visible;
}
#adventure #adventure-ui1 {
  width: auto;
  height: auto;
  max-width: none;
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  z-index: 10;
  pointer-events: none;
}

#adventure #adventure-ui1[hidden] {
  display: none;
}
#adventure #cardinfo-button[hidden] {
  display: none;
}
#adventure #adventure-selected-image[hidden] {
  display: none;
}

#adventure #adventure-selected-image {
  width: auto;
  height: auto;
  max-width: none;
  position: absolute;
  left: 50%;
  top: calc(50% - 40px);
  transform: translate(-50%, -100%);
  display: block;
  z-index: 15;
  pointer-events: none;
}


/* 牌堆计数牌 */
#adventure #adventuredeck {
  width: 150px;
  height: 70px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  align-self: center;
  gap: 4px;

  border: 0;
  background: transparent;

  color: #000000;
  font-size: 16px;
  font-weight: bold;
  line-height: 16px;
}

#adventure #adventurecardnum {
  color: #000000;
  font-weight: bold;
  font-size: 16px;
  line-height: 16px;
}
#adventure #adventurebackcard {
  width: 150px;
  height: 50px;
  max-width: none;
  max-height: none;
  flex: 0 0 50px;
  display: block;
}
#adventure #adventurebackcard {
  width: 150px;
  height: 50px;
  max-width: none;
  max-height: none;
  flex: 0 0 50px;
  display: block;
}
/* 手牌区域 */
#adventure #adventure-hand {
  width: 100%;
  padding: calc(60px + 1em) 6px 6px;
  border: 2px solid #000000;
  display: grid;
  grid-template-columns: repeat(5, minmax(50px, 1fr));
  align-items: center;
  align-content: center;
  justify-items: center;

  gap: 3px;

  overflow: auto;
}

#adventure #adventure-hand .card-slot {
  width: 100%;
  max-width: 120px;
  height: auto;

  aspect-ratio: 1 / 1;
  position: relative;
  overflow: visible;
}
#adventure #adventure-hand .adventure-card-name {
  position: absolute;
  left: 0;
  bottom: calc(100% + 30px);
  width: 100%;
  font-size: 16px;
  line-height: 16px;
  color: #000000;
  text-align: center;
  white-space: nowrap;
  z-index: 2;
  pointer-events: none;
}
#adventure #adventure-hand .card-slot.is-empty,
#adventure #adventure-hand .card-slot:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

/* 左下 adventure-player */
#adventure .adventure-player {
  grid-column: 1;
  grid-row: 2;

  width: 332px;
  height: 100%;

  min-width: 0;
  min-height: 0;

  display: flex;
  align-items: flex-end;
  justify-self: start;

  gap: 12px;

  overflow: hidden;
}

/* 头像外层容器 */
#adventure .avatar-container {
  width: 160px;
  padding: 12px;

  border: var(--border-thick) solid var(--black);
  background: #fff;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;

  flex-shrink: 0;
}

#adventure .adventure-player .avatar-container {
  flex: 0 0 160px;
  max-height: 100%;
}
#adventure #adventuredata2 {
  width: 160px;
  padding: 12px;

  border: var(--border-thick) solid var(--black);
  background: #fff;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 12px;

  flex: 0 0 160px;
  align-self: flex-end;

  color: #111;
  font-size: 16px;
}

#adventure #adventurenewcard {
  grid-column: 1;
  grid-row: 2;

  height: 50%;
  margin-left: 344px;
  margin-top: auto;

  min-width: 0;
  min-height: 0;

  border: 3px solid #000000;
  background: #fff;

  box-sizing: border-box;
  position: relative;
}
#adventure #adventurenewcard {
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

#adventure #adventurenewcard > div {
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  padding: 0;
  border: 0;
  background: #fff;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

#adventure #adventurenewcard > div img {
  width: 60px;
  height: 60px;
  display: block;
  object-fit: cover;
}
/* 头像区域 */
#adventure .avatar-inner {
  width: var(--avatar-size);
  height: var(--avatar-size);
  margin-bottom: 6px;
  padding: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  background: #fff;
}

/* 头像图片 */
#adventure .avatar-inner .avatar-img {
  width: 100%;
  height: 100%;

  display: block;
  object-fit: cover;
}

/* HP、MP 数据 */
#adventure .stats {
  color: #111;
  font-size: 16px;
}

#adventure .stats .hp,
#adventure .stats .mp {
  margin-top: 6px;
}

/* 卡牌栏整体 */
#adventure .hand.large-hand {
  padding: 10px;

  border: var(--border-thick) solid var(--black);
  background: #fff;

  display: flex;
  flex-direction: column;
  gap: 8px;

  flex: 1 1 auto;

  min-width: 0;
  max-height: 100%;

  overflow: hidden;
}

/* 卡牌栏标题 */
#adventure .hand-label {
  padding-left: 6px;
  color: #111;
  font-size: 18px;
}

/* 卡槽排列区域 */
#adventure .slots {
  padding: 6px;

  display: grid;
  grid-template-columns: repeat(8, var(--slot-size));
  gap: 8px;
}

/* 可点击卡牌 */
#adventure .card-slot {
  width: var(--slot-size);
  height: var(--slot-size);
  padding: 0;

  border: 4px solid var(--black);
  background: #fff;

  display: inline-block;
  overflow: hidden;

  cursor: pointer;
  outline: none;

  appearance: none;
  -webkit-appearance: none;
}

/* 卡牌图片 */
#adventure .card-slot img {
  width: 100%;
  height: 100%;

  display: block;
  object-fit: cover;

  border: 0;
}

/* 卡牌悬停及键盘焦点效果 */
#adventure .card-slot:hover,
#adventure .card-slot:focus-visible {
  box-shadow: 0 0 0 4px var(--focus-color);
}

#adventure .adventure-player .slots {
  width: 100%;
  grid-template-columns: repeat(8, minmax(40px, 1fr));

  overflow-x: auto;
  overflow-y: hidden;
}

#adventure .adventure-player .card-slot {
  width: 100%;
  min-width: 40px;
  height: auto;

  aspect-ratio: 1 / 1;
}

/* 右下 playerbag */
/* 右下 playerbag */
#adventure #playerbag {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

#adventure #bag-content {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: #f3f3f3;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.75);
}

#adventure .bag-panel {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 5px;
  display: none;
  grid-auto-rows: var(--bag-slot-size);
  grid-template-columns: repeat(auto-fill, var(--bag-slot-size));
  align-content: start;
  gap: 5px;
  overflow: auto;
  background: #f3f3f3;
  box-sizing: border-box;
}

#adventure .bag-panel.is-active {
  display: grid;
}

#adventure #bag-tabs {
  width: 100%;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

#adventure .bag-tab {
  width: 100%;
  height: 30px;
  min-width: 0;
  padding: 0;
  border: 2px solid #000;
  border-top: 0;
  border-right: 0;
  border-radius: 0;
  background: #5B5B5B;
  color: #000000;
  font: inherit;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

#adventure .bag-tab:first-child {
  border-left: 2px solid #000;
}

#adventure .bag-tab:last-child {
  border-right: 2px solid #000;
}

#adventure .bag-tab.is-active {
  background: #FFFFFF;
  color: #000000;
}

#adventure .bag-tab:hover,
#adventure .bag-tab:focus-visible {
  color: #000000;
  outline: none;
}

#adventure .bag-tab[data-bag-panel]:hover,
#adventure .bag-tab[data-bag-panel]:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus-color);
}

/* JavaScript 动态创建的 RPG 背包窗格 */
#adventure .bag-slot {
  width: var(--bag-slot-size);
  height: var(--bag-slot-size);
  padding: 0;

  border: 2px solid #2e2e2e;
  border-radius: 3px;

  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.95),
      rgba(215, 215, 215, 0.95)
    );

  display: grid;
  place-items: center;

  position: relative;
  overflow: hidden;

  color: #111;
  cursor: pointer;
  outline: none;

  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.8),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);

  appearance: none;
  -webkit-appearance: none;
}

#adventure .bag-slot img {
  width: 100%;
  height: 100%;

  display: block;
  object-fit: contain;

  pointer-events: none;
}

#adventure .bag-slot:hover,
#adventure .bag-slot:focus-visible {
  box-shadow:
    0 0 0 3px var(--focus-color),
    inset 2px 2px 0 rgba(255, 255, 255, 0.8),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2);
}

/* 响应式 */
@media (max-width: 1200px) {
  #adventure .adventure-player {
    gap: 8px;
  }

  #adventure .adventure-player .avatar-container {
    flex-basis: 140px;
    width: 140px;
  }

  #adventure .game-area {
    width: 95%;
  }
}
@media (max-width: 760px) {
  #adventure {
    width: 720px;
    min-width: 720px;
  }
}