:root {
  --bg-start: #08070e;
  --bg-end: #1f1217;
  --surface: #ece8e2;
  --line: #d5ccc3;
  --text: #17120f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Noto Sans TC", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(
      110% 150% at 84% 0%,
      rgba(229, 122, 80, 0.2),
      transparent 42%
    ),
    radial-gradient(
      90% 120% at 12% 16%,
      rgba(210, 169, 86, 0.16),
      transparent 32%
    ),
    linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  min-height: 100vh;
}

.page-wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: 24px;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 8, 14, 0.92);
  border-bottom: 1px solid rgba(230, 176, 113, 0.24);
  backdrop-filter: blur(8px);
}

.top-strip-inner {
  overflow-x: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 58px;
  width: max-content;
  min-width: 100%;
  padding: 0.5rem 0;
}

.icon-button {
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    filter 0.2s ease;
}

.icon-button img {
  width: clamp(168px, 26vw, 280px);
  height: auto;
  display: block;
  pointer-events: none;
}

.icon-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.top-nav-links {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  flex-shrink: 0;
  min-width: max-content;
  white-space: nowrap;
}

.top-bar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.72rem;
  flex: 1 1 auto;
  min-width: max-content;
}

.top-lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.top-lang-switch::after {
  content: "▾";
  position: absolute;
  right: 0.9rem;
  color: #ffe2c4;
  font-size: 0.9rem;
  pointer-events: none;
}

.top-lang-switch__select {
  min-height: 48px;
  padding: 0.7rem 2.25rem 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(236, 192, 135, 0.24);
  background: rgba(36, 24, 30, 0.72);
  color: #fff1e4;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  appearance: none;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.top-lang-switch__select:hover {
  transform: translateY(-1px);
  background: rgba(73, 44, 38, 0.96);
  border-color: rgba(245, 204, 150, 0.5);
  box-shadow: 0 10px 24px rgba(21, 9, 6, 0.34);
}

.top-lang-switch__select:focus-visible {
  outline: 2px solid rgba(255, 213, 170, 0.9);
  outline-offset: 2px;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.02rem;
  border-radius: 999px;
  border: 1px solid rgba(236, 192, 135, 0.24);
  background: rgba(36, 24, 30, 0.72);
  color: #fff1e4;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.top-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(73, 44, 38, 0.96);
  border-color: rgba(245, 204, 150, 0.5);
  box-shadow: 0 10px 24px rgba(21, 9, 6, 0.34);
}

.top-nav-link.is-active {
  background: linear-gradient(
    135deg,
    rgba(227, 122, 78, 0.96),
    rgba(177, 73, 50, 0.96)
  );
  border-color: rgba(255, 219, 178, 0.72);
  color: #fffaf3;
  box-shadow: 0 12px 28px rgba(109, 37, 22, 0.3);
}

.game-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem 0 2rem;
}

.game-stage,
.game-info {
  grid-column: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(33, 18, 14, 0.12);
}

.game-stage {
  --game-frame-width: 1406px;
  --game-frame-height: 894px;
  --game-frame-gap: 14px;
  --game-frame-padding: 20px;
  --game-frame-surface-padding: 0px;
  padding: 8px;
  overflow: hidden;
}

.game-shell-sanguo {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

.game-shell-sanguo .game-shell__toolbar {
  grid-column: 1;
  align-items: center;
  justify-content: flex-start;
  min-height: 72px;
  height: 72px;
  padding: 10px 14px;
  background: rgba(36, 20, 22, 0.94);
}

.game-shell-sanguo .game-shell__toolbar-group {
  gap: 10px;
}

.game-shell-sanguo .game-shell__button {
  min-height: 46px;
  padding: 0.72rem 1.18rem;
  font-size: 1.25rem;
}

.game-shell-sanguo .game-shell__play {
  grid-column: 1;
  grid-row: 2;
  align-items: stretch;
  justify-items: center;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    rgba(24, 13, 15, 0.92);
  box-shadow: none;
}

.sanguo-surface {
  position: relative;
  display: grid;
  place-items: center;
  width: 1366px;
  height: 768px;
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(243, 192, 132, 0.32);
  background: #000;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 18px 34px rgba(0, 0, 0, 0.28);
  user-select: none;
  touch-action: none;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  background: #000;
  object-fit: contain;
  touch-action: none;
}

#gameViewport:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0;
  border-radius: 0;
  border: 0;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#gameViewport:fullscreen #canvas {
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain;
}

.game-shell-stage:fullscreen .game-shell-sanguo {
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  border-radius: 0;
  background: #000;
}

