@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(24px) scale(0.96);
  }
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.site-header,
.game-section,
.toolbox-section,
.community-section {
  width: min(1180px, calc(100vw - 24px));
  margin: 0 auto;
}

.site-header {
  padding-top: 24px;
}

.site-section {
  display: none;
}

.site-section.active {
  display: block;
}

.game-section {
  padding: 12px 0 40px;
}

.toolbox-section,
.community-section {
  padding: 12px 0 40px;
}

.module-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(75, 141, 185, 0.13);
  border-radius: var(--radius-lg);
  background: rgba(251, 253, 255, 0.92);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.module-brand,
.module-current {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.module-brand {
  background: var(--brand-dark);
  color: #fff;
}

.module-current {
  margin-left: 6px;
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}

.module-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.module-nav span,
.module-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.module-nav .active {
  border-color: #cce2dc;
  background: #edf7f4;
  color: var(--brand-dark);
}

.section-head {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.section-head,
.game-shell {
  background: var(--surface);
  border: 1px solid rgba(75, 141, 185, 0.13);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.section-head {
  padding: 20px;
}

.section-kicker {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(24px, 3vw, 34px);
}

.section-copy,
.panel-head p,
.muted,
.game-tab small {
  color: var(--muted);
}

.section-copy {
  max-width: 700px;
  margin-bottom: 14px;
  line-height: 1.7;
}

.feature-strip,
.next-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-strip span,
.next-tags span {
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f3efe5;
  border: 1px solid #e6dccb;
  color: #68451f;
  font-size: 12px;
  font-weight: 900;
}

.connection-box {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.connection-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.room-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.room-actions button {
  padding: 8px 11px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.bot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.bot-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.game-section.compact-mode {
  width: min(100vw - 8px, 760px);
  padding: 6px 0 10px;
}

.game-section.compact-mode .module-bar,
.game-section.compact-mode .feature-strip,
.game-section.compact-mode .room-help,
.game-section.compact-mode .game-overview,
.game-section.compact-mode .info-grid {
  display: none;
}

.game-section.compact-mode .section-head {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.game-section.compact-mode .section-kicker,
.game-section.compact-mode .section-copy,
.game-section.compact-mode .panel-head p,
.game-section.compact-mode .game-tab small {
  display: none;
}

.game-section.compact-mode h1 {
  margin: 0;
  font-size: 22px;
}

.game-section.compact-mode h2 {
  margin: 0;
  font-size: 20px;
}

.game-section.compact-mode .connection-box,
.game-section.compact-mode .game-stage {
  padding: 8px;
}

.game-section.compact-mode .connection-row {
  grid-template-columns: 1fr 1fr auto;
}

.game-section.compact-mode .game-shell {
  grid-template-columns: 1fr;
  min-height: auto;
}

.game-section.compact-mode .game-menu {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px;
}

.game-section.compact-mode .game-tab {
  flex: 0 0 86px;
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
  padding: 8px 6px;
  scroll-snap-align: start;
}

.game-section.compact-mode .game-icon {
  width: 30px;
  height: 30px;
}

.game-section.compact-mode .panel-head {
  align-items: center;
  margin-bottom: 8px;
}

.game-section.compact-mode .status-pill {
  min-height: 28px;
  max-width: 52vw;
  padding: 5px 9px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.game-section.compact-mode .wood {
  padding: 6px;
}

.game-section.compact-mode #gomoku-board {
  width: min(100%, max(260px, calc(100svh - 245px)), 600px);
}

.game-section.compact-mode #draw-board {
  width: min(100%, max(300px, calc((100svh - 285px) * 1.65)), 760px);
}

.game-section.compact-mode .inline-tools,
.game-section.compact-mode .score-strip,
.game-section.compact-mode .guess-box {
  gap: 6px;
  margin: 6px 0;
  padding: 7px;
}

.game-section.compact-mode .inline-tools button,
.game-section.compact-mode .choice,
.game-section.compact-mode .ddz-actions button,
.game-section.compact-mode .chat-input-row button {
  padding: 8px 10px;
  font-size: 13px;
}

.game-section.compact-mode .ddz-players {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.game-section.compact-mode .player-card {
  min-height: 58px;
  padding: 7px;
  font-size: 12px;
}

.game-section.compact-mode .ddz-center {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.game-section.compact-mode #ddz-multiplier {
  grid-column: 1 / -1;
  justify-self: start;
}

.game-section.compact-mode .card-row {
  gap: 4px;
  min-height: 42px;
}

.game-section.compact-mode .card {
  width: 34px;
  height: 48px;
  border-radius: 7px;
  font-size: 12px;
}

.game-section.compact-mode .compact .card {
  width: 30px;
  height: 42px;
  font-size: 11px;
}

.game-section.compact-mode .hand {
  max-height: 168px;
  overflow: auto;
  padding: 8px;
}

.game-section.compact-mode .history {
  max-height: 54px;
  overflow: auto;
  margin-top: 6px;
  font-size: 12px;
}

.game-section.compact-mode .chat-panel {
  margin-top: 8px;
  padding-top: 8px;
}

.game-section.compact-mode .chat-log {
  height: 58px;
  font-size: 12px;
}

.game-section.compact-mode .ddz-actions,
.game-section.compact-mode .uno-actions,
.game-section.compact-mode .mj-actions,
.game-section.compact-mode .inline-tools,
.game-section.compact-mode .guess-box {
  position: sticky;
  bottom: 0;
  z-index: 7;
  border: 1px solid rgba(222, 219, 210, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 108, 95, 0.12);
}

.connection-status {
  min-height: 20px;
  margin: 0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

.room-help {
  display: grid;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.room-help strong {
  color: var(--brand-dark);
  font-size: 13px;
}

.game-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.game-overview div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(32, 33, 36, 0.06);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.game-overview div:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(32, 33, 36, 0.1);
}

.game-overview strong,
.game-overview span {
  display: block;
}

.game-overview strong {
  margin-bottom: 4px;
  color: var(--brand-dark);
  font-size: 20px;
}

.game-overview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.primary,
.chat-input-row button,
.game-tab.active {
  background: var(--brand);
  color: #fff;
}

.primary,
.choice,
.inline-tools button,
.ddz-actions button,
.chat-input-row button,
.game-tab {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
}

.danger {
  background: var(--danger) !important;
  color: #fff !important;
}

.game-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: min(760px, calc(100svh - 160px));
  overflow: hidden;
}

.game-menu {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  background: #f0eee7;
  border-right: 1px solid var(--line);
}

.game-tab {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
}

.game-tab:not(.active):hover {
  background: rgba(20, 108, 95, 0.08);
}

.game-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line);
  font-weight: 900;
}

.game-tab.active .game-icon {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
}

.game-tab strong,
.game-tab small {
  display: block;
}

.game-tab strong {
  margin-bottom: 2px;
}

.game-stage {
  min-width: 0;
  padding: 16px;
}

.game-panel {
  display: none;
}

.game-panel.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p {
  margin-bottom: 0;
  line-height: 1.6;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #edf7f4;
  border: 1px solid #cce2dc;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.board-frame {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.board-frame canvas {
  display: block;
  width: 100%;
  max-width: 760px;
  touch-action: none;
}

.wood {
  padding: 12px;
  background:
    linear-gradient(90deg, rgba(86, 52, 22, 0.08) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(#dba65f, #c98739);
}

.paper {
  padding: 10px;
  background: #fff;
}

.inline-tools,
.score-strip,
.guess-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.score-strip {
  justify-content: space-between;
}

.choice,
.inline-tools button,
.ddz-actions button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand-dark);
}

.hidden {
  display: none !important;
}

.ddz-table {
  display: grid;
  gap: 12px;
}

.ddz-players {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.player-card {
  min-height: 94px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.player-card.active {
  outline: 3px solid rgba(20, 108, 95, 0.16);
}

.player-card strong {
  display: block;
  margin-bottom: 6px;
}

.ddz-center {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #edf4ef;
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 54px;
  align-items: center;
}

.card {
  display: grid;
  place-items: center;
  width: 50px;
  height: 70px;
  border: 1px solid rgba(32, 33, 36, 0.2);
  border-radius: 10px;
  background: linear-gradient(160deg, #fff, #f6f1e8);
  box-shadow: 0 8px 18px rgba(32, 33, 36, 0.1);
  font-weight: 900;
  user-select: none;
}

.card.red {
  color: var(--danger);
}

.compact .card {
  width: 42px;
  height: 56px;
  font-size: 13px;
}

.hand {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.hand .card {
  cursor: pointer;
}

.hand .card.selected {
  transform: translateY(-14px);
  background: linear-gradient(160deg, #fff8d7, #e6bd4a);
  border-color: var(--accent);
}

.ddz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.chat-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.chat-log {
  height: 132px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  line-height: 1.7;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 12px;
  margin-top: 16px;
}

.info-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(32, 33, 36, 0.06);
}

.info-panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.info-panel ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.info-panel p {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.toolbox-head,
.community-head {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbox-note,
.community-note {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.toolbox-note strong,
.community-note strong {
  color: var(--brand-dark);
  font-size: 18px;
}

.toolbox-note span,
.community-note span {
  color: var(--muted);
  line-height: 1.5;
}

.tool-grid,
.community-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tool-card,
.community-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(32, 33, 36, 0.06);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.tool-card:hover,
.community-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(32, 33, 36, 0.1);
}

.community-grid {
  grid-template-columns: 1.1fr 1fr 1.1fr;
}

.novel-tool {
  grid-column: 1 / -1;
}

.ai-image-tool {
  grid-column: 1 / -1;
}

.ai-section {
  margin: 22px auto 56px;
}

.ai-studio-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 178px;
  padding: clamp(24px, 4vw, 46px);
  overflow: hidden;
  border: 1px solid rgba(126, 119, 101, 0.2);
  border-radius: 26px;
  background: radial-gradient(circle at 84% 12%, rgba(239, 189, 105, 0.33), transparent 13rem), linear-gradient(140deg, #173f35, #285b4c);
  color: #fff;
  box-shadow: var(--shadow-card);
}

.ai-studio-head::after { content: "KB"; position: absolute; left: 46%; top: -42px; color: rgba(255, 255, 255, 0.038); font-size: 190px; font-weight: 1000; line-height: 1; transform: rotate(-6deg); }
.ai-studio-head > * { position: relative; z-index: 1; }
.ai-studio-head > div:first-child { grid-row: 1 / 3; }
.ai-studio-head h1 { margin: 0; font-size: clamp(34px, 5vw, 54px); letter-spacing: -0.05em; }
.ai-studio-head p:not(.section-kicker) { max-width: 620px; margin: 10px 0 0; color: rgba(255, 255, 255, 0.72); line-height: 1.7; }
.ai-creative-route { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.ai-creative-route span { display: grid; width: 50px; gap: 1px; justify-items: center; }
.ai-creative-route b { display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid rgba(255,255,255,.7); border-radius: 45% 55% 48% 52%; background: var(--accent); color: #423015; font-size: 15px; transform: rotate(-3deg); }
.ai-creative-route span:nth-of-type(2) b { border-radius: 55% 45% 58% 42%; background: #f4f0e6; color: var(--brand-dark); transform: rotate(3deg); }
.ai-creative-route span:nth-of-type(3) b { border-radius: 48% 52% 42% 58%; background: #79b5cf; color: #14334a; transform: rotate(-2deg); }
.ai-creative-route small { color: rgba(255,255,255,.68); font-size: 8px; font-weight: 800; }
.ai-creative-route i { width: 24px; height: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.58) 0 5px, transparent 5px 9px); }
.ai-studio-badge { display: grid; min-width: 175px; gap: 4px; padding: 13px 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; background: rgba(255,255,255,.08); }
.ai-studio-badge strong { color: #fff; }
.ai-studio-badge span { color: rgba(255,255,255,.6); font-size: 10px; }
.ai-studio-key { margin: 12px 0; background: rgba(255, 253, 248, 0.92); box-shadow: var(--shadow-sm); }
.ai-mode-tabs { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 7px; margin-bottom: 10px; padding: 6px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.ai-mode-tabs button { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 58px; gap: 1px 10px; align-content: center; padding: 8px 13px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; }
.ai-mode-tabs button > span { display: grid; grid-row: 1 / 3; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: rgba(52,116,95,.08); color: var(--brand-dark); font-weight: 1000; }
.ai-mode-tabs button strong { align-self: end; color: inherit; font-size: 12px; }
.ai-mode-tabs button small { align-self: start; font-size: 9px; }
.ai-mode-tabs button.active { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow-sm); }
.ai-mode-tabs button.active > span { background: var(--accent); color: #463419; transform: rotate(-3deg); }
.ai-mode-panel[hidden] { display: none; }
.ai-section .ai-image-tool { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.ai-section .ai-image-tool > .agnes-key-panel { display: none; }

.ai-chat-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 650px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-card); }
.ai-chat-side { display: flex; flex-direction: column; gap: 14px; padding: 14px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.ai-chat-side > button { min-height: 42px; border: 1px solid rgba(52, 116, 95, 0.28); border-radius: 11px; background: var(--surface); color: var(--brand-dark); font-weight: 900; }
.ai-chat-side > div { display: grid; gap: 3px; padding: 10px; border-radius: 10px; background: rgba(52,116,95,.08); }
.ai-chat-side strong { overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.ai-chat-side span,
.ai-chat-side p { color: var(--muted); font-size: 9px; line-height: 1.55; }
.ai-chat-side p { margin: auto 2px 0; }
.ai-chat-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
.ai-chat-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ai-chat-top > div { display: grid; gap: 2px; }
.ai-chat-top strong { color: var(--brand-dark); font-size: 14px; }
.ai-chat-top span { color: var(--muted); font-size: 9px; }
.ai-chat-top button { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.ai-chat-messages { display: flex; min-height: 0; max-height: 550px; flex-direction: column; gap: 18px; overflow-y: auto; padding: clamp(18px, 4vw, 42px); }
.ai-chat-welcome { display: grid; margin: auto; justify-items: center; text-align: center; }
.ai-chat-welcome > span { display: grid; width: 52px; height: 52px; margin-bottom: 12px; place-items: center; border-radius: 16px; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; font-weight: 1000; box-shadow: var(--shadow-md); }
.ai-chat-welcome h2 { margin: 0; color: var(--ink); font-size: 24px; }
.ai-chat-welcome p { margin: 7px 0 16px; color: var(--muted); font-size: 11px; }
.ai-chat-welcome > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.ai-chat-welcome button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--brand-dark); font-size: 10px; }
.ai-chat-message { display: flex; max-width: min(82%, 760px); gap: 9px; align-items: flex-start; }
.ai-chat-message.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-chat-avatar { display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--brand-dark); color: #fff; font-size: 10px; font-weight: 1000; }
.ai-chat-message.user .ai-chat-avatar { background: var(--accent); color: #4a3415; }
.ai-chat-message.notice .ai-chat-avatar { background: var(--danger); }
.ai-chat-message > div { min-width: 0; }
.ai-chat-message p { margin: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 4px 14px 14px; background: var(--surface-soft); color: var(--ink); font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.ai-chat-message.user p { border: 0; border-radius: 14px 4px 14px 14px; background: var(--brand-dark); color: #fff; }
.ai-chat-message.notice p { color: var(--danger); }
.ai-chat-message > div > button { margin-top: 5px; padding: 3px 6px; border: 0; background: transparent; color: var(--muted); font-size: 9px; }
.ai-chat-composer { margin: 0 16px 16px; padding: 10px; border: 1px solid rgba(52,116,95,.28); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 24px rgba(42,52,44,.08); }
.ai-chat-composer textarea { width: 100%; min-height: 72px; padding: 5px; border: 0; background: transparent; box-shadow: none; resize: none; }
.ai-chat-composer textarea:focus { outline: 0; }
.ai-chat-composer > div { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.ai-chat-composer span { margin-right: auto; color: var(--muted); font-size: 9px; }
.ai-chat-composer button { min-height: 34px; padding: 6px 13px; border: 0; border-radius: 9px; background: var(--brand-dark); color: #fff; font-weight: 900; }
.ai-chat-composer #ai-chat-stop { border: 1px solid var(--line); background: var(--surface-soft); color: var(--danger); }

.ai-video-shell { display: grid; grid-template-columns: minmax(320px, .88fr) minmax(390px, 1.12fr); gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-card); }
.ai-video-editor { display: grid; align-content: start; gap: 12px; min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.ai-video-heading { display: flex; align-items: center; gap: 10px; }
.ai-video-heading > span { display: grid; width: 42px; height: 42px; flex: none; place-items: center; border: 2px solid rgba(37,91,124,.18); border-radius: 48% 52% 43% 57%; background: #79b5cf; color: #15374c; font-size: 16px; font-weight: 1000; transform: rotate(-3deg); }
.ai-video-heading > div { display: grid; gap: 2px; }
.ai-video-heading strong { color: var(--brand-dark); font-size: 16px; }
.ai-video-heading small { color: var(--muted); font-size: 9px; }
.ai-video-editor label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 800; }
.ai-video-editor textarea { resize: vertical; }
.ai-video-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ai-video-options select { width: 100%; min-width: 0; }
.ai-video-reference-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.ai-video-reference-actions button { min-height: 34px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--brand-dark); font-size: 10px; font-weight: 800; }
.ai-video-reference-actions span { color: var(--muted); font-size: 9px; }
.ai-video-advanced { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ai-video-advanced summary { color: var(--brand-dark); font-size: 10px; font-weight: 800; cursor: pointer; }
.ai-video-advanced textarea { width: 100%; margin-top: 8px; }
.ai-video-generate { min-height: 46px; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--brand-dark), #3d7c91); color: #fff; font-weight: 1000; box-shadow: var(--shadow-sm); }
.ai-video-generate:disabled { cursor: wait; opacity: .65; }
.ai-video-progress { display: grid; gap: 6px; }
.ai-video-progress > div { height: 6px; overflow: hidden; border-radius: 99px; background: rgba(52,116,95,.12); }
.ai-video-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #79b5cf); transition: width var(--transition-normal); }
.ai-video-progress span { min-height: 16px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.ai-video-output { position: relative; display: grid; min-width: 0; min-height: 540px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(150deg, #183f35, #245b4c 58%, #17384b); }
.ai-video-output [hidden] { display: none !important; }
.ai-video-empty { display: grid; max-width: 320px; justify-items: center; gap: 7px; padding: 30px; color: rgba(255,255,255,.66); text-align: center; }
.ai-video-empty strong { color: #fff; font-size: 20px; }
.ai-video-empty span { font-size: 10px; line-height: 1.65; }
.ai-video-film { display: flex; gap: 5px; padding: 8px; border: 2px solid rgba(255,255,255,.5); border-radius: 10px; transform: rotate(-2deg); }
.ai-video-film i { width: 30px; height: 42px; border-radius: 4px; background: linear-gradient(145deg, var(--accent), #d78245); }
.ai-video-film i:nth-child(2) { background: linear-gradient(145deg, #f5f0e6, #9bc3cf); }
.ai-video-film i:nth-child(3) { background: linear-gradient(145deg, #79b5cf, #375d85); }
.ai-video-output video { display: block; width: 100%; max-height: 600px; background: #0d1517; }
.ai-video-meta { position: absolute; left: 12px; top: 12px; padding: 7px 9px; border-radius: 9px; background: rgba(10,25,26,.74); color: rgba(255,255,255,.82); font-size: 9px; backdrop-filter: blur(8px); }
.ai-video-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 7px; padding: 7px; border-radius: 11px; background: rgba(255,255,255,.9); box-shadow: var(--shadow-sm); backdrop-filter: blur(8px); }
.ai-video-actions button { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-dark); font-weight: 800; }
.ai-video-actions #ai-video-stop { color: var(--danger); }

@media (max-width: 760px) {
  .ai-studio-head { grid-template-columns: 1fr; align-items: flex-start; }
  .ai-studio-head > div:first-child { grid-row: auto; }
  .ai-creative-route { justify-content: flex-start; }
  .ai-studio-badge { min-width: 0; }
  .ai-mode-tabs { display: grid; }
  .ai-chat-shell { grid-template-columns: 1fr; min-height: 600px; }
  .ai-chat-side { display: grid; grid-template-columns: auto minmax(0, 1fr); border-right: 0; border-bottom: 1px solid var(--line); }
  .ai-chat-side p { display: none; }
  .ai-chat-messages { max-height: 470px; padding: 16px 10px; }
  .ai-chat-message { max-width: 94%; }
  .ai-chat-composer { margin: 0 8px 8px; }
  .ai-video-shell { grid-template-columns: 1fr; padding: 10px; }
  .ai-video-output { min-height: 420px; }
}

@media (max-width: 560px) {
  .ai-mode-tabs { grid-template-columns: 1fr; }
  .ai-video-options { grid-template-columns: 1fr; }
  .ai-video-output { min-height: 340px; }
}

.agnes-key-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(300px, 1.3fr);
  gap: 8px 14px;
  align-items: center;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.agnes-key-panel > div:first-child { display: grid; gap: 3px; }
.agnes-key-panel strong { color: var(--brand-dark); font-size: 14px; }
.agnes-key-panel span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.agnes-key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px; }
.agnes-key-row input { min-width: 0; }
.agnes-key-row button { min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--brand-dark); font-weight: 800; }
.agnes-key-status { grid-column: 2; }
.agnes-key-status[data-state="ok"] { color: var(--brand-dark); font-weight: 800; }
.agnes-key-status[data-state="error"] { color: var(--danger); font-weight: 800; }

.ai-image-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
}

.ai-image-editor,
.ai-image-output {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.ai-image-editor { display: grid; gap: 12px; }
.ai-image-editor label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; }
.ai-image-editor textarea { min-height: 120px; resize: vertical; }
.ai-image-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ai-image-options select { width: 100%; min-width: 0; }
.ai-image-reference { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-image-reference button { min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--brand-dark); font-weight: 800; }
.ai-image-reference span { color: var(--muted); font-size: 11px; }
.ai-image-reference-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-image-reference-list figure { position: relative; width: 92px; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ai-image-reference-list img { display: block; width: 80px; height: 64px; border-radius: 7px; object-fit: cover; }
.ai-image-reference-list figcaption { overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.ai-image-reference-list button { position: absolute; top: -6px; right: -6px; display: grid; width: 22px; height: 22px; place-items: center; border: 2px solid var(--surface); border-radius: 50%; background: var(--danger); color: #fff; font-weight: 900; }
.ai-image-generate { min-height: 44px; border: 0; border-radius: 11px; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; font-weight: 900; box-shadow: var(--shadow-sm); }
.ai-image-generate:disabled { cursor: wait; opacity: 0.68; }
.ai-image-status { min-height: 18px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.ai-image-output { position: relative; display: grid; min-height: 390px; place-items: center; overflow: hidden; background: linear-gradient(145deg, var(--surface-soft), var(--surface)); }
.ai-image-output [hidden] { display: none !important; }
.ai-image-output img { display: block; width: 100%; max-height: 520px; border-radius: 10px; object-fit: contain; }
.ai-image-empty { display: grid; justify-items: center; gap: 6px; color: var(--muted); text-align: center; }
.ai-image-empty strong { color: var(--brand-dark); font-size: 19px; }
.ai-image-result-actions { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 7px; padding: 7px; border-radius: 11px; background: rgba(255, 255, 255, 0.88); box-shadow: var(--shadow-sm); backdrop-filter: blur(8px); }
.ai-image-result-actions button { min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-dark); font-weight: 800; }
.ai-image-history-head { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.ai-image-history-head strong { color: var(--brand-dark); font-size: 13px; }
.ai-image-history-head button { border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.ai-image-history { display: flex; gap: 9px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; }
.ai-image-history > span { color: var(--muted); font-size: 11px; }
.ai-image-history-item { position: relative; flex: 0 0 132px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.ai-image-history-preview { display: block; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.ai-image-history-item img { display: block; width: 100%; height: 80px; border-radius: 7px; object-fit: cover; }
.ai-image-history-item span { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.ai-image-history-download { position: absolute; right: 9px; top: 56px; display: grid; width: 28px; height: 28px; padding: 0; place-items: center; border: 1px solid rgba(255,255,255,.7); border-radius: 9px; background: rgba(23,63,53,.88); color: #fff; font-size: 16px; font-weight: 900; box-shadow: var(--shadow-sm); opacity: 0; transform: translateY(3px); transition: opacity var(--transition-fast), transform var(--transition-fast); }
.ai-image-history-item:hover .ai-image-history-download,
.ai-image-history-download:focus-visible { opacity: 1; transform: translateY(0); }
.ai-image-history-item.expired img { opacity: .25; filter: grayscale(1); }
.ai-image-history-item.expired::after { content: "已失效"; position: absolute; inset: 36px 0 auto; color: var(--danger); font-size: 10px; font-weight: 900; text-align: center; pointer-events: none; }

@media (max-width: 900px) {
  .ai-image-layout { grid-template-columns: 1fr; }
  .ai-image-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agnes-key-panel { grid-template-columns: 1fr; }
  .agnes-key-status { grid-column: 1; }
}

@media (max-width: 560px) {
  .agnes-key-row { grid-template-columns: 1fr 1fr; }
  .agnes-key-row input { grid-column: 1 / -1; }
  .ai-image-options { grid-template-columns: 1fr; }
  .ai-image-output { min-height: 300px; }
  .ai-image-history-download { opacity: 1; transform: none; }
}

.novel-search-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

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

.novel-search-head strong {
  display: block;
  color: var(--brand-dark);
  font-size: 16px;
}

.novel-search-head span:not(.novel-search-safety),
.novel-search-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.novel-search-safety,
.novel-result-source {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(20, 116, 95, 0.2);
  border-radius: 999px;
  background: rgba(20, 116, 95, 0.08);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 900;
}

.novel-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.novel-search-row input,
.novel-search-row button {
  min-height: 42px;
}

.novel-search-row button,
.novel-result-import {
  padding: 8px 14px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  white-space: nowrap;
}

.novel-search-row button:disabled,
.novel-result-import:disabled {
  cursor: wait;
  opacity: 0.65;
}

.novel-search-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.novel-result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.novel-result-copy {
  min-width: 0;
}

.novel-result-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.novel-result-meta,
.novel-result-description {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.novel-result-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.novel-result-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.novel-result-import {
  min-height: 36px;
}

.novel-shelf-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.novel-shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.novel-shelf-head strong,
.novel-current-copy strong {
  display: block;
  color: var(--brand-dark);
  font-size: 16px;
}

.novel-shelf-head span,
.novel-current-copy span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.novel-shelf-actions,
.novel-current-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.novel-shelf-actions button,
.novel-current-actions button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
  white-space: nowrap;
}

.novel-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.novel-book-card {
  display: grid;
  justify-items: start;
  gap: 6px;
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fffdf7, #eef4f1);
  color: var(--ink);
  text-align: left;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.novel-book-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.novel-book-card.active {
  border-color: rgba(217, 154, 53, 0.85);
  background: linear-gradient(180deg, #fff3c8, #efbf67);
  box-shadow: 0 10px 22px rgba(76, 46, 11, 0.16);
}

.novel-book-title {
  font-size: 14px;
  line-height: 1.35;
}

.novel-book-meta,
.novel-book-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.novel-book-card.active .novel-book-meta,
.novel-book-card.active .novel-book-time {
  color: #6e460e;
}

.novel-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
  gap: 12px;
}

.novel-input,
.novel-reader-wrap {
  min-width: 0;
}

.novel-reader-wrap {
  display: grid;
  gap: 10px;
}

.novel-current-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.novel-url-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.novel-url-row button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
  white-space: nowrap;
}

.novel-input textarea.dragover,
.novel-reader.dragover {
  border-color: rgba(20, 116, 95, 0.75);
  box-shadow: 0 0 0 4px rgba(20, 116, 95, 0.14);
}

.novel-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.novel-controls label {
  font-size: 12px;
}

.novel-controls select,
.novel-controls button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
}

.novel-controls label select {
  margin-top: 6px;
}

.novel-reader {
  height: 286px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf6e8;
  color: #2a241b;
  font-size: 18px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.novel-reader[data-theme="dark"] {
  border-color: #253238;
  background: #151b1f;
  color: #e7e1d5;
}

.novel-reader[data-theme="green"] {
  border-color: #c9dfc7;
  background: #eff7e8;
  color: #21351f;
}

.novel-reader[data-mode="document"] {
  background: #fff;
  color: #222;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

.novel-reader[data-mode="note"] {
  border-color: #e5dcc7;
  background:
    linear-gradient(#fffbe8 31px, #eadfbf 32px) 0 0 / 100% 32px,
    #fffbe8;
  color: #3a3324;
}

.novel-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.community-card h2 {
  margin-bottom: 10px;
  font-size: 20px;
}

.community-card p {
  color: var(--muted);
  line-height: 1.6;
}

.notice-list {
  display: grid;
  gap: 10px;
}

.notice-list article {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.notice-list strong,
.roadmap-list strong {
  color: var(--brand-dark);
}

.notice-list span,
.roadmap-list span {
  color: var(--muted);
  line-height: 1.5;
}

.roadmap-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.roadmap-list li {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e6dccb;
  border-radius: 12px;
  background: #f8f4ea;
}

.tool-title {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.tool-title h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.tool-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #edf7f4;
  border: 1px solid #cce2dc;
  color: var(--brand-dark);
  font-weight: 900;
}

.timer-display {
  display: grid;
  place-items: center;
  min-height: 108px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: linear-gradient(145deg, #0d4039, #146c5f);
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tool-actions button {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand-dark);
  font-weight: 900;
}

.compact-actions button {
  font-size: 13px;
}

.tool-result {
  min-height: 44px;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid #cce2dc;
  border-radius: 12px;
  background: #edf7f4;
  color: var(--brand-dark);
  font-weight: 900;
  line-height: 1.45;
}

.tool-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .module-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .module-nav {
    justify-content: flex-start;
  }

  .section-head,
  .game-shell,
  .ddz-center,
  .info-grid,
  .toolbox-head,
  .community-head,
  .community-grid {
    grid-template-columns: 1fr;
  }

  .game-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .novel-tool {
    grid-column: 1 / -1;
  }

  .novel-shelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .novel-layout {
    grid-template-columns: 1fr;
  }

  .novel-search-results {
    grid-template-columns: 1fr;
  }

  .game-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .game-tab {
    grid-template-columns: 1fr;
    text-align: center;
    place-items: center;
  }

  .game-tab small {
    display: none;
  }

  .ddz-players {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px), (max-height: 680px) {
  body {
    overflow-x: hidden;
  }

  .game-section {
    width: min(100vw - 8px, 760px);
    padding: 6px 0 10px;
  }

  .site-header,
  .toolbox-section,
  .community-section {
    width: min(100vw - 8px, 760px);
  }

  .site-header {
    padding-top: 6px;
  }

  .toolbox-section,
  .community-section {
    padding: 6px 0 12px;
  }

  .module-bar {
    margin-bottom: 8px;
    padding: 8px;
  }

  .module-nav,
  .feature-strip,
  .game-overview {
    display: none;
  }

  .section-head {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    margin-bottom: 8px;
  }

  .section-kicker,
  .section-copy,
  .panel-head p,
  .game-tab small {
    display: none;
  }

  h1 {
    margin: 0;
    font-size: 22px;
  }

  h2 {
    margin: 0;
    font-size: 20px;
  }

  .connection-box,
  .game-stage {
    padding: 8px;
  }

  .toolbox-head,
  .community-head,
  .tool-card,
  .community-card {
    padding: 10px;
  }

  .tool-grid {
    gap: 8px;
  }

  .timer-display {
    min-height: 88px;
    font-size: 34px;
  }

  .novel-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .novel-shelf-head,
  .novel-current-head {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .novel-url-row {
    grid-template-columns: 1fr;
  }

  .novel-search-head,
  .novel-search-row,
  .novel-result-card {
    grid-template-columns: 1fr;
  }

  .novel-search-head {
    display: grid;
  }

  .novel-search-safety,
  .novel-result-actions {
    justify-self: start;
  }

  .novel-reader {
    height: 240px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .game-menu {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 6px;
  }

  .game-tab {
    flex: 0 0 88px;
    grid-template-columns: 1fr;
    place-items: center;
    text-align: center;
    padding: 8px 6px;
    scroll-snap-align: start;
  }

  .game-icon {
    width: 30px;
    height: 30px;
  }

  .panel-head {
    align-items: center;
    margin-bottom: 8px;
  }

  .status-pill {
    min-height: 28px;
    max-width: 52vw;
    padding: 5px 9px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  .wood {
    padding: 6px;
  }

  #gomoku-board {
    width: min(100%, max(260px, calc(100svh - 245px)), 600px);
  }

  #draw-board {
    width: min(100%, max(300px, calc((100svh - 285px) * 1.65)), 760px);
  }

  .inline-tools,
  .score-strip,
  .guess-box {
    gap: 6px;
    margin: 6px 0;
    padding: 7px;
  }

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

  .player-card {
    min-height: 58px;
    padding: 7px;
    font-size: 12px;
  }

  .ddz-center {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
  }

  #ddz-multiplier {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .card-row {
    gap: 4px;
    min-height: 42px;
  }

  .card {
    width: 34px;
    height: 48px;
    border-radius: 7px;
    font-size: 12px;
  }

  .compact .card {
    width: 30px;
    height: 42px;
    font-size: 11px;
  }

  .hand {
    max-height: 168px;
    overflow: auto;
    padding: 8px;
  }

  .history {
    max-height: 54px;
    overflow: auto;
    margin-top: 6px;
    font-size: 12px;
  }

  .chat-panel {
    margin-top: 8px;
    padding-top: 8px;
  }

  .chat-log {
    height: 58px;
    font-size: 12px;
  }

  .ddz-actions,
  .uno-actions,
  .mj-actions,
  .inline-tools,
  .guess-box {
    position: sticky;
    bottom: 0;
    z-index: 7;
    border: 1px solid rgba(222, 219, 210, 0.9);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
  }
}

@media (max-width: 560px) {
  .site-header,
  .game-section,
  .toolbox-section,
  .community-section {
    width: min(100vw - 12px, 1180px);
  }

  .game-section,
  .toolbox-section,
  .community-section {
    padding-top: 8px;
  }

  .section-head,
  .game-stage {
    padding: 12px;
  }

  .connection-row,
  .chat-input-row {
    grid-template-columns: 1fr;
  }

  .tool-grid,
  .community-grid {
    grid-template-columns: 1fr;
  }

  .game-menu {
    gap: 6px;
    padding: 8px;
  }

  .game-tab {
    flex-basis: 82px;
  }

  .card {
    width: 32px;
    height: 46px;
    border-radius: 7px;
    font-size: 11px;
  }

  .compact .card {
    width: 28px;
    height: 40px;
    font-size: 10px;
  }

  .hand {
    max-height: 146px;
  }
}

@media (max-width: 420px) {
  .section-head {
    padding: 8px;
  }

  .connection-box {
    gap: 7px;
  }

  .room-actions button,
  .primary,
  .choice,
  .inline-tools button,
  .ddz-actions button,
  .chat-input-row button {
    padding: 7px 9px;
    font-size: 12px;
  }

  input {
    padding: 8px 9px;
    font-size: 13px;
  }

  .status-pill {
    max-width: 46vw;
  }

  #gomoku-board {
    width: min(100%, max(230px, calc(100svh - 230px)), 600px);
  }

  #draw-board {
    width: min(100%, max(270px, calc((100svh - 265px) * 1.65)), 760px);
  }

  .chat-log {
    height: 46px;
  }
}

/* 斗地主：按经典欢乐斗地主的牌桌观感重做，使用纯 CSS，不依赖第三方素材。 */
#panel-doudizhu {
  --ddz-green: #0b6b4b;
  --ddz-green-deep: #074733;
  --ddz-gold: #f3c35b;
  --ddz-gold-deep: #b9791d;
}

#panel-doudizhu .panel-head {
  margin-bottom: 10px;
}

#panel-doudizhu .ddz-table {
  position: relative;
  gap: 12px;
  padding: 14px;
  border: 2px solid rgba(243, 195, 91, 0.75);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.14), transparent 34%),
    linear-gradient(145deg, #0b7a53, #06412f 68%, #03281f);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 18px 36px rgba(0, 0, 0, 0.18);
}

#panel-doudizhu .ddz-result {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.26);
  animation: ddz-result-pop 0.32s ease-out both;
}

#panel-doudizhu .ddz-result strong {
  font-size: 24px;
  line-height: 1;
}

#panel-doudizhu .ddz-result span {
  font-weight: 900;
}

#panel-doudizhu .ddz-result.win {
  background: linear-gradient(180deg, #fff4b8, #f0b33f);
  color: #4f2d00;
}

#panel-doudizhu .ddz-result.lose {
  background: linear-gradient(180deg, #dfe7ef, #94a3b8);
  color: #172033;
}

#panel-doudizhu .ddz-effect {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  min-width: 160px;
  padding: 14px 20px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.38);
  animation: ddz-combo-flash 1.25s ease-out both;
}

#panel-doudizhu .ddz-effect strong {
  font-size: 28px;
  line-height: 1;
}

#panel-doudizhu .ddz-effect span {
  margin-top: 6px;
  font-weight: 900;
}

#panel-doudizhu .ddz-effect.bomb {
  background: radial-gradient(circle at 50% 35%, #fff5b8, #f97316 56%, #7c2d12);
  color: #fffaf0;
}

#panel-doudizhu .ddz-effect.rocket {
  background: radial-gradient(circle at 50% 30%, #ffffff, #60a5fa 42%, #312e81 78%);
  color: #fff;
}

#panel-doudizhu .ddz-effect.plane {
  background: radial-gradient(circle at 50% 30%, #ecfeff, #22d3ee 48%, #0f766e 82%);
  color: #042f2e;
}

@keyframes ddz-result-pop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ddz-combo-flash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.65) rotate(-4deg);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(2deg);
  }
  68% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.16) rotate(0deg);
  }
}

#panel-doudizhu .ddz-players {
  gap: 8px;
}

#panel-doudizhu .player-card {
  position: relative;
  min-height: 82px;
  padding: 12px 12px 10px 54px;
  overflow: hidden;
  border: 1px solid rgba(243, 195, 91, 0.5);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(6, 51, 38, 0.9), rgba(12, 105, 74, 0.78));
  color: #fffaf0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

#panel-doudizhu .player-card::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 14px;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(243, 195, 91, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #fff3bd, #d9962a 58%, #8c4c12);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
}

#panel-doudizhu .player-card.active {
  outline: 0;
  border-color: #ffe08a;
  box-shadow: 0 0 0 3px rgba(243, 195, 91, 0.24), 0 0 18px rgba(243, 195, 91, 0.36);
}

#panel-doudizhu .player-card strong {
  margin-bottom: 5px;
  color: #fff7d4;
  font-size: 15px;
}

#panel-doudizhu .player-card .muted,
#panel-doudizhu .ddz-center .muted {
  color: rgba(255, 255, 255, 0.76);
}

#panel-doudizhu .player-card .status-pill {
  min-height: 24px;
  margin-top: 6px;
  padding: 3px 8px;
  border-color: rgba(243, 195, 91, 0.55);
  background: rgba(255, 246, 204, 0.14);
  color: #fff7d4;
}

#panel-doudizhu .ddz-center {
  grid-template-columns: minmax(120px, 0.9fr) minmax(160px, 1.2fr) auto;
  border-color: rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(2, 37, 28, 0.58);
}

#panel-doudizhu #ddz-multiplier {
  border-color: rgba(243, 195, 91, 0.72);
  background: linear-gradient(180deg, #fff0a8, #e5a936);
  color: #5a3200;
}

#panel-doudizhu .ddz-actions {
  justify-content: center;
  min-height: 42px;
}

#panel-doudizhu .ddz-actions button {
  min-width: 74px;
  border: 1px solid rgba(255, 237, 172, 0.9);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff0a8, #e19a2e);
  color: #5a3200;
  box-shadow: 0 6px 0 #8b5417, 0 10px 18px rgba(0, 0, 0, 0.22);
}

#panel-doudizhu .ddz-actions button.primary {
  background: linear-gradient(180deg, #fff4b8, #f0b33f);
}

#panel-doudizhu .ddz-actions button:disabled {
  opacity: 0.45;
  box-shadow: none;
}

#panel-doudizhu .card-row {
  gap: 4px;
}

#panel-doudizhu .card {
  width: 46px;
  height: 64px;
  border: 1px solid rgba(23, 23, 23, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(145deg, #ffffff 0%, #fffdf6 56%, #eadfc6 100%);
  box-shadow: 0 7px 12px rgba(0, 0, 0, 0.24);
  color: #111827;
  font-size: 14px;
}

#panel-doudizhu .card.red {
  color: #c1121f;
}

#panel-doudizhu .compact .card {
  width: 34px;
  height: 48px;
  font-size: 12px;
}

#panel-doudizhu .hand {
  min-height: 122px;
  padding: 34px 22px 14px;
  overflow-x: auto;
  border-color: rgba(243, 195, 91, 0.48);
  background: linear-gradient(180deg, rgba(1, 32, 25, 0.52), rgba(1, 23, 18, 0.76));
  user-select: none;
  touch-action: none;
}

#panel-doudizhu .hand .card {
  flex: 0 0 auto;
  margin-right: -18px;
  cursor: pointer;
  -webkit-user-drag: none;
  transform: translateY(calc(var(--card-curve) * 1.4px)) rotate(var(--card-angle));
  transform-origin: 50% 120%;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#panel-doudizhu .hand .card:hover {
  transform: translateY(-12px) rotate(var(--card-hover-angle));
}

#panel-doudizhu .hand .card.selected {
  transform: translateY(-24px) rotate(0deg);
  border-color: #f4b740;
  background: linear-gradient(145deg, #fffdf2, #ffe08a);
  box-shadow: 0 0 0 3px rgba(243, 195, 91, 0.34), 0 12px 16px rgba(0, 0, 0, 0.28);
}

#panel-doudizhu + .chat-panel {
  margin-top: 12px;
}

#ddz-history.history {
  max-height: 70px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid rgba(11, 107, 75, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
}

@media (max-width: 760px) {
  #panel-doudizhu .ddz-table {
    padding: 10px;
  }

  #panel-doudizhu .ddz-center {
    grid-template-columns: 1fr 1fr;
  }

  #panel-doudizhu #ddz-multiplier {
    grid-column: 1 / -1;
    justify-self: start;
  }

  #panel-doudizhu .card {
    width: 38px;
    height: 54px;
    font-size: 12px;
  }

  #panel-doudizhu .hand {
    min-height: 92px;
    padding: 16px 18px 12px;
  }
}

