:root {
  --paper: #f4eee1;
  --paper-deep: #ebe1cf;
  --card: #fffaf0;
  --ink: #252b2d;
  --muted: #81796b;
  --line: #ded3c0;
  --line-soft: #ece3d3;
  --accent: #e45d3f;
  --accent-dark: #c94a30;
  --teal: #2f766e;
  --teal-soft: #dcebe5;
  --yellow: #f0c45a;
  --shadow: 0 14px 34px rgba(71, 56, 32, 0.10);
  --shadow-soft: 0 6px 16px rgba(71, 56, 32, 0.07);
  --radius: 20px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  overscroll-behavior: none;
}

body {
  overflow-x: hidden;
  background-image:
    radial-gradient(rgba(109, 92, 63, 0.11) 0.7px, transparent 0.7px),
    radial-gradient(circle at 12% 8%, rgba(240, 196, 90, 0.16), transparent 34%),
    radial-gradient(circle at 92% 92%, rgba(47, 118, 110, 0.10), transparent 38%);
  background-size: 18px 18px, auto, auto;
}

button,
input {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(47, 118, 110, 0.35);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------------- 首页 ---------------- */

.home-screen {
  max-width: 560px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(30px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 2px 26px;
}

.brand-mark {
  position: relative;
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 19px;
  background: var(--ink);
  box-shadow: 5px 5px 0 rgba(228, 93, 63, 0.85);
  transform: rotate(-3deg);
}

.brand-pencil {
  position: absolute;
  left: 17px;
  top: 28px;
  width: 31px;
  height: 8px;
  border-radius: 4px;
  background: var(--card);
  transform: rotate(-42deg);
}

.brand-pencil::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 10px solid var(--yellow);
}

.brand-pencil::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 2px;
  width: 5px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.brand h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 3px;
  line-height: 1.05;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.4px;
}

.home-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.paper-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.home-card {
  padding: 20px 22px 20px;
}

.mode-switch {
  display: none !important;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 9px;
  padding: 4px;
  border-radius: 13px;
  background: var(--paper-deep);
}

.mode-btn {
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.mode-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(71, 56, 32, 0.10);
}

.mode-btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.mode-hint {
  min-height: 32px;
  margin: 0 1px 17px;
  color: #948a78;
  font-size: 10.5px;
  line-height: 1.55;
}

.code-input {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.room-settings {
  margin-top: 16px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  background: #faf4e8;
}

.settings-title {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.settings-grid label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.settings-grid label:last-child {
  grid-column: 1 / -1;
}

.settings-grid select {
  width: 100%;
  padding: 8px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 11px;
}

.settings-grid select:disabled {
  opacity: 0.45;
}

.lobby-settings {
  margin: -7px 0 14px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.text-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: #fffdf7;
  color: var(--ink);
  font-size: 16px;
  padding: 13px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input::placeholder {
  color: #b2a996;
}

.text-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 118, 110, 0.12);
  outline: none;
}

.home-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 13px 16px;
  text-align: left;
  color: var(--ink);
  background: #fffdf8;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.action-card:active {
  transform: scale(0.985);
}

.action-card:hover {
  border-color: #c8bcaa;
  box-shadow: var(--shadow-soft);
}

.action-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.action-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.action-copy strong {
  font-size: 17px;
  letter-spacing: 0.5px;
}

.action-copy small {
  color: var(--muted);
  font-size: 12px;
}

.primary-action {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf7;
}

.primary-action .action-icon {
  background: var(--accent);
  color: #fff;
}

.primary-action .action-copy small {
  color: #c9c3b7;
}

.primary-action:hover {
  border-color: var(--ink);
  box-shadow: 0 8px 20px rgba(37, 43, 45, 0.2);
}

.join-panel {
  margin-top: 14px;
  padding: 15px;
  border-radius: 15px;
  background: #f7f0e3;
  border: 1px dashed #d4c7b2;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row .text-input {
  min-width: 0;
  flex: 1;
  padding: 11px 12px;
  font-size: 14px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  transition: transform 0.12s, opacity 0.15s, background 0.15s;
}

