/* ============================================================================
   芙一把 — 样式系统
   暗色原神主题 · 移动优先
   ============================================================================ */

:root {
  --bg: #090d14;
  --bg-card: #191f30;
  --bg-input: #202a3f;
  --bg-hover: #243048;
  --text: #f2efe8;
  --text-dim: #9aadc2;
  --text-bright: #ffffff;
  --gold: #c9a96e;
  --gold-light: #e8d5a3;
  --gold-glow: rgba(201, 169, 110, 0.25);
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.16);
  --green-border: rgba(74, 222, 128, 0.45);
  --yellow: #facc15;
  --yellow-bg: rgba(250, 204, 21, 0.16);
  --yellow-border: rgba(250, 204, 21, 0.45);
  --black-fb: #5e7188;
  --black-bg: rgba(71, 85, 105, 0.22);
  --black-border: rgba(71, 85, 105, 0.4);
  --aid-glow: rgba(168, 85, 247, 0.15);
  --border: #304058;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --transition: 0.18s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 21px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 15px 12px;
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   开始页
   ============================================================================ */

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 85vh;
  text-align: center;
  gap: 24px;
}

.logo-area { margin-bottom: 8px; }

.game-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.game-title {
  font-size: 35px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 50%, #b8955e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 4px;
}

.game-subtitle {
  color: var(--text-dim);
  font-size: 19px;
  margin-top: 6px;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 300px;
}

.mode-btn {
  padding: 20px 34px;
  border-radius: var(--radius);
  font-size: 23px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: all var(--transition);
  position: relative;
  font-family: var(--font);
}

.mode-btn:hover:not(.disabled) {
  background: var(--bg-hover);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.mode-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-btn .soon {
  font-size: 15px;
  color: var(--gold);
  margin-left: 8px;
  font-weight: 400;
}

.difficulty-select {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.difficulty-select h3 {
  font-size: 19px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.diff-btn {
  padding: 17px 29px;
  border-radius: var(--radius);
  font-size: 22px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: all var(--transition);
  font-family: var(--font);
}

.diff-btn:hover {
  background: var(--bg-hover);
  border-color: var(--gold-light);
  transform: translateY(-1px);
}

/* ============================================================================
   游戏页
   ============================================================================ */

.game-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

/* 猜测表格 */
.guess-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
}

.game-header .round-info {
  font-size: 19px;
  color: var(--text-dim);
}

.game-header .score {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold-light);
}

.guess-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 3px;
}

.guess-table th {
  font-size: 15px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 5px 5px;
  text-align: center;
  white-space: nowrap;
}

.guess-table th:first-child {
  text-align: left;
  padding-left: 6px;
  min-width: 60px;
}

.guess-table td {
  padding: 8px 5px;
  text-align: center;
  font-size: 17px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.guess-table td:first-child {
  text-align: left;
  font-weight: 600;
  padding-left: 6px;
  color: var(--text-bright);
}

.guess-table td.green {
  background: var(--green-bg);
  border: 2px solid var(--green-border);
  color: var(--green);
}

.guess-table td.yellow {
  background: var(--yellow-bg);
  border: 2px solid var(--yellow-border);
  color: var(--yellow);
}

.guess-table td.black {
  background: var(--black-bg);
  border: 2px solid var(--black-border);
  color: var(--black-fb);
}

.guess-table td.set-cell {
  font-size: 15px;
  min-width: 70px;
}

.guess-table tr.aid-row td {
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.3);
}

.guess-table tr.correct-row td {
  box-shadow: 0 0 0 2px var(--gold), 0 0 16px var(--gold-glow);
  animation: pulse 0.6s ease-out;
}

.guess-table tr.reveal-row td {
  box-shadow: inset 0 0 0 2px var(--gold);
  background: rgba(201, 169, 110, 0.06);
}

@keyframes pulse {
  0% { transform: scale(1.01); }
  100% { transform: scale(1); }
}

/* 设置列特殊显示——显示交集/非交集 */
.set-match { color: var(--green); font-weight: 600; }
.set-nomatch { color: var(--black-fb); }

/* 输入区 */
.input-area {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  margin-top: auto;
  padding: 12px 0 20px;
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  gap: 8px;
  position: relative;
}

.guess-input {
  flex: 1;
  padding: 15px 17px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-bright);
  font-size: 22px;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
}

.guess-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.guess-input::placeholder {
  color: var(--text-dim);
}

.btn-guess {
  padding: 17px 29px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, var(--gold), #b8955e);
  color: #0f1720;
  font-weight: 700;
  font-size: 23px;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font);
  transition: all var(--transition);
}

.btn-guess:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn-guess:active {
  transform: translateY(0);
}

/* 自动补全 */
.suggestions {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 88px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.suggestion-item {
  padding: 12px 17px;
  cursor: pointer;
  font-size: 19px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition);
}

.suggestion-item:last-child { border-bottom: none; }