@media (max-width: 520px) {
  #panel-doudizhu .ddz-players {
    grid-template-columns: 1fr;
  }

  #panel-doudizhu .player-card {
    min-height: 64px;
    padding: 9px 10px 8px 48px;
  }

  #panel-doudizhu .player-card::before {
    left: 10px;
    top: 10px;
    width: 28px;
    height: 28px;
  }

  #panel-doudizhu .hand .card {
    margin-right: -18px;
  }
}

.uno-table,
.mahjong-table {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.uno-table {
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.16), transparent 34%), #202124;
}

.uno-players,
.mj-players {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.uno-player,
.mj-player {
  min-height: 64px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid transparent;
}

.uno-player.active,
.mj-player.active {
  border-color: #f3c35b;
  box-shadow: 0 0 0 3px rgba(243, 195, 91, 0.2);
}

.uno-player strong,
.mj-player strong {
  display: block;
  margin-bottom: 4px;
}

.uno-player em,
.mj-player em {
  display: inline-flex;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f7f2;
  color: var(--brand-dark);
  font-style: normal;
  font-weight: 800;
}

.uno-turn-tag {
  display: inline-flex;
  margin-top: 5px;
  margin-left: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f3c35b;
  color: #4f2d00;
  font-size: 12px;
}

.mj-turn-tag {
  display: inline-flex;
  margin-top: 5px;
  margin-left: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f3c35b;
  color: #4f2d00;
  font-size: 12px;
}

.mj-player-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.mj-player-melds span {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(14, 107, 80, 0.12);
  color: #0b4738;
  font-size: 12px;
  font-weight: 800;
}

.uno-center {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.uno-card-stack {
  min-height: 112px;
  display: flex;
  align-items: center;
}

.uno-card {
  display: grid;
  place-items: center;
  width: 72px;
  height: 104px;
  border: 5px solid #fff;
  border-radius: 14px;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
}

.uno-card span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.uno-card.red { background: #d72638; }
.uno-card.yellow { background: #f7b801; color: #3a2400; }
.uno-card.green { background: #1b998b; }
.uno-card.blue { background: #2d7dd2; }
.uno-card.wild,
.uno-card.back {
  background: conic-gradient(#d72638 0 25%, #f7b801 0 50%, #1b998b 0 75%, #2d7dd2 0);
}

.uno-color-chip {
  min-width: 76px;
  padding: 10px 12px;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  text-align: center;
  font-weight: 900;
}

.uno-color-chip[data-color="red"] { background: #d72638; color: #fff; }
.uno-color-chip[data-color="yellow"] { background: #f7b801; color: #3a2400; }
.uno-color-chip[data-color="green"] { background: #1b998b; color: #fff; }
.uno-color-chip[data-color="blue"] { background: #2d7dd2; color: #fff; }

.uno-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: #fff;
}

.uno-info div {
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.uno-info strong,
.uno-info span {
  display: block;
}

.uno-info strong {
  margin-bottom: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.uno-info span {
  font-weight: 900;
}

.uno-actions,
.mj-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
}

.uno-actions button,
.mj-actions button {
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.uno-declare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-weight: 900;
}

.uno-declare input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.uno-hand {
  display: flex;
  gap: 0;
  min-height: 126px;
  overflow-x: auto;
  padding: 12px;
}

.uno-hand .uno-card {
  flex: 0 0 auto;
  margin-right: -20px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.uno-hand .uno-card[data-playable] {
  outline: 3px solid #f3c35b;
  outline-offset: 3px;
}

.uno-hand .uno-card[data-disabled] {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.uno-hand .uno-card[data-playable]:hover {
  transform: translateY(-12px);
}

.uno-hand .uno-card[data-disabled]:hover {
  transform: none;
}

.mahjong-table {
  background: linear-gradient(145deg, #0e6b50, #06382b);
}

.mj-center {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.mj-center-river {
  grid-column: 1 / -1;
}

.mj-center-river .mj-river {
  min-height: 92px;
  align-content: flex-start;
  background: rgba(0, 0, 0, 0.16);
}

.mj-melds,
.mj-hand,
.mj-river {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 42px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.mj-meld {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fff;
}

.mj-meld strong {
  margin-right: 2px;
  color: #f3c35b;
}

.mj-turn-banner,
.mj-over-banner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 900;
}

.mj-turn-banner {
  background: rgba(255, 255, 255, 0.92);
  color: #0b4738;
}

.mj-over-banner {
  border: 2px solid #ffe08a;
  background: linear-gradient(180deg, #fff4b8, #d98d22);
  color: #4f2d00;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.mj-over-banner strong {
  font-size: 20px;
}

.mj-tile {
  display: grid;
  place-items: center;
  width: 38px;
  height: 52px;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: linear-gradient(180deg, #fffdf4, #e5dcc7);
  color: #123c31;
  font-weight: 900;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.22);
}

.mj-hand .mj-tile {
  cursor: pointer;
}

.mj-hand .mj-tile:hover {
  transform: translateY(-8px);
}

@media (max-width: 760px) {
  .uno-players,
  .mj-players {
    grid-template-columns: repeat(2, 1fr);
  }

  .uno-card {
    width: 58px;
    height: 84px;
    border-width: 4px;
  }

  .mj-tile {
    width: 32px;
    height: 46px;
    font-size: 12px;
  }
}

@media (max-width: 460px) {
  .uno-players,
  .mj-players,
  .uno-center,
  .mj-center {
    grid-template-columns: 1fr;
  }
}

/* 斗地主牌桌：座位、桌面牌、操作与手牌形成真实牌局层级。 */
#panel-doudizhu {
  --ddz-ink: #071b2a;
  --ddz-table: #123f4a;
  --ddz-table-deep: #082a34;
  --ddz-cream: #fffdf5;
  --ddz-red: #eb5548;
  --ddz-yellow: #f2c94c;
  --ddz-blue: #64a9d7;
}

#panel-doudizhu .ddz-table {
  display: grid;
  grid-template-rows: minmax(250px, 1fr) auto minmax(116px, auto);
  min-height: 535px;
  padding: 22px 28px 18px;
  gap: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  background: radial-gradient(ellipse at 50% 38%, rgba(65, 132, 141, 0.42), transparent 48%), linear-gradient(145deg, var(--ddz-table), var(--ddz-table-deep) 78%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 -70px 100px rgba(0, 0, 0, 0.18), 0 20px 44px rgba(7, 27, 42, 0.18);
}

#panel-doudizhu .ddz-table::before {
  content: "KB  ·  KASUKABE TABLE";
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  color: rgba(255, 255, 255, 0.055);
  font-size: clamp(32px, 5vw, 68px);
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

#panel-doudizhu .ddz-table > .ddz-players {
  position: absolute;
  z-index: 3;
  inset: 26px 30px 152px;
  display: block;
  pointer-events: none;
}

#panel-doudizhu .player-card {
  position: absolute;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 190px;
  min-height: 68px;
  padding: 9px 11px;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(5, 27, 35, 0.72);
  color: #fff;
  box-shadow: 0 12px 24px rgba(2, 17, 24, 0.25);
  backdrop-filter: blur(12px);
}

#panel-doudizhu .player-card::before { content: none; }
#panel-doudizhu .player-card.seat-left { top: 0; left: 0; }
#panel-doudizhu .player-card.seat-right { top: 0; right: 0; }
#panel-doudizhu .player-card.seat-self { bottom: 0; left: 0; }

#panel-doudizhu .player-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: var(--ddz-blue);
  color: #082433;
  font-size: 17px;
  font-weight: 900;
}

#panel-doudizhu .seat-right .player-avatar { background: var(--ddz-yellow); }
#panel-doudizhu .seat-self .player-avatar { background: var(--ddz-red); color: #fff; }
#panel-doudizhu .player-identity { min-width: 0; }

#panel-doudizhu .player-card strong {
  margin: 0 0 4px;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#panel-doudizhu .player-tags { display: flex; align-items: center; gap: 4px; min-height: 18px; }

#panel-doudizhu .player-card .status-pill,
#panel-doudizhu .landlord-tag {
  min-height: 0;
  margin: 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.82);
  font-size: 9px;
  line-height: 1.4;
}

#panel-doudizhu .landlord-tag { background: var(--ddz-yellow); color: #4a3500; font-weight: 900; }

#panel-doudizhu .player-count {
  display: grid;
  justify-items: center;
  min-width: 28px;
  color: rgba(255, 255, 255, 0.55);
}

#panel-doudizhu .player-count b { color: #fff; font-size: 20px; line-height: 1; }
#panel-doudizhu .player-count small { margin-top: 3px; font-size: 9px; }

#panel-doudizhu .player-card.active {
  border-color: rgba(242, 201, 76, 0.9);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.16), 0 12px 26px rgba(2, 17, 24, 0.3);
}

#panel-doudizhu .player-card.active .player-avatar { box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.2); }

#panel-doudizhu .ddz-center {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 110px minmax(180px, 1fr) auto;
  grid-row: 1;
  align-self: center;
  justify-self: center;
  align-items: center;
  width: min(590px, 72%);
  margin-top: 62px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(4, 28, 36, 0.48);
  box-shadow: none;
  backdrop-filter: blur(8px);
}

#panel-doudizhu .ddz-center .muted {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  letter-spacing: 0.12em;
}

#panel-doudizhu .ddz-play-zone {
  display: grid;
  justify-items: center;
  min-height: 72px;
  padding: 0 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

#panel-doudizhu .ddz-play-zone .card-row { justify-content: center; }
#panel-doudizhu .ddz-bottom-zone .card-row { flex-wrap: nowrap; }

#panel-doudizhu #ddz-multiplier {
  min-height: 30px;
  border: 0;
  background: var(--ddz-yellow);
  color: #413000;
  font-size: 11px;
  font-weight: 900;
  box-shadow: none;
}

#panel-doudizhu .ddz-actions {
  z-index: 5;
  grid-row: 2;
  justify-content: center;
  min-height: 42px;
  padding-left: 190px;
}

#panel-doudizhu .ddz-actions button {
  min-width: 76px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #18323c;
  box-shadow: 0 7px 14px rgba(2, 17, 24, 0.2);
}

#panel-doudizhu .ddz-actions button.primary { border-color: var(--ddz-red); background: var(--ddz-red); color: #fff; }
#panel-doudizhu .ddz-actions button:hover:not(:disabled) { transform: translateY(-2px); }

#panel-doudizhu .hand {
  z-index: 4;
  grid-row: 3;
  min-height: 120px;
  padding: 30px 24px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 0;
  border-radius: 16px;
  background: rgba(3, 22, 29, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  user-select: none;
  touch-action: none;
  flex-wrap: nowrap;
}

#panel-doudizhu .card {
  width: 50px;
  height: 72px;
  border: 1px solid rgba(7, 27, 42, 0.2);
  border-radius: 8px;
  background: linear-gradient(145deg, #fff, var(--ddz-cream) 68%, #e8dfcc);
  color: #101820;
  font-size: 15px;
  box-shadow: 0 6px 12px rgba(2, 17, 24, 0.24);
}

#panel-doudizhu .card.red { color: #cf352f; }
#panel-doudizhu .compact .card { width: 36px; height: 50px; font-size: 12px; }

#panel-doudizhu .hand .card {
  margin-right: -17px;
  transform: translateY(calc(var(--card-curve) * 0.22px)) rotate(var(--card-angle));
  transform-origin: 50% 120%;
}

#panel-doudizhu .hand .card:hover { transform: translateY(-11px) rotate(var(--card-hover-angle)); }

#panel-doudizhu .hand .card.selected {
  z-index: 10;
  border-color: var(--ddz-yellow);
  background: #fffdf4;
  transform: translateY(-21px) rotate(0);
  box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.42), 0 12px 20px rgba(2, 17, 24, 0.32);
}

