:root {
  color-scheme: dark;
  --bg: #10151a;
  --panel: rgba(25, 31, 39, 0.82);
  --panel-strong: #17202a;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #aab7c7;
  --cyan: #6de7ff;
  --lime: #9df7a8;
  --coral: #ff6f88;
  --amber: #ffd166;
  --ink: #091013;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 15% 20%, rgba(109, 231, 255, 0.13), transparent 30%),
    linear-gradient(135deg, #0d1717 0%, #151923 43%, #201821 100%);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.game-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 24px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.hero-panel,
.play-panel,
.graph-panel,
.side-panel > section {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  min-height: 176px;
  grid-column: 1 / -1;
  border-radius: 8px;
  padding: clamp(18px, 3vw, 28px);
}

.hero-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  opacity: 0.3;
}

.hero-grid span {
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(135deg, rgba(109, 231, 255, 0.12), transparent 48%),
    linear-gradient(315deg, rgba(255, 209, 102, 0.1), transparent 50%);
}

.hero-content,
.status-row {
  position: relative;
  z-index: 1;
}

.hero-content {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow,
.result-label {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2.35rem, 6.4vw, 4.85rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-switch {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(118px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid rgba(109, 231, 255, 0.32);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(7, 13, 19, 0.72);
  box-shadow: 0 0 0 1px rgba(109, 231, 255, 0.08), 0 12px 28px rgba(0, 0, 0, 0.24);
  font-size: 0.78rem;
  font-weight: 900;
}

.language-switch select {
  min-width: 118px;
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.icon-button,
.pill-button,
.hint-button,
.mic-button,
.go-button,
.tab-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  color: var(--text);
}

.icon-button {
  width: 44px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
}

.pill-button {
  padding: 0 18px;
  background: var(--coral);
  color: white;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  max-width: 920px;
  margin-top: clamp(20px, 4vw, 32px);
}

.status-chip {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 16, 0.42);
}

.status-chip span,
.answer-top span,
.mini-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-chip strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.06rem, 3vw, 1.55rem);
}

.play-panel {
  min-width: 0;
  border-radius: 8px;
  padding: clamp(14px, 2.4vw, 22px);
}

.graph-panel {
  position: relative;
  grid-column: 1;
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(240px, 0.86fr) minmax(320px, 1.14fr);
  min-height: 430px;
  background:
    linear-gradient(135deg, rgba(109, 231, 255, 0.1), transparent 38%),
    linear-gradient(315deg, rgba(157, 247, 168, 0.08), transparent 46%),
    var(--panel);
}

.graph-panel::before {
  content: "";
  position: absolute;
  inset: -45%;
  pointer-events: none;
  opacity: 0.28;
  background:
    conic-gradient(from 0deg, transparent, rgba(109, 231, 255, 0.34), transparent, rgba(255, 209, 102, 0.24), transparent);
  animation: graph-orbit 18s linear infinite;
}

.graph-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 72% 50%, black, transparent 70%);
}

.graph-copy {
  position: relative;
  z-index: 1;
  padding: clamp(16px, 2.4vw, 24px);
  display: grid;
  align-content: center;
  gap: 14px;
}

.graph-copy h2 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.7rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.graph-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 760;
}

.graph-principles {
  display: grid;
  gap: 8px;
}

.graph-principles div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 16, 0.42);
}

.graph-principles strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.graph-principles span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.42;
  font-weight: 760;
}

.graph-stage {
  position: relative;
  z-index: 1;
  min-height: 430px;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 40%, rgba(109, 231, 255, 0.12), transparent 32%),
    rgba(3, 8, 12, 0.34);
}

.semantic-graph {
  position: absolute;
  inset: 0;
}

.semantic-graph canvas {
  display: block;
}

.graph-status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(8, 12, 16, 0.72);
  font-size: 0.78rem;
  font-weight: 850;
  pointer-events: none;
}

