:root {
  --bg-1: #fff6fb;
  --bg-2: #ffe0f3;
  --bg-3: #fff3cc;
  --card: rgba(255, 255, 255, 0.78);
  --card-border: rgba(255, 255, 255, 0.7);
  --text-main: #73355f;
  --text-soft: #9e5f85;
  --shadow: 0 24px 70px rgba(196, 104, 157, 0.2);
  --pink: linear-gradient(135deg, #ff82b2, #ff5f8f);
  --green: linear-gradient(135deg, #74d59d, #4bb77a);
  --purple: linear-gradient(135deg, #b17cff, #8a55ea);
  --orange: linear-gradient(135deg, #ffb05f, #ff8750);
  --brown: linear-gradient(135deg, #bf8b65, #9a6544);
  --blue: linear-gradient(135deg, #73b7ff, #438dff);
  --danger: linear-gradient(135deg, #ff5c72, #ff8693);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 32%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.85), transparent 28%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
}

.page-shell {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 28px 16px 48px;
}

.spark {
  position: absolute;
  border-radius: 999px;
  filter: blur(6px);
  opacity: 0.55;
  pointer-events: none;
  animation: floaty 7s ease-in-out infinite;
}

.spark-a {
  top: 6%;
  left: 10%;
  width: 120px;
  height: 120px;
  background: rgba(255, 140, 181, 0.34);
}

.spark-b {
  top: 18%;
  right: 12%;
  width: 140px;
  height: 140px;
  background: rgba(159, 124, 255, 0.3);
  animation-delay: -2s;
}

.spark-c {
  bottom: 12%;
  left: 18%;
  width: 160px;
  height: 160px;
  background: rgba(255, 181, 96, 0.25);
  animation-delay: -4s;
}

.game-card {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  border: 1px solid var(--card-border);
  border-radius: 34px;
  background: var(--card);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  text-align: center;
}

.game-title {
  display: inline-block;
  margin: 0;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 235, 246, 0.72));
  box-shadow: inset 0 -8px 20px rgba(255, 165, 204, 0.18);
  cursor: text;
  outline: none;
}

.game-title[contenteditable="true"] {
  box-shadow: 0 0 0 3px rgba(255, 135, 193, 0.3), inset 0 -8px 20px rgba(255, 165, 204, 0.18);
}

.title-tip {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 28px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 0 0 1px rgba(255, 200, 221, 0.6);
}

.menu-label {
  font-size: 0.95rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.slider-group {
  min-width: min(100%, 360px);
}

input[type="range"] {
  width: min(240px, 42vw);
  accent-color: #ff73a8;
}

select,
.action-btn,
.icon-close {
  border: none;
  border-radius: 14px;
  font: inherit;
}

select,
.action-btn {
  padding: 10px 14px;
}

select {
  color: var(--text-main);
  background: rgba(255, 247, 252, 0.95);
}

.action-btn {
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #ff91be, #ff6da7);
  box-shadow: 0 12px 22px rgba(255, 121, 176, 0.25);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.action-btn:hover,
.word-card:hover,
.icon-close:hover {
  transform: translateY(-2px);
}

.action-btn:active,
.word-card:active,
.icon-close:active {
  transform: translateY(0);
}

.action-btn.primary {
  background: linear-gradient(135deg, #a56dff, #ff79a8);
}

.sr-only-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.action-btn.ghost {
  background: linear-gradient(135deg, #7ab6ff, #5a8eff);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

.timer-badge,
.wordbook-status {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 211, 228, 0.72);
  font-weight: 700;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(86px, 1fr));
  gap: 14px;
  max-width: 1090px;
  margin: 28px auto 0;
  justify-content: center;
}

.board.is-locked .word-card {
  cursor: not-allowed;
  filter: saturate(0.76);
}

.word-card {
  position: relative;
  min-height: 78px;
  padding: 12px 10px;
  border: none;
  border-radius: 22px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  cursor: pointer;
  box-shadow: 0 16px 24px rgba(126, 86, 144, 0.18);
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.24s ease;
}

.word-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.word-card.is-selected {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 18px 28px rgba(102, 67, 138, 0.26);
}

.word-card.is-wrong {
  background: var(--danger) !important;
  animation: wrongFlash 0.36s ease;
}

.word-card.is-matched {
  animation: vanish 0.6s ease forwards;
  pointer-events: none;
}

.empty-board {
  grid-column: 1 / -1;
  padding: 28px 20px;
  text-align: center;
  border-radius: 24px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 214, 232, 0.65);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(91, 42, 79, 0.35);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(92vw, 460px);
  padding: 28px 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, #fffdfd, #fff0f6);
  box-shadow: 0 30px 60px rgba(146, 86, 129, 0.3);
  text-align: center;
}

.modal-wide {
  width: min(96vw, 920px);
  text-align: left;
}

.modal-card h2 {
  margin: 0 0 12px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.wordbook-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.wordbook-option:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.modal-header,
.mistakes-head,
.mistake-row {
  display: grid;
  grid-template-columns: 90px minmax(140px, 1.1fr) minmax(180px, 2fr) 110px;
  gap: 12px;
  align-items: center;
}

.modal-header {
  margin-bottom: 16px;
}

.modal-header h2 {
  grid-column: 1 / span 3;
}

.icon-close {
  width: 42px;
  height: 42px;
  margin-left: auto;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  background: linear-gradient(135deg, #ff86b5, #ff659d);
}

.mistakes-head {
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 16px;
  color: var(--text-soft);
  font-weight: 700;
  background: rgba(255, 244, 249, 0.95);
}

.mistakes-list {
  max-height: 62vh;
  overflow: auto;
}

.mistake-row {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.mistake-row + .mistake-row {
  margin-top: 8px;
}

.speak-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #7caeff, #5d8cff);
}

.mistake-empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-soft);
}

.version-badge {
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 12;
  padding: 8px 12px;
  border-radius: 999px;
  color: rgba(115, 53, 95, 0.86);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(173, 106, 143, 0.16);
  backdrop-filter: blur(10px);
}

.default-wordbook-btn {
  position: fixed;
  left: 16px;
  bottom: 14px;
  z-index: 12;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #ff9e73, #ff7b9c);
  box-shadow: 0 12px 26px rgba(221, 113, 134, 0.22);
  backdrop-filter: blur(10px);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.default-wordbook-btn:hover {
  transform: translateY(-2px);
}

.default-wordbook-btn:active {
  transform: translateY(0);
}

@keyframes vanish {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.88;
    transform: scale(1.08) rotate(2deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.2) rotate(12deg);
  }
}

@keyframes wrongFlash {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-14px) scale(1.06);
  }
}

@media (max-width: 1080px) {
  .board {
    grid-template-columns: repeat(6, minmax(86px, 1fr));
  }
}

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

  .game-card {
    padding: 24px 14px 30px;
    border-radius: 26px;
  }

  .toolbar {
    justify-content: stretch;
  }

  .menu-item,
  .slider-group {
    width: 100%;
    justify-content: space-between;
  }

  .board {
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    gap: 12px;
  }

  .modal-header,
  .mistakes-head,
  .mistake-row {
    grid-template-columns: 70px 1fr;
  }

  .result-actions {
    flex-direction: column;
  }

  .wordbook-actions {
    grid-template-columns: 1fr;
  }

  .mistakes-head span:nth-child(3),
  .mistakes-head span:nth-child(4),
  .mistake-row .meaning,
  .mistake-row .count {
    grid-column: 2;
  }

  .modal-header h2 {
    grid-column: 1 / 2;
  }
}