#ddz-history.history {
  display: flex;
  gap: 6px;
  max-height: 58px;
  margin-top: 8px;
  padding: 7px;
  overflow: auto;
  border: 0;
  border-radius: 10px;
  background: rgba(7, 27, 42, 0.04);
}

#ddz-history.history:empty { display: none; }

#ddz-history.history > div {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 760px) {
  #panel-doudizhu .ddz-table { grid-template-rows: minmax(230px, 1fr) auto minmax(105px, auto); min-height: 490px; padding: 14px 10px 10px; border-radius: 18px; }
  #panel-doudizhu .ddz-table::before { inset: 9px; font-size: 25px; }
  #panel-doudizhu .ddz-players { inset: 16px 14px 142px; }
  #panel-doudizhu .player-card { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 7px; width: min(43%, 170px); min-height: 56px; padding: 7px; border-radius: 12px; }
  #panel-doudizhu .player-avatar { width: 34px; height: 34px; font-size: 13px; }
  #panel-doudizhu .player-card strong { font-size: 12px; }
  #panel-doudizhu .player-count b { font-size: 16px; }
  #panel-doudizhu .player-card.seat-self { bottom: 40px; }
  #panel-doudizhu .ddz-center { grid-template-columns: 84px minmax(110px, 1fr) auto; width: 94%; margin-top: 50px; padding: 10px; transform: translateY(-12px); }
  #panel-doudizhu .ddz-actions { gap: 6px; padding-left: 0; }
  #panel-doudizhu .ddz-actions button { min-width: 64px; min-height: 36px; padding: 7px 10px; }
  #panel-doudizhu .hand { min-height: 105px; padding: 26px 14px 10px; }
  #panel-doudizhu .card { width: 44px; height: 64px; font-size: 13px; }
  #panel-doudizhu .compact .card { width: 30px; height: 43px; font-size: 10px; }
  #panel-doudizhu .hand .card { margin-right: -18px; }
}

@media (max-width: 430px) {
  #panel-doudizhu .player-card { grid-template-columns: 32px minmax(0, 1fr) auto; width: 46%; }
  #panel-doudizhu .player-card.seat-self { width: 42%; }
  #panel-doudizhu .player-avatar { width: 32px; height: 32px; }
  #panel-doudizhu .player-tags .status-pill { display: none; }
  #panel-doudizhu .ddz-center { grid-template-columns: 70px minmax(90px, 1fr) auto; width: 98%; gap: 7px; }
  #panel-doudizhu .ddz-play-zone { padding: 0 5px; }
  #panel-doudizhu .ddz-actions button { min-width: 58px; padding-inline: 8px; font-size: 12px; }
}