.btn:active {
  transform: scale(0.975);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fffaf4;
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.btn-dark {
  background: var(--ink);
  color: #fffaf4;
}

.btn-dark:not(:disabled):hover {
  background: #394143;
}

.wide {
  width: 100%;
}

.tiny-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(47, 118, 110, 0.1);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  min-width: 0;
  min-height: 88px;
  padding: 14px 8px;
  border-top: 2px solid var(--ink);
  color:var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.steps span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.footnote {
  margin: -2px 0 0;
  text-align: center;
  color: #9b927f;
  font-size: 11px;
}

/* ---------------- 游戏 ---------------- */

.game-screen {
  max-width: 1120px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
}

.game-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 2px 10px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  font-size: 27px;
  line-height: 1;
  padding-bottom: 4px;
  box-shadow: var(--shadow-soft);
}

.icon-btn:active {
  transform: scale(0.94);
}

.room-info {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: baseline;
  gap: 7px;
}

.room-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}

.room-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.conn-state {
  display: flex;
  flex: none;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10.5px;
}

.conn-state span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

.conn-state.offline span {
  background: #b0a48f;
}

.game-main {
  display: grid;
  gap: 14px;
}

.play-column {
  min-width: 0;
}

.play-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 12px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.word-line {
  min-height: 30px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 2px;
  line-height: 1.2;
  word-break: break-all;
}

.word-line .meta {
  margin-left: 8px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  vertical-align: 3px;
}

.word-line .you-draw {
  color: var(--accent);
}

.timer {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-family: "Songti SC", "STSong", serif;
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 3px 3px 0 var(--yellow);
}

.timer.low {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 3px 3px 0 rgba(228, 93, 63, 0.25);
}

.canvas-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  background: #fffdf8;
  overflow: hidden;
}

#board {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #fffdf8;
  touch-action: none;
}

.canvas-wrap.draw-enabled #board {
  cursor: crosshair;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px;
  text-align: center;
  background:
    linear-gradient(rgba(255, 250, 240, 0.93), rgba(255, 250, 240, 0.97)),
    radial-gradient(rgba(109, 92, 63, 0.14) 0.8px, transparent 0.8px);
  background-size: auto, 17px 17px;
  backdrop-filter: blur(2px);
}

.canvas-overlay h2 {
  margin: 0 0 9px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
  letter-spacing: 1.5px;
}

.overlay-copy {
  max-width: 310px;
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.lobby-address {
  margin: -5px 0 15px;
  padding: 7px 12px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.2px;
}

.lobby-address:empty {
  display: none;
}

.lobby-address.is-code {
  padding: 9px 18px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  cursor: pointer;
}

.lobby-players {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  max-width: 330px;
  margin-bottom: 18px;
}

.lobby-player {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.lobby-player.is-host {
  background: var(--teal-soft);
  color: var(--teal);
}

.lobby-overlay .wide {
  max-width: 260px;
}

.overlay-hint {
  margin: 9px 0 0;
  color: #9b927f;
  font-size: 10.5px;
}

.choose-overlay {
  align-items: stretch;
  justify-content: center;
  padding: 18px 24px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(255, 250, 240, 0.96), rgba(255, 250, 240, 0.98)),
    radial-gradient(rgba(109, 92, 63, 0.12) 0.8px, transparent 0.8px);
  background-size: auto, 17px 17px;
}

.choose-overlay .eyebrow,
.choose-overlay h2 {
  text-align: center;
}

.choose-overlay h2 {
  margin-bottom: 5px;
  font-size: 25px;
}

.choose-overlay .overlay-copy {
  margin-bottom: 12px;
}

.choose-form {
  width: min(100%, 330px);
  margin: 0 auto;
  text-align: left;
}

.choose-form .field-label {
  margin-top: 9px;
}

.choose-form .text-input {
  padding: 10px 12px;
  font-size: 15px;
}

.choose-form .btn {
  margin-top: 10px;
  padding: 10px 16px;
}

.btn-quiet {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.choose-wait-overlay {
  background: rgba(255, 250, 240, 0.94);
}

.choose-wait-overlay h2 {
  font-size: 24px;
}

.reveal-overlay {
  background: rgba(37, 43, 45, 0.86);
  color: #fffaf0;
  backdrop-filter: blur(4px);
}

.reveal-overlay .eyebrow {
  color: var(--yellow);
}

.reveal-overlay h2 {
  font-size: 52px;
  letter-spacing: 7px;
  text-shadow: 4px 4px 0 rgba(228, 93, 63, 0.8);
}

.reveal-overlay .overlay-copy {
  color: #ded8cc;
}

.over-overlay {
  justify-content: center;
}

.ranking {
  width: min(100%, 290px);
  margin: 4px 0 20px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.ranking li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.ranking li:last-child {
  border-bottom: 0;
}

.rank-num {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: none;
  border-radius: 50%;
  background: var(--paper);
  font-size: 11px;
  font-weight: 800;
}

.ranking li:first-child .rank-num {
  background: var(--yellow);
}

.rank-name {
  flex: 1;
  font-weight: 700;
}

.rank-score {
  color: var(--accent);
  font-weight: 800;
}

.wait-overlay {
  background: rgba(255, 250, 240, 0.92);
}

.wait-overlay p {
  color: var(--muted);
  font-size: 12px;
}

.wait-doodle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.wait-doodle span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s infinite ease-in-out;
}

.wait-doodle span:nth-child(2) {
  background: var(--yellow);
  animation-delay: 0.15s;
}

.wait-doodle span:nth-child(3) {
  background: var(--teal);
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.5; }
  35% { transform: translateY(-7px); opacity: 1; }
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: #fbf5e9;
}

.tool-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.tool-action {
  min-width: 30px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.tool-action.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--card);
}

