a,
a:hover,
a:active,
a:visited,
a:link,
a:focus {
  -webkit-tap-highlight-color: transparent;
  outline: none;
  background: none;
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  color: rgb(70, 70, 70);
}

button {
  appearance: none;           /* 移除系统默认样式（关键） */
  -webkit-appearance: none;   /* Safari/旧版 Chrome */
  -moz-appearance: none;      /* Firefox */
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;              /* 继承父级字体设置 */
  color: inherit;             /* 继承父级文字颜色 */
  text-align: inherit;        /* 继承文字对齐方式 */
  outline: none;
  cursor: pointer;
  user-select: none;
}

::selection {
  background: #fff;
  color: rgb(70, 70, 70);
}

::-moz-selection {
  background: #fff;
  color: rgb(70, 70, 70);
}

::-webkit-selection {
  background: #fff;
  color: rgb(70, 70, 70);
}

* {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
  touch-action: manipulation;
  touch-action: none;
}

body {
  font-family: Helvetica, sans-serif;
}

#tetris {
  position: relative;
  margin: 1em auto;
  padding: 1em;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 1px 1px 8px 4px rgba(0, 0, 0, 0.15);
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#ip {
  position: absolute;
  top: 0;
  right: 0;
  font-size: calc(10px + 0.1em);
  opacity: 0.5;
  padding: 0 4px;
}

.history_max_number {
  position: absolute;
  top: 0;
  left: 0;
  font-size: calc(10px + 0.1em);
  padding: 0 4px;
}
#hmn_ip {
  opacity: 0.5;
}
#hmn_score {
  color: rgb(255, 124, 124);
  font-weight: bold;
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);
}

#bgImg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  /* opacity: 0.5; */
  pointer-events: none;
  object-fit: cover;
  z-index: -1;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.audio {
    position: fixed;
    width: 0;
    height: 0;
    opacity: 0;
    z-index: -1;
}

#stats {
  display: inline-block;
  vertical-align: top;
  width: 2.4em !important;
  text-align: center;
}

#stats div {
  background-color: rgba(8, 8, 24, 0.5) !important;
}

#stats canvas {
  opacity: 0.8;
  width: 92% !important;
  height: 16px !important;
}

#canvas {
  display: inline-block;
  vertical-align: top;
  background-color: rgba(255,255,255, 0.03);
  /*backdrop-filter: blur(2px);*/
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 1px 1px 8px 4px rgba(0, 0, 0, 0.15);
}

#menu {
  display: inline-block;
  vertical-align: top;
  position: relative;
}

#start {
  text-align: center;
  margin: 0;
  font-size: 1em;
  font-weight: 600;
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);
}

#upcoming_box {
  margin-left: 2vh;
  margin-top: 2vh;
}

#upcoming {
  display: block;
  margin: 0 auto;
}

#number {
  display: inline-block;
  text-align: center;
  width: 100%;
  font-size: 0.8em;
  color: rgb(70, 70, 70);
  text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);
}

#score {
  color: rgb(255, 124, 124);
  font-weight: bold;
  vertical-align: middle;
}

#rows {
  color: rgb(146, 146, 250);
  font-weight: bold;
  vertical-align: middle;
}

#stats,
#upload,
#delete {
  position: absolute;
  bottom: 0em;
  right: 1em;
  opacity: 0.4 !important;
}

#delete,
#upload {
  width: 1.6em;
  height: 1.6em;
  line-height: 1.6em;
  text-align: center;
  overflow: hidden;
  font-size: 0.75em;
  right: 0;
  color: #222;
  /*background-color: rgba(0, 0, 0, 0.4);*/
  /*text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);*/
  /*box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.4);*/
  /*backdrop-filter: blur(2px);*/
}

#upload {
  transform: rotate(-90deg);
}

#delete {
  transform: rotate(90deg);
}

#file {
  display: none;
}

.keystroke {
  display: none;
}

@media screen and (min-width: 500px) and (min-height: 500px) {
  #tetris {
    font-size: 1.25em;
    width: 450px;
  }

  #menu {
    width: 200px;
    height: 400px;
  }

  #upcoming {
    width: 100px;
    height: 100px;
  }

  #canvas {
    width: 200px;
    height: 400px;
  }
}

/* 20px 方块 */
@media screen and (min-width: 600px) and (min-height: 600px) {
  #tetris {
    font-size: 1.5em;
    width: 550px;
  }

  #menu {
    width: 250px;
    height: 500px;
  }

  #upcoming {
    width: 125px;
    height: 125px;
  }

  #canvas {
    width: 250px;
    height: 500px;
  }
}

