@font-face {
  font-family: SiYuan;
  src: url("../assets/fonts/siyuan_medium_sub.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
:root {
  font-family:
    SiYuan,
    -apple-system,
    BlinkMacSystemFont,
    "Microsoft YaHei",
    sans-serif;
  color: #191815;
  font-synthesis: none;
  --view-height: 100vh;
  --green: #138273;
  --land-text: #1e4b3d;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: #faedda;
}
body {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
button,
input {
  font: inherit;
}
button {
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid #178cde;
  outline-offset: 3px;
}
button,
img {
  -webkit-user-select: none;
  user-select: none;
}
img {
  display: block;
}
button[hidden],
[hidden] {
  display: none !important;
}
.viewer {
  min-height: var(--view-height);
  display: flex;
  flex-direction: column;
  background: #faedda url("../assets/images/play_bg.png") center/100% 100%
    no-repeat;
}
h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.portrait-header {
  height: auto;
  min-height: 56px;
  background: #f3f0e9;
  color: #30291f;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: env(safe-area-inset-top) 0 4px;
  box-shadow: 0 1px 4px #3b2c1714;
}
.portrait-header::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #a98c5e70, transparent);
}
.portrait-header h1 {
  flex: 1;
  min-width: 0;
  padding: 4px 52px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  letter-spacing: 0.025em;
}
.portrait-header .back-button {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font: 36px/44px sans-serif;
  width: 32px;
}
.portrait-header .more-button {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #504332;
  line-height: 40px;
}
.portrait-header .more-button:active {
  border-color: transparent;
  background: transparent;
}
.more-button {
  width: 40px;
  height: 44px;
  font-size: 27px;
  line-height: 40px;
}
.board-area {
  width: 100%;
  flex: 0 0 auto;
  padding: 5px;
}
.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  box-shadow: 0 3px 6px #0003;
  background: #ceb053;
}
.board-shell canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}
.board-analysis-popup {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 20px);
  max-width: calc(100% - 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 10px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #f6bd77;
  box-shadow: none;
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: auto;
  cursor: pointer;
}
.load-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  font-size: 15px;
  background: #ceb053aa;
}
.load-state button {
  border: 1px solid #4e3c16;
  padding: 5px 22px;
  border-radius: 4px;
  pointer-events: auto;
  background: #fff9;
}
.load-state.error {
  background: #ceb053e8;
}
.load-state span {
  max-width: 85%;
  text-align: center;
  line-height: 1.7;
}
.loading-progress {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0002;
}
.loading-progress-box {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  background: #202020d9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-spinner {
  position: relative;
  width: 36px;
  height: 36px;
}
.loading-spinner i {
  position: absolute;
  left: calc(50% - 1.5px);
  top: calc(50% - 4.5px);
  width: 3px;
  height: 9px;
  border-radius: 2px;
  background: #fff;
  transform: rotate(calc(var(--spoke) * 30deg)) translateY(-13px);
  animation: loading-spoke 1s linear infinite;
  animation-delay: calc(var(--spoke) * -0.083333s);
}
@keyframes loading-spoke {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.15;
  }
}
.detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.landscape-header {
  display: none;
}
.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  min-height: 40px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 14px;
}
.player-text {
  min-width: 0;
}
.player-text > span:first-child {
  overflow-wrap: anywhere;
}
.avatar {
  width: 20px;
  height: 20px;
  flex: none;
}
.white-player {
  flex-direction: row-reverse;
  text-align: right;
}
.captures,
.player-divider {
  display: none;
}
.panel-gap {
  display: none;
}
.result-area {
  flex: 1;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  color: #ff5252;
  font-size: 18px;
  text-align: center;
  line-height: 1.5;
}
#result:empty {
  visibility: hidden;
}
#result.analysis-result {
  font-size: 14px;
}
.controls {
  padding: 0 10px calc(8px + env(safe-area-inset-bottom));
  flex: none;
}
.progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-box {
  flex: 1;
  min-width: 0;
  padding: 0 6px 0 16px;
}
input[type="range"] {
  --progress: 0%;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin: 0;
  height: 36px;
  cursor: pointer;
  background: transparent;
  display: block;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    #2196f3 var(--progress),
    #2196f34d var(--progress)
  );
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 3px;
  background: #2196f34d;
}
input[type="range"]::-moz-range-progress {
  height: 4px;
  background: #2196f3;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #2196f3;
  margin-top: -8px;
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #2196f3;
}
input[type="range"]:disabled {
  cursor: default;
  opacity: 0.5;
}
input[type="range"]:disabled::-webkit-slider-runnable-track {
  background: #aaa;
}
input[type="range"]:disabled::-webkit-slider-thumb {
  background: #999;
}
.image-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  min-width: 0;
  line-height: 1.4;
  font-size: 14px;
  touch-action: manipulation;
}
.image-button img {
  width: 45px;
  height: 45px;
  object-fit: contain;
  pointer-events: none;
}
.button-label {
  white-space: nowrap;
}
.portrait-play {
  min-width: 45px;
  gap: 8px;
}
.nav-mode {
  font-size: 14px;
  padding: 0 0 4px 20px;
  margin-top: -18px;
}
.portrait-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: start;
  column-gap: 6px;
}
.landscape-navigation,
.landscape-actions,
.landscape-sound {
  display: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.popup-menu {
  position: fixed;
  z-index: 20;
  width: 136px;
  max-width: calc(100vw - 16px);
  background: #fff;
  box-shadow: 0 3px 10px #0005;
  border-radius: 2px;
  padding: 8px 0;
  font-size: 16px;
}
.popup-menu > button,
.menu-sound {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  text-align: left;
}
.popup-menu > button:active,
.menu-sound:active {
  background: #f3f3f3;
}
.menu-sound {
  gap: 6px;
  cursor: pointer;
}
.menu-sound input {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: #e46d66;
  cursor: pointer;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 85vw;
  padding: 10px 16px;
  background: #222d;
  color: #fff;
  border-radius: 5px;
  z-index: 30;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
@media (orientation: landscape) {
  body {
    overflow: hidden;
    background: #899a96;
  }
  .viewer {
    height: var(--view-height);
    min-height: 0;
    display: grid;
    grid-template-columns: 67% 33%;
    background: url("../assets/images_land/pad_live_bg.webp") center/100% 100%
      no-repeat;
    overflow: hidden;
  }
  .portrait-header {
    display: none;
  }
  .board-area {
    display: flex;
    height: 100%;
    padding: 5px;
    align-items: center;
    justify-content: center;
    min-width: 0;
  }
  .board-shell {
    width: min(55vw, calc(var(--view-height) * 0.95));
    max-width: 100%;
    flex: none;
  }
  .detail-panel {
    height: 100%;
    min-width: 0;
    padding: 0 30px;
    background: url("../assets/images_land/live_right_bg.webp") center/100% 100%
      no-repeat;
    color: var(--land-text);
  }
  .landscape-header {
    display: flex;
    height: 35px;
    flex: none;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 27vw;
    max-width: 100%;
    margin: 0 auto;
    background: url("../assets/images_land/pad_title_bg.png") center/100% 100%
      no-repeat;
  }
  .landscape-header h1 {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    padding: 0 40px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .landscape-header .more-button {
    position: absolute;
    right: 0;
    height: 35px;
    line-height: 30px;
    font-size: 24px;
  }
  .player-card {
    width: 27vw;
    max-width: 100%;
    height: 190px;
    min-height: 0;
    flex: none;
    margin: 10px auto 0;
    padding: 10px 0;
    background: url("../assets/images_land/pad_name_info_bg.png") center/100%
      100% no-repeat;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    color: #fff;
  }
  .player-row {
    height: 80px;
    flex: none;
    margin: 0 15px 0 40px;
    padding: 15px;
    gap: 15px;
    font-size: 18px;
  }
  .player-text {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1px;
    font-weight: 700;
  }
  .player-text > span:first-child {
    line-height: 1.3;
  }
  .avatar {
    width: 40px;
    height: 40px;
  }
  .white-player {
    flex-direction: row;
    text-align: left;
  }
  .captures {
    display: inline;
    font-size: 16px;
    font-weight: 400;
    color: #70ccbf;
  }
  .player-divider {
    display: block;
    width: calc(100% - 60px);
    height: 2px;
    object-fit: fill;
    margin: 0 30px;
  }
  .panel-gap {
    display: block;
    flex: 1;
    min-height: 0;
  }
  .result-area {
    flex: none;
    min-height: 38px;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
  }
  .result-area #result {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22vw;
    max-width: 100%;
    min-height: 38px;
    padding: 3px 10px;
    background: url("../assets/images_land/pad_result_bg.png") center/100% 100%
      no-repeat;
    color: #fff;
  }
  .result-area #result.analysis-result {
    font-size: 16px;
    background: none;
    color: #fff;
    font-weight: 400;
  }
  .controls {
    padding: 0 5px 10px;
    width: 27vw;
    max-width: 100%;
    margin: 0 auto;
    flex: none;
  }
  .slider-box {
    padding: 0 10px 0 0;
  }
  input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(
      to right,
      var(--green) var(--progress),
      #13827366 var(--progress)
    );
    height: 5px;
  }
  input[type="range"]::-webkit-slider-thumb {
    background: var(--green);
    margin-top: -7.5px;
  }
  input[type="range"]::-moz-range-progress,
  input[type="range"]::-moz-range-thumb {
    background: var(--green);
  }
  input[type="range"]::-moz-range-track {
    background: #13827366;
  }
  .portrait-play,
  .portrait-actions,
  .nav-mode {
    display: none;
  }
  .landscape-navigation {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 10px;
    height: 54px;
  }
  .landscape-navigation .image-button {
    height: 54px;
    min-width: 44px;
    justify-content: center;
    gap: 0;
  }
  .landscape-navigation .image-button img {
    height: 40px;
    width: 40px;
  }
  .landscape-navigation .back1 img,
  .landscape-navigation .next1 img {
    width: 20px;
  }
  .landscape-navigation .play img {
    width: 30px;
  }
  .landscape-navigation .button-label {
    display: none;
  }
  .landscape-actions {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    margin-top: 10px;
  }
  .landscape-actions .image-button {
    font-size: 16px;
    gap: 8px;
  }
  .landscape-actions .image-button img {
    width: 60px;
    height: 60px;
  }
  .landscape-sound {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 40px;
    font-size: 14px;
    color: #191815;
    cursor: pointer;
  }
  .landscape-sound input {
    accent-color: var(--green);
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
  }
  .menu-sound input {
    accent-color: var(--green);
  }
  .menu-sound {
    display: none;
  }
  .image-button.playing.arrow img {
    visibility: hidden;
  }
  .image-button.playing.arrow {
    position: relative;
  }
  .image-button.playing.arrow:after {
    content: "";
    position: absolute;
    width: 22px;
    height: 30px;
    border-left: 7px solid #15db59;
    border-right: 7px solid #15db59;
    filter: drop-shadow(0 0 2px #fff);
  }
}
@media (orientation: landscape) and (max-height: 550px) {
  .detail-panel {
    padding: 0 12px;
  }
  .player-card {
    height: 140px;
    margin-top: 3px;
  }
  .player-row {
    height: 60px;
    margin-left: 18px;
    padding: 8px;
    gap: 8px;
    font-size: 15px;
  }
  .captures {
    font-size: 13px;
  }
  .avatar {
    width: 30px;
    height: 30px;
  }
  .landscape-sound {
    margin-top: 12px;
  }
  .landscape-actions .image-button img {
    width: 42px;
    height: 42px;
  }
  .landscape-actions .image-button {
    font-size: 13px;
    gap: 3px;
  }
  .landscape-navigation {
    height: 40px;
    margin-top: 3px;
  }
  .landscape-navigation .image-button {
    height: 40px;
    min-width: 28px;
  }
  .landscape-navigation .image-button img {
    max-height: 30px;
  }
  .result-area {
    min-height: 28px;
  }
  .result-area #result {
    min-height: 28px;
    font-size: 15px;
  }
  .landscape-header {
    height: 30px;
  }
  .panel-gap {
    min-height: 2px;
  }
  .controls {
    padding-bottom: 5px;
  }
}
@media (orientation: portrait) and (max-width: 380px) {
  .image-button img {
    width: 40px;
    height: 40px;
  }
  .image-button {
    font-size: 13px;
    gap: 5px;
  }
  .portrait-actions {
    column-gap: 3px;
  }
  .nav-mode {
    padding-bottom: 6px;
  }
  .result-area {
    min-height: 45px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .image-button img {
    transition: filter 0.1s;
  }
  .image-button:active:not(:disabled) img {
    filter: brightness(0.94);
  }
}

/* Keep real, accessible checkboxes while matching the existing palette. */
input[data-sound] {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid #5d4023;
  border-radius: 1px;
  background-color: transparent;
  flex: none;
}
input[data-sound]:checked {
  border-color: #e46d66;
  background-color: #e46d66;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='white' stroke-width='2' d='m3 8 3 3 7-7'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}
@media (orientation: landscape) {
  input[data-sound] {
    border-color: var(--green);
  }
  input[data-sound]:checked {
    border-color: var(--green);
    background-color: var(--green);
  }
}
