:root {
  --gold: #f2d58e;
  --cyan: #9ff4ee;
  --ink: #06151c;
  --line: rgba(205,255,250,.2);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.panel {
  width: min(1050px,100%);
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  border: 1px solid var(--line);
  background: linear-gradient(145deg,rgba(12,38,48,.95),rgba(3,12,17,.98));
  box-shadow: 0 28px 80px rgba(0,0,0,.45);
}

.hero {
  padding: 68px;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: .2em;
  color: var(--gold);
}

h1 {
  font: 700 clamp(48px,6vw,80px)/1.06 STKaiti,KaiTi,serif;
  margin: 16px 0;
}

h1 span {
  display: block;
  color: var(--gold);
  font-size: .52em;
  margin-top: 10px;
}

.desc {
  line-height: 1.9;
  color: rgba(235,255,255,.72);
  max-width: 620px;
}

.features {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
  margin: 28px 0;
}

.feature {
  padding: 15px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  font-size: 13px;
  color: rgba(235,255,255,.65);
}

.feature b {
  display: block;
  color: #efffff;
  font-size: 15px;
  margin-bottom: 5px;
}

.side {
  padding: 30px;
  border-left: 1px solid var(--line);
  display: flex;
  align-items: center;
}

.card {
  width: 100%;
  padding: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg,rgba(18,55,65,.72),rgba(5,18,24,.88));
}

.card h2 {
  font: 700 31px STKaiti,KaiTi,serif;
  margin: 0;
}

.sub {
  color: rgba(235,255,255,.58);
  font-size: 14px;
  margin-top: 5px;
}

.notes {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  font-size: 13px;
  color: rgba(235,255,255,.68);
}

.notes div:before {
  content: "◇";
  color: var(--gold);
  margin-right: 8px;
}

.btn {
  /* border: 1px solid rgba(242,213,142,.62);
  background: linear-gradient(#c3944b,#6b461d); */
  background: url(../img/button/btn_task.png) center no-repeat;
  background-size: contain;
  color: #fff4d1;
  font-weight: 600;
  min-width: 100px;
  width: 35%;
  padding: 12px 24px;
  cursor: pointer;
  /* box-shadow: inset 0 0 0 1px rgba(255,255,255,.08),0 10px 24px rgba(0,0,0,.24); */
}
.btn:hover {
  color: #351209;
  background: url(../img/button/btn_task-hover.png) center no-repeat;
  background-size: contain;
}

.card .btn {
  width: 100%;
}

#gameModal {
  position: fixed;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  gap: 0;
  color: white;
  font-family: "Space Mono", monospace;
  overflow: hidden;
  inset: 0;
  z-index: 9999999999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(0,5,8,.92);
  backdrop-filter: blur(9px);
}

#gameModal.active {
  display: flex;
}

#gameModal::before {
  content: "";
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  position: fixed;
  background: url(../img/bg_dark.jpg) top center no-repeat;
  background-size: cover;
  opacity: .35;
  left: 0;
  top: 0;
  z-index: 1;
}

body.game_open {
  overflow: hidden;
}

.game_wrapper {
  width: 100%;
  height: fit-content;
  height: 100%;
  max-height: 720px !important;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 98vw;
  max-height: 100dvh;
  padding: 15px 0;
  overflow: hidden;
  z-index: 99;
  color: white;
  font-family: "Space Mono", monospace;
}

.canvasArea {
  position: relative;
  width: min(
    100%,
    calc((100svh - 20px) * 2 / 3),
    480px
  );
  height: 100%;
  aspect-ratio: 2 / 3;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(200, 255, 250, 0.28);
  border-radius: 25px;
  background: #071923;
  touch-action: none;
  user-select: none;
}

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

.topbar {
  position: absolute;
  z-index: 20;
  left: 15px;
  right: 15px;
  top: 15px;
  display: flex;
  justify-content: space-between;
}

.iconBtn {
  width: 25px;
  height: 25px;
  /* border: 1px solid rgba(255,255,255,.28);
  background: rgba(3,18,24,.82); */
  color: #fff;
  cursor: pointer;
  filter: brightness(5);
}


.btn_sound.active{
  background: url(../img/game/audio_on.png) center no-repeat;
  background-size: cover;
}
.btn_sound{
  background: url(../img/game/audio_off.png) center no-repeat;
  background-size: cover;
}

.iconBtn.btn_close {
  width: 20px;
  height: 20px;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 15;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 25px;
  background: linear-gradient(rgba(3,15,21,.22),rgba(3,12,17,.72));
}

.screen.active {
  display: flex;
}
#readyScreen {
  align-items: center;
  justify-content: flex-end;
  background: url(../img/game/cover.png) center no-repeat;
  background-size: cover;
}
#resultScreen {
  align-items: center;
  justify-content: flex-end;
  background: url(../img/game/end.png) center no-repeat;
  background-size: cover;
}
#readyScreen *, #resultScreen *{
  z-index: 1;
}
#readyScreen::before, #resultScreen::before{
  content: "";
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(to top, rgba(0, 0, 0, .9),rgba(0,0,0,0));
  z-index: 0;
}
/* #resultScreen:has(.resultActions.one) {
  background: linear-gradient(rgba(3,15,21,.22),rgba(3,12,17,.72));
} */