/* 25px 方块 */
@media screen and (min-width: 700px) and (min-height: 700px) {
  #tetris {
    font-size: 1.75em;
    width: 650px;
  }

  #menu {
    width: 300px;
    height: 600px;
  }

  #upcoming {
    width: 150px;
    height: 150px;
  }

  #canvas {
    width: 300px;
    height: 600px;
  }
}

/* 30px 方块 */
@media screen and (min-width: 800px) and (min-height: 800px) {
  #tetris {
    font-size: 2em;
    width: 750px;
  }

  #menu {
    width: 350px;
    height: 700px;
  }

  #upcoming {
    width: 175px;
    height: 175px;
  }

  #canvas {
    width: 350px;
    height: 700px;
  }
}

/* 35px 方块 */
@media screen and (min-width: 900px) and (min-height: 900px) {
  #tetris {
    font-size: 2.25em;
    width: 850px;
  }

  #menu {
    width: 400px;
    height: 800px;
  }

  #upcoming {
    width: 200px;
    height: 200px;
  }

  #canvas {
    width: 400px;
    height: 800px;
  }
}

/* 40px 方块 */

/* 📱 手机端：上下布局，覆盖之前的 inline-block 布局 */
@media (max-width: 490px) {
  body {
    font-size: 14px;
    padding: 0;
    margin: 0;
    position: relative;
  }

  /* #tetris 容器：适应手机宽度 */
  #tetris {
    width: 100% !important;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    border-radius: 0;
    border: none;
    height: 100vh;
  }

  /* 关键：让 menu 和 canvas 垂直堆叠 */
  #menu,
  #canvas,
  #stats {
    display: block;
    margin: 0 auto;
    float: none;
    height: auto !important;
  }
  
  /* 菜单按钮区域 */
  #menu {
    display: flex;
    width: 100%;
    height: auto !important;
    padding: 0;
  }

  #start {
    flex: 1;
    order: 3;
    text-align: center;
    margin: 0;
    line-height: 8vh;
    font-size: 1.6em;
  }

  #canvas {
    width: 36vh !important;
    height: 72vh !important;
    background-size: 36vh 72vh;
  }

  /* 预览图 */
  #upcoming_box {
    flex: 1;
    order: 2;
    position: relative;
    width: 8vh !important;
    height: 8vh !important;
    overflow: hidden;
    text-align: center;
    margin: 0;
  }

  #upcoming {
    position: absolute;
    top: -3.6vh;
    left: 0;
    width: 16vh !important;
    height: 16vh !important;
    transform: scale(0.5);
    overflow: hidden;
    background-color: transparent;
  }

  #number {
    flex: 1;
    order: 1;
    font-size: 1em;
    line-height: 8.25vh;
    height: 8vh;
    overflow: hidden;
  }

  /* 统计信息放在底部，居中 */
  #stats {
    position: fixed;
    top: 0;
    left: 0.5em;
    right: unset;
    margin: 0;
    width: 5.8em !important;
    max-height: 3vh;
  }
  
  #stats div {
    background-color: rgba(8, 8, 24, 0.5) !important;
  }
  
  #stats canvas {
    opacity: 0.8;
    height: 10px !important;
  }

  #upload,
  #delete {
    position: fixed;
    bottom: 20vh;
    right: 1vw;
    margin: 0;
    opacity: 0.4 !important;
    width: 1.6em;
    height: 1.6em;
    line-height: 1.6em;
    text-align: center;
    font-size: 1.62em;
    color: #222;
    /*background-color: rgba(0, 0, 0, 0.4);*/
    /*text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.6);*/
    /*backdrop-filter: blur(2px);*/
  }

  #upload {
    transform: rotate(-90deg);
  }

  #delete {
    transform: rotate(90deg);
  }

  .keystroke {
    display: block;
    width: 100%;
    padding: 0;
    margin-top: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .keystroke .lr {
    width: 50vw;
    height: calc(100vh - 80vh);
    display: flex;
    flex-direction: row;
  }

  .keystroke .ud {
    width: 50vw;
    height: calc(100vh - 80vh);
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    
    .icon {
        transform: rotate(90deg);
    }
  }

  #key_37,
  #key_38,
  #key_39,
  #key_40 {
    width: 100%;
    height: 100%;
    line-height: 100%;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(2px);
    font-size: 2em;
    font-weight: 1600;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
    color: #fff;
    padding-bottom: 10px;
    /* 居中 */
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
  }
  
  #key_37.active,
  #key_38.active,
  #key_39.active,
  #key_40.active {
    background-color: rgba(255, 255, 255, 0.3) !important;
    color: #000 !important; /* 文字变深色，对比更强 */
    transition: all 0.1s ease !important; /* 平滑过渡 */
  }
  
  /* 可选：调整字体大小 */
  #score,
  #rows {
    font-size: 1.2em;
  }
}