.suggestion-item:hover {
  background: var(--bg-hover);
}

.suggestion-item .sub {
  font-size: 17px;
  color: var(--text-dim);
}

.suggestion-item.already-guessed {
  opacity: 0.4;
}

.suggestion-item.already-guessed::after {
  content: "已猜过";
  font-size: 15px;
  color: var(--text-dim);
}

/* ============================================================================
   结果页
   ============================================================================ */

.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 25px;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.result-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 34px 29px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.result-card .result-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.result-card .result-title {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 4px;
}

.result-card .result-target {
  color: var(--gold-light);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

.result-card .result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
}

.result-stat {
  text-align: center;
}

.result-stat .value {
  font-size: 30px;
  font-weight: 800;
  color: var(--gold-light);
}

.result-stat .label {
  font-size: 17px;
  color: var(--text-dim);
  margin-top: 2px;
}

.result-card .result-guesses {
  text-align: left;
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 18px;
}

.result-guess-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.result-guess-row .correct-mark {
  color: var(--green);
  font-weight: 700;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-btn {
  flex: 1;
  padding: 17px 25px;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.result-btn.primary {
  background: linear-gradient(135deg, var(--gold), #b8955e);
  color: #0f1720;
  border: none;
}

.result-btn.secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.result-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* ============================================================================
   提示消息
   ============================================================================ */

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 25px;
  border-radius: var(--radius);
  font-size: 19px;
  border: 1px solid var(--border);
  z-index: 200;
  animation: slideDown 0.3s ease, fadeOut 0.3s ease 2s forwards;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; pointer-events: none; }
}

/* ============================================================================
   辅助按钮
   ============================================================================ */

.help-details {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  background: var(--bg-card);
}

.help-details summary {
  cursor: pointer;
  color: var(--gold-light);
  font-weight: 700;
  font-size: 19px;
  user-select: none;
}

.help-details[open] summary {
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.help-content p {
  margin: 5px 0;
  line-height: 1.6;
}

.help-content b {
  color: var(--text-bright);
  min-width: 48px;
  display: inline-block;
}

.help-content .rule {
  color: #e2d08b;
}

.help-content .rule-sub {
  display: inline-block;
  color: var(--text-dim);
  font-size: 15px;
  padding-left: 52px;
}

.aid-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--font);
  transition: all var(--transition);
}

.aid-toggle:hover {
  border-color: var(--gold);
}

.aid-toggle.active {
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.08);
}

/* ============================================================================
   滚动条
   ============================================================================ */

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ============================================================================
   响应式
   ============================================================================ */

@media (min-width: 540px) {
  .guess-table-wrapper {
    margin: 0;
    padding: 0;
  }
}

@media (max-width: 380px) {
  .game-title { font-size: 35px; }
  .guess-input { font-size: 19px; padding: 12px 15px; }
  .btn-guess { font-size: 19px; padding: 12px 20px; }
  .guess-table th { font-size: 15px; }
  .guess-table td { font-size: 17px; padding: 8px 3px; }
}

.target-attrs {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin: 16px 0;
  text-align: left;
  border: 2px solid var(--gold);
}
.target-attrs h4 {
  color: var(--gold-light);
  margin-bottom: 14px;
  font-size: 25px;
  text-align: center;
}
.target-attr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 19px;
  border-bottom: 1px solid var(--border);
}
.target-attr-row:last-child { border-bottom: none; }
.target-attr-row b { color: var(--text-bright); min-width: 100px; font-size: 19px; }
.target-attr-row span { color: var(--text); font-size: 19px; }

.result-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================================
   查角色页
   ============================================================================ */

.lookup-screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 85vh;
  padding-top: 20px;
}

.lookup-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lookup-header h2 {
  font-size: 24px;
  color: var(--text-bright);
  font-weight: 700;
}

.lookup-back {
  padding: 10px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 19px;
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.lookup-back:hover {
  border-color: var(--gold);
  background: var(--bg-hover);
}

.lookup-search {
  display: flex;
  gap: 8px;
}

.lookup-input {
  flex: 1;
  padding: 15px 17px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-bright);
  font-size: 21px;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
}

.lookup-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.lookup-input::placeholder {
  color: var(--text-dim);
}

.lookup-btn {
  padding: 15px 25px;
  font-size: 21px;
}

.lookup-suggestions-area {
  position: relative;
}

.lookup-suggestions {
  position: static;
  right: auto;
}

.lookup-hint {
  text-align: center;
  padding: 52px 25px;
  color: var(--text-dim);
  font-size: 18px;
}

.lookup-hint-sub {
  font-size: 15px;
  margin-top: 8px;
  color: #5e7188;
}

.lookup-error {
  text-align: center;
  padding: 34px 25px;
  color: #f87171;
  font-size: 20px;
}

.lookup-result-area .target-attrs h4 {
  font-size: 28px;
}