.game-shell-stage:fullscreen .game-shell-sanguo .game-shell__toolbar {
  display: none;
}

.game-shell-stage:fullscreen .game-shell-sanguo .game-shell__play {
  grid-row: 1;
  padding: 0;
  border-radius: 0;
  background: #000;
}

.sanguo-noscript {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #ffe6d0;
  font-size: 0.95rem;
}

.sanguo-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  padding: 24px;
  background: rgba(11, 5, 8, 0.56);
  backdrop-filter: blur(4px);
}

.sanguo-status.is-hidden {
  display: none;
}

.sanguo-status__panel {
  width: min(100%, 520px);
  padding: 1.6rem;
  border-radius: 22px;
  border: 1px solid rgba(243, 192, 132, 0.26);
  background:
    linear-gradient(165deg, rgba(37, 19, 21, 0.95), rgba(49, 24, 22, 0.9)),
    radial-gradient(circle at top, rgba(255, 195, 130, 0.14), transparent 44%);
  color: #fff3e6;
  text-align: center;
  box-shadow: 0 26px 58px rgba(0, 0, 0, 0.45);
}

.sanguo-status__progress {
  display: block;
  width: 100%;
  height: 16px;
  margin: 1rem 0 0.8rem;
  accent-color: #e58b4f;
}

.sanguo-status__hint {
  margin: 0;
  color: #ffd7b3;
  font-size: 1rem;
}

.sanguo-status__notice {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 178, 148, 0.5);
  background: rgba(93, 31, 26, 0.6);
  color: #ffe8dc;
  font-size: 0.95rem;
  line-height: 1.45;
}

.sanguo-audio-toggle.is-muted {
  opacity: 0.88;
}

.game-kicker {
  margin: 0 0 0.45rem !important;
  color: #a35d43;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-info__panel h2 {
  margin: 0 0 0.6rem;
}

.game-info__lead {
  color: #4f3930;
  font-size: 1.06rem;
  font-weight: 700;
}

.game-info__panel p {
  margin: 0.42rem 0;
  line-height: 1.7;
}

.game-info__panel h3 {
  margin: 1.2rem 0 0.45rem;
}

.site-footer {
  border-top: 1px solid rgba(214, 176, 141, 0.32);
  padding: 1rem 0 1.5rem;
  color: #f1d9c3;
}

.site-footer a {
  color: #ffe9d5;
}

@media (max-width: 768px) {
  .page-wrap {
    padding-inline: 10px;
  }

  .game-page {
    padding-top: 0.75rem;
  }

  .game-stage {
    padding: 8px;
    overflow: hidden;
  }

  .game-shell-sanguo {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .game-shell-sanguo .game-shell__toolbar {
    min-height: 46px;
    height: 46px;
    padding: 6px 8px;
  }

  .game-shell-sanguo .game-shell__toolbar-group {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .game-shell-sanguo .game-shell__button {
    min-height: 34px;
    padding: 0.42rem 0.58rem;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .sanguo-audio-toggle {
    width: 34px;
    min-width: 34px;
    padding-inline: 0;
  }

  .game-shell-sanguo .game-shell__play {
    padding: 0;
  }

  .sanguo-surface {
    width: 1366px;
    height: 768px;
    max-width: none;
    max-height: none;
    border-radius: 14px;
  }

  .sanguo-status {
    padding: 18px;
  }

  .sanguo-status__panel {
    width: min(100%, 520px);
    padding: 1.2rem;
    border-radius: 18px;
  }

  .sanguo-load-title {
    font-size: 1.7rem;
  }

  .sanguo-start-btn {
    min-width: 220px;
    min-height: 56px;
    font-size: 1.35rem;
  }
}

.sanguo-load-title {
  margin: 0 0 1.15rem;
  color: #fff3e6;
  font-size: clamp(1.6rem, 2.7vw, 2.15rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.sanguo-start-btn {
  margin: 1.1rem 0 0.85rem;
  min-width: 220px;
  min-height: 60px;
  border: 1px solid rgba(255, 219, 178, 0.75);
  border-radius: 999px;
  background: linear-gradient(135deg, #e58b4f, #b84a31);
  color: #fffaf3;
  padding: 0.9rem 2rem;
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(87, 28, 17, 0.35);
}

.sanguo-start-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.sanguo-start-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media (max-width: 560px) {
  .top-bar-actions {
    min-width: auto;
  }

  .top-lang-switch__select {
    min-height: 44px;
    padding-inline: 0.9rem 2rem;
    font-size: 0.96rem;
  }
}
