:root {
  color-scheme: only light;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #3d2416;
  background: #2e160c;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-width: 320px;
  background:
    linear-gradient(rgba(31,12,5,.25), rgba(31,12,5,.5)),
    url("./assets/art/a16/main_ui/backgrounds/desk_with_props_no_cards_ui.png") center / cover fixed;
}
button, a { font: inherit; }
button { cursor: pointer; }
.lab-app { min-height: 100vh; padding: 18px clamp(14px, 2vw, 32px) 28px; }
.lab-header {
  display: grid;
  grid-template-columns: minmax(155px, 1fr) auto minmax(155px, 1fr);
  align-items: center;
  max-width: 1480px;
  margin: 0 auto 16px;
  color: #fff2c9;
  text-shadow: 0 2px 2px #341309;
}
.lab-header img { width: min(280px, 29vw); max-height: 92px; object-fit: contain; }
.lab-header > div { justify-self: end; display: grid; text-align: right; }
.lab-header span { color: #f1bd57; font-size: 11px; letter-spacing: .24em; }
.lab-header strong { font: 900 clamp(22px, 2.1vw, 32px) "Kaiti SC", "STKaiti", serif; }
.lab-header small { opacity: .82; }
.lab-back {
  justify-self: start;
  padding: 10px 16px;
  border: 1px solid rgba(255,224,155,.58);
  border-radius: 999px;
  color: #fff3cc;
  background: rgba(54,22,10,.68);
  text-decoration: none;
}
.lab-layout {
  display: grid;
  grid-template-columns: 230px minmax(620px, 1fr) 230px;
  gap: 16px;
  max-width: 1480px;
  margin: auto;
  align-items: start;
}
.lab-modes, .lab-notes, .lab-board {
  border: 1px solid rgba(249,216,143,.62);
  border-radius: 18px;
  background: rgba(245,224,178,.94);
  box-shadow: 0 12px 28px rgba(28,9,3,.4), inset 0 0 0 3px rgba(115,61,28,.12);
}
.lab-modes, .lab-notes { padding: 18px; }
.lab-modes h2, .lab-notes h2 { margin: 0 0 13px; font: 900 22px "Kaiti SC", "STKaiti", serif; }
.lab-modes > button {
  width: 100%;
  margin: 0 0 10px;
  padding: 13px 12px;
  border: 1px solid rgba(104,55,26,.28);
  border-radius: 12px;
  color: #63371f;
  background: rgba(255,248,221,.75);
  text-align: left;
  box-shadow: 0 3px 6px rgba(72,34,12,.12);
}
.lab-modes > button[aria-pressed="true"] {
  color: #fff7d9;
  border-color: #73311b;
  background: linear-gradient(145deg, #b84b27, #7c2819);
  transform: translateX(5px);
}
.lab-modes button b, .lab-modes button span { display: block; }
.lab-modes button b { margin-bottom: 4px; font-size: 17px; }
.lab-modes button span { font-size: 12px; opacity: .78; line-height: 1.45; }
.lab-isolation { display: flex; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed #b68555; font-size: 12px; }
.lab-isolation p { margin: 0; line-height: 1.5; }
.lab-board { min-width: 0; overflow: hidden; }
.lab-hud {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 20px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(111,55,24,.22);
  background: linear-gradient(#fff4d4, #e8c98e);
}
.lab-hud small { display: block; color: #8b603d; font-size: 11px; }
.lab-hud h1, .lab-hud strong { margin: 0; }
.lab-hud h1 { font: 900 24px "Kaiti SC", "STKaiti", serif; color: #872c1d; }
.lab-hud strong { font-size: 16px; }
.lab-objective, .lab-counter { min-width: 125px; padding-left: 18px; border-left: 1px solid rgba(117,66,34,.22); }
.lab-canvas-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: url("./assets/art/a16/main_ui/backgrounds/desk_clean_wood.png") center / cover;
}
#lab-canvas { display: block; width: 100%; height: 100%; outline: 0; touch-action: none; }
#lab-canvas:focus-visible { box-shadow: inset 0 0 0 4px #f7c95c; }
.lab-turn-banner {
  position: absolute;
  left: 50%; top: 16px;
  transform: translateX(-50%);
  min-width: 128px;
  padding: 6px 15px;
  border: 2px solid #f5d894;
  border-radius: 999px;
  color: #fff6d8;
  background: rgba(91,32,18,.88);
  text-align: center;
  font-weight: 900;
  pointer-events: none;
}
.lab-turn-banner[data-actor="ai"] { background: rgba(167,29,29,.9); }
.lab-charge {
  position: absolute;
  left: var(--charge-x, 50%);
  top: var(--charge-y, 60%);
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 5px;
  color: #fff6dc;
  font-weight: 800;
  pointer-events: none;
  filter: drop-shadow(0 5px 8px rgba(45,17,7,.48));
}
.lab-charge[hidden] { display: none; }
.lab-charge-ring {
  position: relative;
  width: clamp(98px, 15vw, 142px);
  aspect-ratio: 1;
  border: 3px solid rgba(255,244,201,.86);
  border-radius: 50%;
  background: conic-gradient(#4e9fe8 0 40%, #58b969 40% 75%, #eb9b32 75% 90%, #d64232 90% 100%);
  box-shadow: inset 0 0 0 4px rgba(47,21,12,.35), 0 0 0 2px rgba(72,30,14,.65);
}
.lab-charge-ring::after {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: rgba(48,22,12,.91);
  box-shadow: inset 0 0 12px rgba(0,0,0,.55);
}
.lab-charge-ring > i {
  position: absolute;
  inset: -6px;
  z-index: 2;
  border-radius: 50%;
  background: conic-gradient(#fff3aa 0 var(--charge-progress, 0%), transparent var(--charge-progress, 0%) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
}
.lab-charge-ring > div {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  text-align: center;
}
.lab-charge-ring b { font-size: 25px; line-height: 1; }
.lab-charge-ring span { margin-top: 5px; color: #ffe08a; font-size: 13px; }
.lab-charge small { padding: 4px 9px; border-radius: 99px; background: rgba(48,22,12,.82); white-space: nowrap; }
.lab-charge[data-band="power"] .lab-charge-ring { animation: charge-wobble .14s infinite alternate; }
.lab-charge[data-band="over"] .lab-charge-ring { animation: charge-pulse .24s infinite alternate; }
.lab-charge[data-band="over"]::before,
.lab-charge[data-band="over"]::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 3px;
  top: 40%;
  background: #ffe09a;
  box-shadow: 0 12px #e8a84a, 0 -12px #fff0b8;
}
.lab-charge[data-band="over"]::before { right: 88%; transform: rotate(-12deg); }
.lab-charge[data-band="over"]::after { left: 88%; transform: rotate(12deg); }
@keyframes charge-wobble { to { transform: translateX(2px) scale(1.02); } }
@keyframes charge-pulse { to { transform: scale(1.08); filter: brightness(1.18); } }
.lab-ai-target {
  position: absolute;
  left: var(--target-x, 50%);
  top: var(--target-y, 50%);
  width: 92px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 4px solid rgba(221,47,36,.88);
  border-radius: 50%;
  box-shadow: 0 0 0 7px rgba(255,235,188,.35), inset 0 0 16px rgba(203,33,23,.32);
  animation: ai-aim .42s infinite alternate;
  pointer-events: none;
}
.lab-ai-target[hidden], .lab-callout[hidden] { display: none; }
.lab-ai-target::before, .lab-ai-target::after { content: ""; position: absolute; background: #e3392c; }
.lab-ai-target::before { left: 50%; top: -12px; bottom: -12px; width: 2px; }
.lab-ai-target::after { top: 50%; left: -12px; right: -12px; height: 2px; }
.lab-ai-target span { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); padding: 3px 8px; border-radius: 99px; color: white; background: #a71919; font-size: 11px; white-space: nowrap; }
@keyframes ai-aim { to { transform: translate(-50%, -50%) scale(.88); } }
.lab-callout {
  position: absolute;
  left: 50%; top: 43%;
  z-index: 5;
  transform: translate(-50%, -50%) rotate(-4deg);
  color: #fff1b1;
  font: 900 clamp(30px, 6vw, 62px) "Kaiti SC", serif;
  text-shadow: 0 4px #9e211a, 3px 0 #9e211a, -3px 0 #9e211a, 0 -3px #9e211a, 0 8px 15px rgba(38,11,4,.6);
  animation: callout-pop .8s both;
  pointer-events: none;
}
@keyframes callout-pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.35) rotate(-8deg); } 28% { opacity: 1; transform: translate(-50%, -50%) scale(1.16) rotate(-4deg); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.96) rotate(-2deg); } }
.lab-duel-score {
  position: absolute;
  top: 16px; left: 16px;
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 8px 12px;
  border: 2px solid #eed492;
  border-radius: 12px;
  color: #fff4cf;
  background: rgba(46,21,12,.86);
}
.lab-duel-score[hidden] { display: none; }
.lab-duel-score span b { font-size: 24px; }
.lab-duel-score i { color: #f2b74c; font-weight: 900; }
.lab-duel-score small { padding-left: 9px; border-left: 1px solid rgba(255,255,255,.25); }
.lab-ai-difficulty {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px dashed rgba(98,50,23,.28);
  background: rgba(115,54,24,.08);
}
.lab-ai-difficulty[hidden] { display: none; }
.lab-ai-difficulty > span { font-weight: 900; }
.lab-ai-difficulty button {
  min-height: 36px;
  padding: 5px 15px;
  border: 1px solid #8d4b2b;
  border-radius: 999px;
  color: #60321d;
  background: #f5dfaa;
}
.lab-ai-difficulty button[aria-pressed="true"] { color: #fff7dc; background: #9b3822; }
.lab-ai-difficulty button:disabled { cursor: default; opacity: .55; }
.lab-ai-difficulty small { margin-left: auto; color: #7b563b; }
.lab-feedback {
  display: flex;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px 16px;
  border-top: 1px solid rgba(98,50,23,.16);
}
.lab-feedback p { margin: 0; line-height: 1.55; }
.lab-feedback button, .lab-result-actions button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 24px;
  border: 2px solid #7a351d;
  border-radius: 999px;
  color: #fff8d9;
  background: linear-gradient(#c35a2e, #87301d);
  font-weight: 900;
}
.lab-rewards { display: flex; gap: 18px; align-items: center; min-height: 126px; padding: 12px 16px; background: rgba(116,57,27,.08); }
.lab-rewards h2 { margin: 0; font: 900 18px "Kaiti SC", "STKaiti", serif; }
.lab-rewards p { max-width: 220px; margin: 4px 0 0; color: #805b3e; font-size: 12px; }
.lab-reward-list, .lab-result-rewards { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-height: 96px; }
.lab-reward-card { width: 64px; aspect-ratio: 2 / 3; perspective: 600px; }
.lab-reward-card > span { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .65s cubic-bezier(.2,.75,.25,1); }
.lab-reward-card.is-revealed > span { transform: rotateY(180deg); }
.lab-reward-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; backface-visibility: hidden; box-shadow: 0 5px 9px rgba(58,24,8,.3); }
.lab-reward-card img:last-child { transform: rotateY(180deg); }
.lab-notes ol { margin: 0; padding-left: 21px; line-height: 1.65; font-size: 13px; }
.lab-notes li + li { margin-top: 8px; }
.lab-stats { display: grid; gap: 8px; margin-top: 20px; padding-top: 15px; border-top: 1px dashed #b68555; }
.lab-stats span { display: flex; justify-content: space-between; }
.lab-result {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 18px;
  color: #4d2918;
  background: #f5dfad;
  box-shadow: 0 20px 60px rgba(32,10,3,.6), inset 0 0 0 5px rgba(138,73,35,.2);
}
.lab-result::backdrop { background: rgba(35,13,5,.72); backdrop-filter: blur(4px); }
.lab-result form { padding: 24px; text-align: center; }
.lab-result-kicker { color: #a44b29; font-weight: 900; }
.lab-result h2 { margin: 8px 0; font: 900 36px "Kaiti SC", "STKaiti", serif; }
.lab-result-copy { line-height: 1.65; }
.lab-result-breakdown { display: grid; gap: 6px; margin: 13px auto; max-width: 440px; }
.lab-result-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 7px 10px; border: 1px solid rgba(116,61,30,.18); border-radius: 9px; background: rgba(255,247,215,.58); font-size: 13px; }
.lab-result-row b { color: #982f20; }
.lab-reward-card { position: relative; }
.lab-reward-kind { position: absolute; z-index: 5; left: -5px; top: -5px; padding: 2px 5px; border-radius: 5px; color: white; background: #2b7651; font-size: 9px; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.lab-reward-kind.is-bonus { background: #b74625; }
.lab-result-rewards { justify-content: center; margin: 16px 0; }
.lab-result-rewards .lab-reward-card { width: 78px; }
.lab-result-actions { display: flex; justify-content: center; gap: 12px; }
.lab-result-actions button:first-child { color: #5b351e; background: #e6c98d; }
.lab-result-actions button:last-child { background: linear-gradient(#e69335, #b54f20); }

@media (max-width: 1050px) {
  .lab-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .lab-notes { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; }
  .lab-notes ol { display: flex; gap: 25px; }
  .lab-notes li { flex: 1; }
}
@media (max-width: 760px) {
  .lab-app { padding: 10px; }
  .lab-header { grid-template-columns: auto 1fr; }
  .lab-header img { width: 145px; }
  .lab-header > div { display: none; }
  .lab-back { font-size: 12px; }
  .lab-layout { display: block; }
  .lab-modes { display: flex; gap: 7px; margin-bottom: 10px; padding: 10px; overflow-x: auto; }
  .lab-modes h2, .lab-isolation { display: none; }
  .lab-modes > button { flex: 0 0 145px; margin: 0; padding: 9px; }
  .lab-modes > button[aria-pressed="true"] { transform: translateY(-2px); }
  .lab-hud { grid-template-columns: 1fr 1fr; padding: 9px 12px; }
  .lab-hud h1 { font-size: 20px; }
  .lab-counter { display: none; }
  .lab-objective { min-width: 0; }
  .lab-feedback { align-items: flex-start; }
  .lab-feedback p { font-size: 13px; }
  .lab-feedback button { padding: 8px 14px; }
  .lab-rewards { min-height: 110px; }
  .lab-rewards > div:first-child { display: none; }
  .lab-notes { display: none; }
  .lab-duel-score { top: 10px; left: 8px; padding: 5px 8px; font-size: 12px; }
  .lab-duel-score span b { font-size: 18px; }
  .lab-turn-banner { top: 8px; font-size: 12px; }
  .lab-ai-difficulty { flex-wrap: wrap; padding: 7px 10px; }
  .lab-ai-difficulty small { flex-basis: 100%; margin: 0; font-size: 11px; }
  .lab-charge-ring { width: 96px; }
  .lab-result-row { grid-template-columns: 1fr; text-align: left; }
}
@media (max-height: 430px) and (orientation: landscape) {
  .lab-app { padding: 4px 8px 10px; }
  .lab-header { grid-template-columns: auto 1fr; margin-bottom: 4px; }
  .lab-header img { width: 112px; max-height: 38px; justify-self: end; }
  .lab-header > div { display: none; }
  .lab-back { min-height: 40px; padding: 7px 12px; font-size: 12px; }
  .lab-layout { display: block; }
  .lab-modes { display: flex; gap: 6px; margin-bottom: 4px; padding: 5px; overflow-x: auto; }
  .lab-modes h2, .lab-isolation { display: none; }
  .lab-modes > button { flex: 1 0 150px; min-height: 42px; margin: 0; padding: 5px 9px; }
  .lab-modes > button[aria-pressed="true"] { transform: none; }
  .lab-modes button b { margin: 0; font-size: 14px; }
  .lab-modes button span { display: none; }
  .lab-hud { padding: 5px 10px; min-height: 44px; }
  .lab-hud h1 { font-size: 19px; }
  .lab-canvas-wrap { height: 250px; aspect-ratio: auto; }
  .lab-feedback { min-height: 48px; padding: 5px 10px; }
  .lab-rewards, .lab-notes { display: none; }
  .lab-charge-ring { width: 82px; }
  .lab-charge small { font-size: 10px; }
  .lab-ai-difficulty small { display: none; }
  .lab-ai-difficulty { padding: 4px 10px; min-height: 44px; }
  .lab-ai-difficulty button { min-width: 58px; min-height: 40px; }
  .lab-duel-score { min-height: 44px; }
}