.gameCopy, .resultCopy{
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.96);
}

.small {
  font-size: 12px;
  color: rgba(236,255,255,.52);
  margin-top: 12px;
}

.hud {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 16px;
  right: 16px;
  display: none;
  padding: 11% 0 25px;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
}

.hud.active {
  display: flex;
}

.hudRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  display: flex;
  border-radius: 0;
  gap: 10%;
  padding: 3% 6% 3% 20%;
  background: url(../img/game/stroke.png) right no-repeat;
  background-size: 100% 100%;
  font-size: 12px;
  margin-left: -15%;
  color: #322222;
  align-items: center;
  justify-content: flex-end;
}

.badge b {
  display: block;
  font-size: 20px;
}

.time {
  font-size: 31px;
  font-weight: 800;
  text-shadow: 0 2px 12px #000;
}

.instruction {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
  text-shadow: 0 2px 12px #000;
}

/* =========================================================
   HUD 经脉进度点
========================================================= */
.meridianDots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}

/* 未完成状态 */
.meridianDot {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 246, 216, 0.38);
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 38% 35%,
      rgba(255, 255, 255, 0.2),
      rgba(23, 30, 34, 0.78) 58%,
      rgba(5, 12, 16, 0.92)
    );
  box-shadow:
    inset 0 0 4px rgba(255, 255, 255, 0.12);
  transition:
    background 0.22s ease,
    box-shadow 0.22s ease,
    transform 0.22s ease;
}


/* 完成状态 */
.meridianDot.on {
  transform: scale(1.12);
  border-color:
    rgba(255, 239, 184, 0.95);
  background:
    radial-gradient(
      circle at 38% 35%,
      #ffffff 0,
      #fff0b2 30%,
      #dba94e 68%,
      #805012 100%
    );

  box-shadow:
    0 0 8px rgba(255, 224, 139, 0.95),
    0 0 16px rgba(242, 184, 75, 0.58),
    inset 0 0 4px rgba(255, 255, 255, 0.72);
}

.combo {
  position: absolute;
  z-index: 13;
  right: 16px;
  top: 170px;
  padding: 8px 12px;
  border: 1px solid rgba(242,213,142,.34);
  background: rgba(3,20,26,.74);
  font-size: 12px;
  color: rgba(235,255,255,.7);
  display: none;
}

/* .combo.active {
  display: block;
} */

.combo b {
  display: block;
  color: var(--gold);
  font-size: 24px;
}

.riftHud {
  position: absolute;
  z-index: 13;
  /* left: 16px;
  right: 16px; */
  width: 100%;
  max-width: 100%;
  bottom: 0;
  display: none;
  text-align: center;
  background: linear-gradient(0deg, black, transparent);
}

.riftHud.active {
  display: block;
}

.riftName {
  filter: drop-shadow(0 2px 6px black) drop-shadow(0 0 6px black);
  font-weight: 600;
}

.riftCopy {
  font-size: 13px;
  color: rgba(235,255,255,.65);
  margin-top: 5px;
}

.riftProgress {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.riftDot {
  width: 33.3%;
  height: 5px;
  /* border: 1px solid rgba(255,255,255,.34); */
  background: rgba(255,255,255,.08);
}

.riftDot.on {
  background: #fff1ce;
  box-shadow: 0 0 14px rgba(242,213,142,.9);
}

.timingBar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 92%;
  position: relative;
  aspect-ratio: 412/78;
  margin: 5px auto -10px;
  max-height: 78px;
  padding-top: 3%;
  padding-bottom: 5%;
  background: url(../img/game/timingbar.png) center no-repeat;
  background-size: contain;
  /* background: linear-gradient(180deg,rgba(1,11,16,.94),rgba(10,35,43,.94));
  box-shadow: inset 0 0 18px rgba(117,238,232,.12),0 10px 28px rgba(0,0,0,.3); */
  /* background: url(../img/game/timingbar.png) center no-repeat;
  background-size: contain; */
}


.timingBar:before {
  content: "";
  position: absolute;
  width: 90%;
  height: 55%;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
  border-radius: 99px;
  align-self: center;
  justify-self: center;
  background: rgba(19, 20, 26, 0.75);
  z-index: -1;
}


.timingWrapper:before,.timingWrapper:after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  z-index: 1;
  background: rgba(255,255,255,.1);
}
.timingWrapper:before {
  left: 25%;
}
.timingWrapper:after {
  right: 25%;
}
 
.timingWrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 90%;
  height: 100%;
  overflow: hidden;
  border-radius: 99px;
  align-self: center;
  justify-self: center;
}
.timingWrapper *{
  z-index: -1;
}

.timingGlow {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,transparent,rgba(159,244,238,.07),transparent);
  animation: flow 1.4s linear infinite;
}