@keyframes graph-orbit {
  to {
    transform: rotate(360deg);
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.select-wrap {
  flex: 1 1 150px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(7, 13, 19, 0.72);
  outline: 0;
}

select {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
}

.guess-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 82px;
  gap: 8px;
  min-width: 0;
}

input {
  min-height: 56px;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 1.12rem;
  font-weight: 800;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: rgba(109, 231, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(109, 231, 255, 0.14);
}

input.voice-active {
  border-color: rgba(157, 247, 168, 0.75);
  box-shadow: 0 0 0 3px rgba(157, 247, 168, 0.11);
}

.go-button {
  background: var(--amber);
  color: #201306;
}

.mic-button {
  display: grid;
  place-items: center;
  min-height: 56px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.mic-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mic-button.listening {
  color: #081014;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(157, 247, 168, 0.13);
  animation: listen-pulse 920ms ease-in-out infinite alternate;
}

.mic-button.unsupported {
  color: rgba(255, 255, 255, 0.38);
  cursor: not-allowed;
}

.hint-button {
  padding: 0 16px;
  background: rgba(109, 231, 255, 0.16);
  border: 1px solid rgba(109, 231, 255, 0.28);
}

.hint-button.disabled,
.hint-button:disabled {
  color: rgba(255, 255, 255, 0.42);
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

@keyframes listen-pulse {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-1px);
  }
}

.result-card {
  position: relative;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(109, 231, 255, 0.12), transparent 48%),
    rgba(7, 13, 19, 0.62);
}

.result-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 18% 20%, var(--feedback-color), transparent 42%);
}

.result-card.feedback-hit {
  --feedback-color: rgba(157, 247, 168, 0.42);
  animation: hit-pop 360ms ease;
  border-color: rgba(157, 247, 168, 0.72);
}

.result-card.feedback-near {
  --feedback-color: rgba(255, 209, 102, 0.34);
  animation: near-glow 420ms ease;
  border-color: rgba(255, 209, 102, 0.55);
}

.result-card.feedback-miss {
  --feedback-color: rgba(255, 111, 136, 0.34);
  animation: miss-shake 280ms ease;
  border-color: rgba(255, 111, 136, 0.62);
}

.result-card.feedback-hit::after,
.result-card.feedback-near::after,
.result-card.feedback-miss::after {
  animation: feedback-wash 420ms ease;
}

.result-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#latestGuess {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  line-height: 1.08;
}

.score-readout {
  flex: 0 0 auto;
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 0.95;
  color: var(--text);
}

.meter {
  height: 12px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--lime), var(--amber), var(--coral));
  transition: width 180ms ease;
}

.feedback {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 9, 13, 0.48);
}

.tab-button {
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: white;
  color: #111820;
}

.guess-list {
  display: grid;
  gap: 8px;
  min-height: 330px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.guess-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) minmax(80px, auto);
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--row-color) 24%, transparent), transparent 60%),
    rgba(9, 15, 20, 0.74);
  animation: row-enter 260ms ease both;
}

.guess-item:first-child {
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}

.guess-rank {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--row-color);
  color: #121212;
  font-weight: 1000;
}

.guess-name {
  min-width: 0;
  font-size: 1.08rem;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.guess-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.guess-score {
  justify-self: end;
  min-width: 76px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
  font-size: 1.04rem;
  font-weight: 1000;
  color: var(--row-color);
  background: rgba(0, 0, 0, 0.26);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  padding: 22px;
}

.side-panel {
  grid-column: 2;
  grid-row: 2 / span 2;
  display: grid;
  align-content: start;
  gap: 14px;
}

.side-panel > section {
  border-radius: 8px;
  padding: 16px;
}

.answer-panel {
  background:
    linear-gradient(145deg, rgba(157, 247, 168, 0.12), transparent 48%),
    var(--panel);
}

.challenge-panel {
  display: grid;
  gap: 12px;
}

.challenge-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.challenge-head span,
.challenge-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.challenge-head strong {
  text-align: right;
}

.challenge-goal {
  min-height: 2.7em;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.45;
}

.timer-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.timer-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lime), var(--amber), var(--coral));
  transition: width 180ms linear;
}

