*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

html {
  font-size: 62.5%;
}

body {
  box-sizing: border-box;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  background-attachment: fixed;
  width: 100vw;
  height: 100vh;
  margin: auto;
  margin-top: 50px;
  margin-bottom: -50px;
  font-family: 'Avenir Next';
  overflow-x: hidden;
}

.cpu-box {
  display: flex;
  justify-content: center;
  margin-bottom: 100px;
  min-height: 150px;
  padding: 10px 0;
}

.play-area {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  margin: 20px 0;
}

.score {
  display: flex;
  flex-direction: column;
  margin: auto 0;
  color: rgb(6, 37, 62);
  font-size: x-large;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  backdrop-filter: blur(5px);
}

#seperator {
  margin: 10px 0;
  border: 2px solid rgb(8, 81, 140);
}

#cpu-score, 
#player-score {
  font-size: 1.5em;
  font-weight: bold;
  color: #00eaff;
}

.player-box {
  display: flex;
  justify-content: center;
  margin-top: 100px;
  min-height: 150px;
  padding: 10px 0;
}

img {
  width: 100px;
  margin-left: -28px;
  border-radius: 10px;
  box-shadow: -7px -7px 14px #00405c, 
              0 0 5px rgba(0, 234, 255, 0.5);
  transition: all 0.2s ease-in-out;
}

.player-hand img:hover {
  transform: scale(1.05) translateY(-8px);
  cursor: pointer;
}

.draw-pile img:hover {
  transform: scale(1.1);
  cursor: pointer;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

#draw-card {
  position: absolute;
  right: 19vw;
  z-index: 2;
}

.player-draw {
  transform: translateY(260px) translateX(-100px);
  transition: all 0.2s ease-in-out;
}

.cpu-draw {
  transform: translateY(-260px) translateX(-100px);
  transition: all 0.2s ease-in-out;
}

.player-animation {
  position: absolute;
  z-index: 2;
  left: 75vw;
  top: 600px;
}

.cpu-animation {
  position: absolute;
  z-index: 2;
  left: 75vw;
  top: 100px;
}