.safeZone {
  position: absolute;
  height: 100%;
  border: 1px solid rgba(255,232,155,.9);
  background: linear-gradient(90deg,rgba(167,112,35,.42),rgba(255,224,130,.74),rgba(167,112,35,.42));
  box-shadow: 0 0 18px rgba(255,221,125,.45),inset 0 0 12px rgba(255,255,220,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: left .25s,width .25s;
}

.safeZone span {
  font-size: 11px;
  color: #fff9d7;
  text-shadow: 0 1px 3px #4d2a00;
  white-space: nowrap;
}

.timingNeedle {
  position: absolute;
  bottom: 0;
  width: 21px;
  max-width: 5%;
  aspect-ratio: 21/30;
  z-index: -1;
  margin-left: -10.5px;
  /* background: linear-gradient(#efffff,#80e9e5 48%,#fff0a8);
  box-shadow: 0 0 12px #bffffb,0 0 22px rgba(255,228,135,.65);
  clip-path: polygon(50% 0,100% 20%,72% 100%,28% 100%,0 20%); */
  background: url(../img/game/needle.png) center no-repeat;
  background-size: contain;
}

@keyframes flow {
  from {
    transform: translateX(-60%);
  }
  to {
    transform: translateX(60%);
  }
}

.toast:not(.show){
  display: unset;
}
.toast {
  position: absolute;
  width: fit-content;
  z-index: 18;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-30%);
  opacity: 0;
  padding: 10px 16px;
  background: rgba(4,20,27,.5);
  pointer-events: none;
  transition: transform .35s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%,-50%);
  transition: transform .35s;
}

.result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  padding: 28px 22px;
}
/* .result:has(.resultActions.one) {
  justify-content: center;
} */

.resultRank {
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--gold);
  display: none;
}

.gameTitle, .resultTitle {
  display: none;
  font-family: monospace;
  margin: 10px 0;
  font-size: clamp(12px, 20vw, 50px);
  width: 99%;
  text-wrap: nowrap;
  text-align: center;
  filter: drop-shadow(0 2px 6px black) drop-shadow(0 0 6px black);
}

.resultActions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.resultActions.one {
  grid-template-columns: 1fr;
}

.secondary {
  background: rgba(6,28,37,.95);
  border-color: rgba(154,239,235,.38);
  color: #e8ffff;
}

@media(max-width:760px) {
  .page {
    padding: 0;
  }
  .panel {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 44px 24px;
  }
  .side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 22px;
  }
  .features {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Responsive media layers
   素材的位置、尺寸和缩放由 game.config.js 控制
========================================================= */

.canvasArea canvas {
  position: relative;
  z-index: 10;
}

.game_asset {
  position: absolute;

  left: 0;
  top: 0;

  width: auto;
  height: auto;

  max-width: none;
  max-height: none;

  display: none;
  pointer-events: none;
  user-select: none;

  object-fit: contain;
  object-position: center center;

  /*
   * 真正的 transform 会由 JavaScript 写入。
   * 默认以元素自身左上角作为 transform 计算起点。
   */
  transform-origin: 0 0;
}

.game_asset.active {
  display: block;
}

.game_asset_fg{
  min-width: 390px;
}
.game_asset_char{
  min-width: 300px;
  width: 80%;
}

/* 只在对应游戏阶段显示的图片素材 */
.game_asset_barrier {
  visibility: hidden;
  opacity: 0;
  transition: opacity .18s ease;
}

.game_asset_barrier.state-visible {
  visibility: visible;
}

.game_asset_barrier{
  animation: rotatecenter 6s infinite linear;
}

/* Developer asset adjustment panel */

.game_debug {
  position: absolute;
  z-index: 60;
  top: 58px;
  right: 10px;
  width: min(260px,calc(100% - 20px));
  max-height: calc(100% - 76px);
  overflow: auto;
  padding: 13px;
  border: 1px solid rgba(242,213,142,.5);
  background: rgba(2,13,18,.94);
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  color: #efffff;
  font-size: 12px;
  display: none;
}

.game_debug.active {
  display: block;
}

.game_debug_head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--gold);
}

.game_debug_head button {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,.2);
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.game_debug label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 8px;
  margin: 9px 0;
}

.game_debug label select,.game_debug label input {
  grid-column: 1/-1;
  width: 100%;
}

.game_debug select,.game_debug textarea,.game_debug button {
  font: inherit;
}

.game_debug select {
  min-height: 32px;
  background: #0a242d;
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
}

.game_debug input[type="range"] {
  accent-color: #d9b66c;
}

.game_debug output {
  color: var(--gold);
}

.game_debug_actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 12px;
}

.game_debug_actions button {
  min-height: 34px;
  border: 1px solid rgba(242,213,142,.45);
  background: #18343c;
  color: #fff;
  cursor: pointer;
}

.game_debug textarea {
  width: 100%;
  height: 104px;
  margin-top: 8px;
  padding: 8px;
  resize: vertical;
  background: #031015;
  color: #dff;
  border: 1px solid rgba(255,255,255,.15);
}

.game_debug small {
  display: block;
  line-height: 1.5;
  color: rgba(235,255,255,.58);
  margin-top: 7px;
}

@media(max-width:760px) {
  .game_debug {
    top: 54px;
    right: 7px;
    width: min(235px,calc(100% - 14px));
    font-size: 11px;
  }
}