.tool-action:active {
  transform: scale(0.95);
}

.palette {
  display: flex;
  gap: 7px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(37, 43, 45, 0.12);
  transition: transform 0.12s;
}

.color-swatch.active {
  border-color: var(--ink);
  transform: scale(1.1);
}

.tool-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.widths {
  display: flex;
  gap: 5px;
  align-items: center;
}

.width-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
}

.width-btn.active {
  border-color: var(--ink);
  background: #fffdf8;
}

.width-dot {
  display: block;
  border-radius: 50%;
  background: var(--ink);
}

.clear-btn {
  margin-left: auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
}

.clear-btn:active {
  background: var(--paper-deep);
}

.draw-hint {
  margin: 0;
  padding: 0 12px 11px;
  background: #fbf5e9;
  color: var(--muted);
  font-size: 10.5px;
}

.side-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 9px;
}

.panel-head h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 1px;
}

.panel-head span {
  color: var(--muted);
  font-size: 10px;
}

.players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0 12px 12px;
  list-style: none;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--paper);
  font-size: 11px;
}

.player-chip .avatar {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--ink);
  font-size: 9px;
  font-weight: 800;
}

.player-chip .p-name {
  overflow: hidden;
  max-width: 80px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-chip .p-score {
  color: var(--accent);
  font-weight: 800;
}

.player-chip.is-drawer {
  background: var(--ink);
  color: #fffaf0;
}

.player-chip.is-drawer .avatar {
  background: var(--yellow);
  color: var(--ink);
}

.player-chip.is-drawer .p-score {
  color: var(--yellow);
}

.player-chip.is-correct {
  background: var(--teal-soft);
}

.player-chip.is-drawer.is-correct {
  background: var(--ink);
}

.correct-check {
  color: var(--teal);
  font-size: 10px;
  font-weight: 900;
}

.player-chip.is-drawer .correct-check {
  color: var(--yellow);
}

.player-chip.is-me .p-name::after {
  content: " ·你";
  color: var(--muted);
  font-size: 8px;
}

.player-chip.is-drawer.is-me .p-name::after {
  color: #d8d2c5;
}

.host-star {
  color: var(--yellow);
  font-size: 9px;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 250px;
}

.chat-tabs {
  display: flex;
  gap: 4px;
  margin: 0 12px 7px;
  padding: 3px;
  border-radius: 9px;
  background: var(--paper);
}

.chat-tab {
  flex: 1;
  min-height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.chat-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(71, 56, 32, 0.08);
}

.chat-tab:disabled {
  opacity: 0.4;
}

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  padding: 2px 13px 10px;
  scrollbar-width: thin;
}

.chat-empty {
  margin: auto;
  padding: 10px;
  color: #a99f8c;
  font-size: 10.5px;
  line-height: 1.7;
  text-align: center;
}