.challenge-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.challenge-stats div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.challenge-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.answer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#targetMask {
  font-size: 1.8rem;
  overflow-wrap: anywhere;
  text-align: right;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mini-grid div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.mini-grid strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
}

.hint-stack {
  display: grid;
  gap: 8px;
}

.hint-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 12, 16, 0.42);
}

.hint-card span {
  display: block;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
}

.hint-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.powered-panel {
  padding: 12px;
}

.powered-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.powered-link:hover .powered-copy strong,
.powered-link:focus-visible .powered-copy strong {
  color: var(--cyan);
}

.powered-link:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(109, 231, 255, 0.16);
  border-radius: 8px;
}

.powered-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.powered-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.powered-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.powered-copy span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.powered-copy strong {
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  transition: color 140ms ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 28px));
  transform: translate(-50%, 18px);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(8, 12, 16, 0.92);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.round-flash {
  position: fixed;
  left: 50%;
  top: 22px;
  z-index: 30;
  transform: translate(-50%, -18px) scale(0.96);
  max-width: min(520px, calc(100vw - 28px));
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(8, 12, 16, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: clamp(1rem, 4vw, 1.55rem);
  font-weight: 1000;
}

.round-flash.show {
  animation: flash-in 920ms ease both;
}

.round-flash.hit {
  border-color: rgba(157, 247, 168, 0.68);
  color: var(--lime);
}

.round-flash.near {
  border-color: rgba(255, 209, 102, 0.68);
  color: var(--amber);
}

.round-flash.miss {
  border-color: rgba(255, 111, 136, 0.68);
  color: var(--coral);
}

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  left: 50%;
  top: 22%;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  background: var(--confetti-color);
  transform: translate(-50%, -50%) rotate(0deg);
  animation: confetti-fall 880ms ease-out forwards;
}

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

.win .result-card {
  border-color: rgba(157, 247, 168, 0.7);
  box-shadow: 0 0 0 3px rgba(157, 247, 168, 0.1);
}

@keyframes hit-pop {
  0% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.018);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes near-glow {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-2px);
  }
}

@keyframes miss-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  50% {
    transform: translateX(5px);
  }

  75% {
    transform: translateX(-3px);
  }
}

@keyframes feedback-wash {
  0% {
    opacity: 0;
  }

  40% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flash-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.96);
  }

  16%,
  74% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

@keyframes confetti-fall {
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--spin));
  }
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-columns: 1fr;
    padding-bottom: 88px;
  }

  .hero-panel {
    min-height: 160px;
  }

  .side-panel {
    grid-row: 2;
    grid-column: 1;
  }

  .play-panel {
    grid-row: 3;
  }

  .graph-panel {
    grid-row: 4;
    grid-column: 1;
    grid-template-columns: 1fr;
  }

  .graph-stage {
    min-height: 360px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .game-shell {
    padding: 10px;
    gap: 10px;
  }

  .hero-content {
    display: grid;
  }

  .hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .language-switch {
    flex: 1 1 auto;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .language-switch select {
    min-width: 0;
  }

  .status-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .status-chip {
    padding: 10px 8px;
  }

  .status-chip strong {
    font-size: 1rem;
  }

  .guess-form,
  .input-wrap {
    grid-template-columns: 1fr;
  }

  .hint-button,
  .mic-button,
  .go-button {
    width: 100%;
  }

  .result-main {
    display: grid;
  }

  .score-readout {
    justify-self: start;
  }

  .guess-item {
    grid-template-columns: 38px minmax(0, 1fr) 76px;
    gap: 8px;
    padding: 8px;
  }

  .guess-rank {
    width: 34px;
    height: 34px;
  }

  .guess-score {
    min-width: 68px;
    padding: 7px 8px;
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
