@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Noto+Sans+TC:wght@500&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/*字體*/
.bbn {
  color: #f4f3f1;
  font-family: "Bebas Neue";
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  letter-spacing: 1.2px;
}

.nst {
  font-family: "Noto Sans TC", sans-serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-style: normal;
}

/*基本*/
html {
  height: 100vh;
  width: 100vw;
  min-width: 750px;
  min-height: 700px;
  overflow: hidden;
}

body {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #353535;
}

/* 變數 */
:root {
  --highestLayer: 10000;
  --higherLayer: 1000;
  --hideLayer: -10000;
  --normalLayer: 10;
}

/* logo */
.wordmark {
  cursor: default;
  transition: all 0.2s ease-in;
}

/* 按鈕 */
.butCon {
  display: flex;
  gap: 36px;
  flex-shrink: 0;
  transition: all 0.2s ease-in;
}

.butCon button {
  width: 176px;
  height: 55px;
  flex-shrink: 0;
  background-color: #777;
  color: #f4f3f1;
  text-align: center;
  font-family: "Bebas Neue";
  font-size: 24px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  letter-spacing: 2.4px;
  border-radius: 15px;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: var(--normalLayer);
  cursor: pointer;
}

.replayBut svg {
  width: 24px;
  height: 24px;
}

.nextBut svg {
  width: 40px;
  height: 40px;
}

button.fake3d {
  box-shadow: 0px 10px #494949;
}

button.fake3d.active {
  animation: fake3dPress 0.3s forwards;
}

@keyframes fake3dPress {
  0% {
    box-shadow: 0px 10px #494949;
    transform: translateY(0);
  }
  50% {
    box-shadow: 0px 5px #494949;
    transform: translateY(5px);
  }
  100% {
    box-shadow: 0px 10px #494949;
    transform: translateY(0);
  }
}

button::after {
  position: absolute;
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  top: 75px;
}

.replayBut::after {
  content: "重玩";
}

.nextBut::after {
  content: "下一個";
}

.settingBut::after {
  content: "設定";
}

.settingBut.settingOn::after {
  content: "關閉";
}

/* 載入畫面 */
.loadingScreen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 50px;
  justify-content: center;
  align-items: center;
  background-color: #353535;
  z-index: var(--highestLayer);
  opacity: 1;
  transition: all 0.15s ease-in;
}

.loadingScreen.hidden {
  opacity: 0;
  z-index: var(--hideLayer);
  pointer-events: none;
}

.spinner {
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Footer */
.footer {
  position: absolute;
  bottom: 0px;
  width: 100%;
  height: 100px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 30px;
  padding-top: 0px;
  z-index: var(--highestLayer);
}

.footer .info {
  display: flex;
  flex-direction: column;
  gap: 10px; /* 增加段落之間的間距 */
}

.footer .altButCon {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  align-items: end;
  justify-content: space-around;
  gap: 20px; /* 按鈕之間的間距 */
}

.footer .historyBut {
  color: #777;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease-in;
  user-select: none;
}

.footer .historyBut:hover {
  color: #f4f3f1;
}

.info p {
  color: #777;
  font-size: 12px;
  text-align: right;
}

/* 文字展示&輸入區 */
.mainTextCon,
.mandarinInput {
  color: #777;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
  will-change: transform;
}

.incorrect {
  color: #ec9495;
}

.correct {
  color: #f4f3f1;
}

.mandarinInput {
  padding: 25px;
  text-align: left;
  background-color: #777;
  color: #353535;
  outline: none;
  border-radius: 15px 0 0 15px;
  border: none;
  font-size: 50px;
  box-sizing: border-box;
  width: 100%;
  cursor: text;
  caret-color: #353535;
}

.char {
  font-size: 50px;
  flex-shrink: none;
  display: inline-block;
}

/*排版*/
.wordmark {
  position: absolute;
  inset: calc(50% - 300px) auto auto 50%;
  z-index: var(--normalLayer);
  transform: translateY(-50%) translateX(-50%);
}

.mainTextCon {
  display: flex;
  position: absolute;
  inset: calc(50% - 55px) auto auto 50%;
  left: 50%; /* <-- Add this line */
  z-index: var(--normalLayer);
  transform: translateY(calc(-50% - 55px));
  user-select: none;
  overflow: hidden;
  min-width: 400px;
}

.mandarinInput {
  position: absolute;
  inset: calc(50% + 55px) auto auto 50%;
  left: calc(50% - 25px); /* <-- Add this line */
  z-index: var(--normalLayer);
  transform: translateY(calc(-50% - 55px));
  min-width: 400px;
  opacity: 1;
}

.butCon {
  position: absolute;
  inset: calc(50% + 300px) auto auto 50%;
  z-index: var(--normalLayer);
  transform: translateY(calc(-50% - 50px)) translateX(-50%);
}

/* 設定 */
.settingCon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1000px;
  height: 450px;
  border-radius: 15px;
  padding: 50px;
  opacity: 0;
  transition: all 0.15s ease-in;
  z-index: var(--hideLayer);

  display: flex;
  padding-top: 75px;
  gap: 50px;
  justify-content: start;
  align-items: start;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: center;
}

.settingCon.open {
  opacity: 1;
  z-index: var(--highestLayer);
}

.settingItem {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  width: 270px;
  height: max-content;
  justify-content: space-between;
}

.settingCon h1 {
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 1.2px;
}

.settingCon button {
  width: 130px;
  height: 40px;
  border-radius: 10px;
  border: #777 2px solid;
  background-color: rgba(0, 0, 0, 0);
  color: #777;
  cursor: pointer;
  transition: all 0.15s ease-in;
}

.settingCon button.selected {
  background-color: #777;
  color: #f4f3f1;
}