.chat-line {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 11.5px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-line .who {
  flex: none;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.chat-line.mine .who {
  color: var(--teal);
}

.chat-line.correct {
  color: var(--teal);
  font-weight: 700;
}

.chat-line.system {
  justify-content: center;
  color: #9b927f;
  font-size: 10px;
  text-align: center;
}

.chat-line.system .who {
  display: none;
}

.guess-form {
  display: flex;
  gap: 7px;
  padding: 9px;
  border-top: 1px solid var(--line-soft);
  background: #fbf5e9;
}

.guess-input {
  min-width: 0;
  flex: 1;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 13px;
}

.guess-input:focus {
  border-color: var(--teal);
  outline: none;
}

.guess-input:disabled {
  opacity: 0.5;
}

.guess-btn {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf0;
  font-size: 12px;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s, transform 0.18s;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(37, 43, 45, 0.42);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(100%, 340px);
  padding: 26px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 10px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 26px;
}

.modal-card p:not(.eyebrow) {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------------- 桌面布局 ---------------- */

@media (min-width: 860px) {
  .home-screen {
    padding-top: 8vh;
  }

  .game-screen {
    padding-top: 18px;
  }

  .game-main {
    grid-template-columns: minmax(0, 1fr) 310px;
    align-items: start;
    gap: 18px;
  }

  .canvas-wrap {
    padding-bottom: 84.7%;
  }

  .side-column {
    height: 100%;
  }

  .chat-panel {
    height: 300px;
  }

  .word-line {
    font-size: 29px;
  }
}

@media (min-width: 1100px) {
  .canvas-wrap {
    padding-bottom: 75.7%;
  }
}

@media (max-width: 360px) {
  .home-card {
    padding: 20px 16px 17px;
  }

  .brand h1 {
    font-size: 35px;
  }

  .word-line {
    font-size: 22px;
  }

  .tool-divider {
    display: none;
  }

  .color-swatch {
    width: 23px;
    height: 23px;
  }

  .width-btn {
    width: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------- 调色轮盘 ---------------- */

.wheel-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  z-index: 9;
  width: 26px;
  height: 54px;
  padding: 0;
  border: 1px solid rgba(37, 43, 45, 0.18);
  border-radius: 14px 0 0 14px;
  background: rgba(255, 250, 240, 0.94);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  box-shadow: -3px 0 10px rgba(71, 56, 32, 0.10);
  transform: translateY(-50%);
}

.color-wheel {
  position: absolute;
  right: 0;
  top: 50%;
  z-index: 8;
  width: 58px;
  height: 292px;
  padding: 10px 7px 10px 15px;
  border: 1px solid rgba(37, 43, 45, 0.14);
  border-right: 0;
  border-radius: 146px 0 0 146px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: -8px 8px 22px rgba(71, 56, 32, 0.14);
  transform: translateY(-50%);
}

.wheel-scroll {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

.wheel-scroll::-webkit-scrollbar {
  display: none;
}

.wheel-color {
  width: 23px;
  height: 23px;
  flex: none;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--wheel-color);
  box-shadow: inset 0 0 0 1px rgba(37, 43, 45, 0.12);
}

.wheel-color.active {
  border-color: var(--ink);
  transform: scale(1.08);
}

/* ---------------- 横屏自适应 ---------------- */

@media (orientation: landscape) and (max-height: 620px) {
  .game-screen {
    max-width: none;
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .game-header {
    height: 42px;
    padding-bottom: 5px;
  }

  .game-main {
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 10px;
    align-items: start;
  }

  .play-head {
    padding: 2px 2px 6px;
  }

  .word-line {
    min-height: 24px;
    font-size: 20px;
    letter-spacing: 1px;
  }

  .eyebrow {
    margin-bottom: 2px;
  }

  .timer {
    width: 42px;
    height: 42px;
    font-size: 19px;
    box-shadow: 2px 2px 0 var(--yellow);
  }

  .canvas-wrap {
    width: auto;
    height: calc(100dvh - 122px);
    max-width: 100%;
    margin: 0 auto;
    padding-bottom: 0;
    aspect-ratio: 1 / 1;
  }

  .canvas-card {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
  }

  .side-column {
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
  }

  .chat-panel {
    height: 230px;
  }

  .tools {
    padding: 7px 9px;
    gap: 6px;
  }

  .color-swatch {
    width: 22px;
    height: 22px;
  }

  .width-btn {
    width: 24px;
    height: 24px;
  }

  .draw-hint {
    display: none;
  }

  .home-screen {
    max-width: 760px;
    padding-top: 12px;
  }

  .home-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }

  .steps {
    grid-template-columns: 1fr;
  }
}