.play-card {
  transform: translateY(-260px);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cpu-play-card {
  transform: translateY(260px);
  transition: all 0.1s ease-in;
}

.hidden {
  display: none;
}

.shout img {
  transform: scale(3.5);
  transition: all 0.1s ease-in-out;
  border-radius: 0px;
  box-shadow: none;
}

.player-animation img,
.cpu-animation img {
  border-radius: 0px;
  box-shadow: none;
  transition: all 1s ease-in-out;
}

.end-of-round {
  position: absolute;
  z-index: 2;
  top: 40vh;
  left: 35vw;
  width: 30vw;
  margin: auto;
  font-size: xx-large;
  padding: 100px;
  padding-top: 50px;
  border: 5px solid #00eaff;
  border-radius: 20px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.5s ease-out;
}

.end-of-game {
  position: absolute;
  z-index: 2;
  top: 37vh;
  left: 30vw;
  width: 40vw;
  margin: auto;
  font-size: xx-large;
  padding: 100px;
  padding-top: 50px;
  border: 5px solid #00eaff;
  border-radius: 20px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.end-of-round p,
.end-of-game p {
  color: #00eaff;
  text-align: center;
}

.end-of-game button {
  background: linear-gradient(to right, #4facfe, #00f2fe);
  color: black;
  margin-left: 14vw;
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1.2rem;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.end-of-game button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(79, 172, 254, 0.7);
}

.color-picker {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center;
  width: 60vw;
  margin: auto;
  margin-top: 20px;
  text-align: center;
  opacity: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 15px;
  backdrop-filter: blur(5px);
  transition: opacity 0.3s ease;
}

.color-picker p {
  color: rgb(134, 174, 204);
  font-size: large;
  margin-bottom: 10px;
}

.color-picker div {
  display: flex;
  justify-content: center;
  gap: 10px;
}

button {
  height: 40px;
  width: 80px;
  color: white;
  border-radius: 10px;
  font-weight: bold;
  border: 2px solid white;
  transition: all 0.2s ease;
}

button:hover {
  transform: scale(1.1);
  cursor: pointer;
}

.red {
  background-color: red;
}

.green {
  background-color: green;
}

.blue {
  background-color: blue;
}

.yellow {
  background-color: yellow;
  color: black;
}

.empty {
  width: 100px;
  margin-left: -28px;
  border-radius: 10px;
  box-shadow: none;
}

@media (max-width: 812px) {
  body {
    margin-top: -50px;
    margin-bottom: 0px;
    font-family: 'Avenir Next';
  }

  .cpu-box {
    margin-bottom: 10px;
  }

  .play-area {
    flex-direction: column;
    gap: 20px;
  }

  .score {
    order: -1;
    margin-bottom: 20px;
    font-size: large;
  }

  .player-box {
    margin-top: 10px;
  }
  
  img {
    width: 60px;
    margin-left: -15px;
  }

  .play-card {
    transform: translateY(-130px);
  }

  .cpu-play-card {
    transform: translateY(130px);
  }

  .shout img {
    transform: scale(2);
  }

  .player-draw {
    transform: translateY(170px) translateX(-100px);
  }

  .cpu-draw {
    transform: translateY(-170px) translateX(-100px);
  }

  .color-picker {
    margin-top: 0px;
    width: 80vw;
  }

  .color-picker p {
    font-size: medium;
  }

  .color-picker button {
    height: 30px;
    width: 60px;
    font-size: 0.8rem;
  }

  .end-of-round {
    left: 25vw;
    width: 50vw;
    font-size: x-large;
  }

  .end-of-game {
    left: 20vw;
    width: 60vw;
    font-size: x-large;
  }

  .end-of-game button {
    margin-left: 10vw;
    font-size: 1rem;
  }
}
@media (max-width: 812px) {
  body {
    margin-top: 0;
    margin-bottom: 0;
    background: linear-gradient(135deg, #1a3a6a, #224a98);
    overflow-x: hidden;
  }

  /* 顶部电脑手牌区域 */
  .cpu-box {
    margin-bottom: 10px;
    min-height: 80px;
    display: flex;
    justify-content: center;
  }

  /* 中间游戏区域 - 自定义三部分水平布局 */
  .play-area {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin: 5px auto;
    width: 95%;
    flex-wrap: nowrap; /* 禁止换行 */
  }

  /* 打出的牌堆 - 左侧 */
  .play-pile {
    order: 1;
    flex: 0 0 auto;
  }

  /* 分数提示 - 中间 */
  .score {
    order: 2;
    flex: 0 0 auto;
    font-size: 1.1rem;
    padding: 0 10px;
    white-space: nowrap; /* 防止文字换行 */
  }

  /* 分数分隔线调整 */
  #seperator {
    display: none; /* 在小屏幕上隐藏分隔线 */
  }

  /* 分数文字调整 */
  .cpu-score-title, 
  .player-score-title {
    display: block;
    line-height: 1.3;
  }

  /* 抽牌堆 - 右侧 */
  .draw-pile {
    order: 3;
    flex: 0 0 auto;
  }

  /* 卡片尺寸调整 */
  img {
    width: 50px;
    margin-left: -15px;
  }

  .play-pile img, 
  .draw-pile img {
    width: 55px;
    margin-left: -10px;
  }

  /* 动画位置调整 */
  #draw-card {
    position: relative;
    right: auto;
    margin-left: -25px;
  }

  .player-draw {
    transform: translateY(100px) translateX(-60px);
  }

  .cpu-draw {
    transform: translateY(-100px) translateX(-60px);
  }

  /* 底部玩家手牌区域 */
  .player-box {
    margin-top: 10px;
    min-height: 80px;
    display: flex;
    justify-content: center;
  }

  /* UNO提示位置 */
  .player-animation {
    left: 60vw;
    top: 65vh;
  }

  .cpu-animation {
    left: 60vw;
    top: 15vh;
  }

  /* 游戏结束提示 */
  .end-of-round, 
  .end-of-game {
    width: 85%;
    left: 7.5%;
    top: 30%;
    padding: 15px;
    font-size: 1.3rem;
  }

  .end-of-game button {
    margin-left: 25%;
    width: 50%;
    padding: 8px;
    font-size: 1rem;
  }

  /* 颜色选择器 */
  .color-picker {
    width: 90%;
    margin: 5px auto;
    padding: 8px;
  }

  .color-picker button {
    height: 32px;
    width: 65px;
    font-size: 0.8rem;
    margin: 0 2px;
  }

  /* 规则文字调整 */
  .rules {
    display: none; /* 在小屏幕上隐藏规则文字 */
  }

  /* 超小屏幕额外调整 */
  @media (max-width: 400px) {
    img {
      width: 45px;
      margin-left: -12px;
    }

    .play-pile img, 
    .draw-pile img {
      width: 50px;
    }

    .score {
      font-size: 1rem;
      padding: 0 5px;
    }

    .color-picker button {
      width: 60px;
      height: 30px;
    }
  }
}