.settingCon button.disable {
  cursor: not-allowed;
  opacity: 0.5;
}

.settingCon button.withInput {
  border-right: none;
  border-radius: 10px 0 0 10px;
  width: 140px;
  margin-right: -10px;
}

.settingCon button.withInput.selected {
  position: relative;
  border: #777 2px solid;
  border-radius: 10px;
  width: 140px;
  margin-right: -10px;
}

.settingCon input {
  width: 130px;
  height: 40px;
  border-radius: 0px 10px 10px 0px;
  text-align: center;
  background-color: rgba(0, 0, 0, 0);
  color: #777;
  border: #777 2px solid;
  border-left: none;
  outline: none;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  /* Chrome, Safari, Edge, Opera */
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  /* Firefox */
  appearance: textfield;
  -moz-appearance: textfield;
}

#autoDeleteUnderlineSetting h1::after,
#autoCorrectSetting h1::after {
  content: "BETA";
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 0.5px;
  margin-left: 5px;
}

/* 遊戲中 */
html.inGame .butCon {
  opacity: 0;
}
html.inGame .wordmark {
  opacity: 0.2;
}

html.settingOpening .replayBut,
html.settingOpening .nextBut,
html.settingOpening .resultCon {
  opacity: 0;
  pointer-events: none;
}

html.inGame .inGameHud {
  opacity: 1;
  z-index: var(--higherLayer);
}

/* 模糊效果 */
.blur {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20vw;
  height: 300px;
  flex-shrink: 0;
  background: linear-gradient(90deg, rgba(53, 53, 53, 0) 0%, rgba(53, 53, 53, 0.75) 50%, #353535 75%, #353535 100%);
  z-index: var(--higherLayer);
}

.blurRight {
  right: 0;
}

.blurLeft {
  left: 0;
  transform: translateY(-50%) rotateY(180deg);
}

/* 成績 */
.resultCon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 700px;
  height: 180px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: start;
  color: #777;
  flex-shrink: 0;
  opacity: 0;
  z-index: var(--hideLayer);
  transition: all 0.15s ease-in;
  align-content: space-evenly;
}

.resultCon h1 {
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 1.2px;
}

.resultCon p {
  color: #f4f3f1;
  font-family: "Bebas Neue";
  font-size: 64px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  transform: translateX(-2px);
}

.resultItem {
  width: auto;
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: end;
  justify-content: end;
}

.resultItem img {
  margin-bottom: 5px;
  cursor: pointer;
}

.resultItem h1 {
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 1.2px;
}

.resultItem p {
  color: #f4f3f1;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
}

.resultCon.visible {
  opacity: 1;
  z-index: var(--highestLayer);
}

/* 遊戲中 HUD */
.inGameHud {
  position: absolute;
  top: calc(50% - 30px);
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  opacity: 0;
  z-index: var(--hideLayer);
  height: 375px;
  width: 100px;
  justify-content: space-between;
  align-items: center;
}

.hudTimer {
  color: #f4f3f1;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 1.2px;
  cursor: default;
}

.inGameHud .hudButCon {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.hudButCon svg {
  cursor: pointer;
}

.hudButCon svg path {
  stroke: #777;
}

.hudButCon svg:hover path {
  stroke: #f4f3f1;
}

/* 歷史紀錄 */
.historyCon {
  position: absolute;
  width: auto;
  min-width: 500px;
  height: calc(100vh - 100px);
  bottom: 100px;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 50px;
  gap: 50px;
  justify-content: start;
  align-items: start;
  background-color: #353535;
  border-radius: 0 0 15px 0;
  border: #777 2px solid;
  border-left: none;
  border-top: none;
  opacity: 0;
  z-index: var(--hideLayer);
  animation: slideInToLeft 0.3s forwards;
}

.highestCon {
  height: max-content;
  width: 100%;
}

.highestCon .highestWpm {
  color: #f4f3f1;
  font-family: "Bebas Neue";
  font-size: 64px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  letter-spacing: 3.2px;
}

.historyCon h1 {
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 1.2px;
}

.historyTitle {
  margin-bottom: -20px;
}

.highestWpm::after {
  content: "原始結果 / 淨結果";
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 15px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: 0.75px;
  margin-left: 20px;
}

.tableCon {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex-grow: 100;
  gap: 30px;
  z-index: var(--highestLayer);
  overflow-y: auto;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  border-radius: 0 0 15px 15px;
}

.historyTable::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.historyTable {
  width: 100%;
  border-collapse: collapse;
  height: max-content;
  max-height: 100%;
}

.historyTable th {
  text-align: left;
  color: #777;
  font-family: "Noto Sans TC";
  font-size: 15px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  padding-bottom: 20px;
}

.historyTable th:first-child {
  opacity: 0.5;
}

.historyTable td {
  color: #f4f3f1;
  font-family: "Noto Sans TC";
  font-size: 24px;
  font-style: normal;
  font-weight: 500;
  line-height: normal;
  letter-spacing: -1.2px;
  padding-bottom: 15px;
}

.historyTable td:first-child {
  color: #777;
  opacity: 0.5;
}

.historyTable td,
.historyTable th {
  padding-right: 50px;
  width: max-content;
  white-space: nowrap;
}
.historyTable td:last-child {
  padding-right: 0;
}

.historyTable thead {
  position: sticky;
  top: 0;
  background: #353535; /* 建議加背景色避免透明 */
  z-index: 2;
}

.historyCon.open {
  opacity: 1;
  z-index: var(--highestLayer);
  animation: slideOutFromLeft 0.3s forwards;
}

@keyframes slideOutFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInToLeft {
  from {
    transform: translateX(0%);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

.historyTable tr.highest td {
  text-decoration: underline;
}
