/* 子屏游戏 · 你画我猜（独立样式） */
.draw-guess-game {
    position: absolute;
    inset: 0;
    z-index: 100190;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    font-family: ui-rounded, 'Apple LiGothic', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    color: #25323a;
}

.draw-guess-game.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dg-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background:
        linear-gradient(155deg, rgba(255, 248, 239, 0.98) 0%, rgba(239, 251, 248, 0.98) 48%, rgba(250, 241, 255, 0.98) 100%);
    overflow: hidden;
}

.dg-header {
    flex: 0 0 auto;
    min-height: 56px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 70px;
    align-items: center;
    gap: 6px;
    padding: calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) max(12px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px))) 8px max(12px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    box-sizing: border-box;
    border-bottom: 1px solid rgba(37, 50, 58, 0.09);
    background: rgba(255, 255, 255, 0.76);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dg-header h3 {
    margin: 0;
    min-width: 0;
    text-align: center;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: 0;
}

.dg-icon-btn,
.dg-text-btn {
    min-width: 0;
    height: 38px;
    border: 1px solid rgba(37, 50, 58, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: #26333c;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    letter-spacing: 0;
}

.dg-icon-btn {
    width: 38px;
    font-size: 24px;
    line-height: 1;
}

.dg-text-btn {
    padding: 0 10px;
    font-size: 13px;
}

.dg-header-spacer {
    width: 38px;
    height: 38px;
}

.dg-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px max(12px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px))) 14px max(12px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    box-sizing: border-box;
}

.dg-main--setup,
.dg-main--result {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dg-band,
.dg-word-band,
.dg-canvas-zone,
.dg-chat-zone,
.dg-winner-band,
.dg-rank-list,
.dg-history-band {
    border: 1px solid rgba(37, 50, 58, 0.09);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 10px 24px rgba(56, 74, 83, 0.08);
}

.dg-band {
    padding: 12px;
    box-sizing: border-box;
}

.dg-band-title,
.dg-chat-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.25;
    color: rgba(37, 50, 58, 0.68);
}

.dg-band-title strong,
.dg-chat-title strong {
    color: #25323a;
    font-size: 15px;
}

.dg-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 8px;
    margin-bottom: 10px;
}

.dg-search-row input,
.dg-search-row button,
.dg-options-band select {
    width: 100%;
    min-width: 0;
    height: 40px;
    box-sizing: border-box;
    border: 1px solid rgba(37, 50, 58, 0.13);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    color: #25323a;
    font: inherit;
    font-size: 14px;
    letter-spacing: 0;
    outline: none;
}

.dg-search-row input {
    padding: 0 11px;
}

.dg-search-row button {
    font-weight: 800;
    cursor: pointer;
}

.dg-friend-list {
    display: grid;
    gap: 8px;
    max-height: 46cqh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dg-friend-list::-webkit-scrollbar { width: 0; height: 0; display: none; }

.dg-friend-row {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    box-sizing: border-box;
    border: 1px solid rgba(37, 50, 58, 0.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.62);
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.dg-friend-row.is-selected {
    border-color: rgba(44, 159, 143, 0.42);
    background: rgba(223, 250, 245, 0.82);
}

.dg-friend-avatar,
.dg-score-avatar,
.dg-chat-avatar,
.dg-rank-avatar,
.dg-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
    border-radius: 10px;
    background: linear-gradient(145deg, #ffe6ef 0%, #dff7f2 100%);
    color: #31535c;
    font-weight: 850;
    line-height: 1;
}

.dg-friend-avatar,
.dg-chat-avatar {
    width: 42px;
    height: 42px;
}

.dg-friend-avatar img,
.dg-score-avatar img,
.dg-chat-avatar img,
.dg-rank-avatar img,
.dg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dg-friend-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dg-friend-main strong,
.dg-rank-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.15;
}

.dg-friend-main small,
.dg-history-row small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(37, 50, 58, 0.58);
    font-size: 12px;
    line-height: 1.2;
}

.dg-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(44, 159, 143, 0.12);
    color: #1d7d72;
    font-weight: 900;
}

.dg-options-band {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.dg-options-band label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    color: #31414b;
}

.dg-footer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 12px max(12px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px))) max(14px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))) max(12px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    box-sizing: border-box;
    border-top: 1px solid rgba(37, 50, 58, 0.09);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dg-footer--play {
    grid-template-columns: minmax(0, 0.66fr) minmax(0, 0.66fr) minmax(0, 1.28fr);
}

.dg-primary,
.dg-secondary {
    min-width: 0;
    min-height: 44px;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: 0;
    cursor: pointer;
}

.dg-primary {
    border: 1px solid rgba(44, 159, 143, 0.22);
    background: #2c9f8f;
    color: #fff;
}

.dg-secondary {
    border: 1px solid rgba(37, 50, 58, 0.13);
    background: rgba(255, 255, 255, 0.78);
    color: #25323a;
}

.dg-primary:disabled,
.dg-secondary:disabled {
    opacity: 0.58;
    cursor: default;
}

.dg-main--play {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.dg-score-strip {
    flex: 0 0 auto;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px;
}

.dg-score-strip::-webkit-scrollbar {
    display: none;
}

.dg-score-chip {
    flex: 0 0 auto;
    min-width: 88px;
    max-width: 126px;
    height: 42px;
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 5px;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--dg-chip, #8bd3dd) 48%, transparent);
    background: color-mix(in srgb, var(--dg-chip, #8bd3dd) 22%, white);
}

.dg-score-chip.is-user {
    border-color: rgba(242, 183, 5, 0.38);
    background: rgba(255, 247, 218, 0.9);
}

.dg-score-avatar {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 12px;
}

.dg-score-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 800;
}

.dg-score-chip strong {
    font-size: 14px;
}

.dg-word-band {
    flex: 0 0 auto;
    min-height: 46px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    box-sizing: border-box;
}

.dg-word-band span,
.dg-word-band small {
    font-size: 12px;
    color: rgba(37, 50, 58, 0.62);
    white-space: nowrap;
}

.dg-word-band strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 18px;
    line-height: 1.2;
    color: #26333c;
}

.dg-word-band button,
.dg-word-btn {
    height: 30px;
    padding: 0 9px;
    border: 1px solid rgba(37, 50, 58, 0.12);
    border-radius: 8px;
    background: #fff;
    color: #25323a;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.dg-word-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.dg-play-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    /* 行高改按容器比例（fr）分配，不再用 cqh：#app 只是 inline-size 容器，
       cqh 实际回退到视口高度——软键盘弹起/地址栏伸缩时视口高度突变，
       画布区与聊天区比例跟着跳（真机抖屏诱因之一）。fr 只随自身容器走。 */
    grid-template-rows: minmax(290px, 1.15fr) minmax(180px, 1fr);
    gap: 10px;
}

.dg-canvas-zone {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    box-sizing: border-box;
}

.dg-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    border: 1px dashed rgba(37, 50, 58, 0.18);
    background:
        linear-gradient(45deg, rgba(44, 159, 143, 0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(44, 159, 143, 0.05) 25%, transparent 25%),
        #fffdf8;
    background-size: 18px 18px;
}

/* 画布右下角·小线性图标发送猜图按钮 */
.dg-canvas-send {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 11px 0 9px;
    border: 1px solid rgba(44, 159, 143, 0.5);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #1d7d72;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 4px 12px rgba(44, 159, 143, 0.22);
}

.dg-canvas-send svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
}

.dg-canvas-send.is-busy {
    color: rgba(37, 50, 58, 0.5);
    border-color: rgba(37, 50, 58, 0.18);
    cursor: default;
}

.dg-canvas-send.is-busy svg {
    animation: dg-spin 0.9s linear infinite;
}

@keyframes dg-spin {
    to { transform: rotate(360deg); }
}

.dg-canvas-wrap canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    touch-action: none;
    cursor: crosshair;
}

.dg-toolbar {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 50px 40px minmax(76px, 0.62fr);
    gap: 8px;
    align-items: center;
    padding-top: 8px;
}

.dg-tool-undo {
    font-size: 18px;
    line-height: 1;
    padding: 0;
}

.dg-tool-group {
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x;
    cursor: grab;
    scroll-behavior: auto;
}

.dg-tool-group:active {
    cursor: grabbing;
}

.dg-tool-group::-webkit-scrollbar {
    display: none;
}

.dg-swatch {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    background: var(--dg-swatch);
    box-shadow: 0 0 0 1px rgba(37, 50, 58, 0.12);
    cursor: pointer;
}

.dg-swatch.is-active {
    box-shadow: 0 0 0 2px #26333c;
}

.dg-tool-btn {
    height: 34px;
    border: 1px solid rgba(37, 50, 58, 0.13);
    border-radius: 8px;
    background: #fff;
    color: #25323a;
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    cursor: pointer;
}

.dg-tool-btn.is-active {
    background: #26333c;
    color: #fff;
}

.dg-size {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    color: rgba(37, 50, 58, 0.68);
    font-size: 12px;
    font-weight: 800;
}

.dg-size input {
    min-width: 0;
}

.dg-chat-zone {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

.dg-reaction-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding-right: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dg-reaction-list::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.dg-chat-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    -webkit-touch-callout: none;
}

.dg-chat-row.is-user {
    flex-direction: row-reverse;
}

.dg-chat-row.is-grouped {
    margin-top: -4px;
}

.dg-chat-av {
    flex: 0 0 auto;
    width: 40px;
}

.dg-chat-avatar {
    width: 40px;
    height: 40px;
}

.dg-chat-col {
    min-width: 0;
    max-width: 78%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.dg-chat-row.is-user .dg-chat-col {
    align-items: flex-end;
}

.dg-chat-name {
    margin: 0 2px 4px;
    font-size: 12px;
    line-height: 1.2;
    color: rgba(37, 50, 58, 0.62);
    font-weight: 800;
}

.dg-bubble-quote {
    max-width: 100%;
    margin-bottom: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(37, 50, 58, 0.07);
    color: rgba(37, 50, 58, 0.6);
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dg-chat-bubble {
    min-width: 0;
    max-width: 100%;
    border: 1px solid color-mix(in srgb, var(--dg-bubble, #ffb6b9) 58%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--dg-bubble, #ffb6b9) 27%, white);
    padding: 8px 10px;
    box-sizing: border-box;
}

.dg-chat-row.is-correct .dg-chat-bubble {
    border-color: rgba(44, 159, 143, 0.45);
    background: rgba(225, 250, 245, 0.92);
}

.dg-bubble-action {
    display: block;
    margin-bottom: 2px;
    color: rgba(37, 50, 58, 0.6);
    font-size: 12px;
    line-height: 1.4;
    font-style: italic;
}

.dg-bubble-main {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.45;
}

.dg-bubble-trans {
    display: block;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed rgba(37, 50, 58, 0.18);
    color: rgba(37, 50, 58, 0.62);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.4;
}

.dg-bubble-edited {
    display: inline-block;
    margin-top: 4px;
    color: rgba(37, 50, 58, 0.42);
    font-size: 10px;
}

.dg-bubble-emoji {
    display: block;
    max-width: 110px;
    max-height: 110px;
    border-radius: 6px;
}

.dg-chat-meta {
    margin: 4px 2px 0;
    color: rgba(37, 50, 58, 0.55);
    font-size: 11px;
    line-height: 1.25;
}

.dg-feed-tip {
    align-self: center;
    margin: 2px auto;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(37, 50, 58, 0.06);
    color: rgba(37, 50, 58, 0.5);
    font-size: 11px;
}

.dg-multi-check {
    flex: 0 0 auto;
    align-self: center;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1.5px solid rgba(44, 159, 143, 0.5);
    color: #1d7d72;
    font-size: 12px;
    font-weight: 900;
}

.dg-chat-row.is-selected .dg-chat-bubble {
    outline: 2px solid rgba(44, 159, 143, 0.6);
    outline-offset: 1px;
}

.dg-typing {
    display: inline-flex;
    gap: 4px;
    padding: 3px 2px;
}

.dg-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(37, 50, 58, 0.4);
    animation: dg-typing 1s infinite ease-in-out;
}

.dg-typing i:nth-child(2) { animation-delay: 0.16s; }
.dg-typing i:nth-child(3) { animation-delay: 0.32s; }

@keyframes dg-typing {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.dg-chat-multi {
    display: inline-flex;
    gap: 6px;
}

.dg-mini-btn {
    height: 26px;
    padding: 0 10px;
    border: 1px solid rgba(37, 50, 58, 0.14);
    border-radius: 7px;
    background: #fff;
    color: #25323a;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.dg-msg-menu {
    position: fixed;
    z-index: 100210;
    display: none;
    flex-direction: row;
    gap: 2px;
    padding: 4px;
    background: #4c4c4c;
    border-radius: 9px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
    font-family: inherit;
    -webkit-user-select: none;
    user-select: none;
}

.dg-msg-menu.is-open {
    display: flex;
}

.dg-msg-menu__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 52px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}

.dg-msg-menu__item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.dg-msg-menu__item:active {
    background: rgba(255, 255, 255, 0.22);
}

.dg-msg-menu__ico {
    font-size: 17px;
    line-height: 1;
}

.dg-msg-menu__txt {
    letter-spacing: 0.5px;
}

/* ===== 底部聊天输入栏（接收 / 表情 / 输入框 / 发送） ===== */
.dg-composer {
    display: block;
    padding: 8px max(10px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px))) max(10px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))) max(10px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
}

.dg-quote-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 7px;
    padding: 5px 8px 5px 10px;
    border-radius: 8px;
    background: rgba(37, 50, 58, 0.07);
    color: rgba(37, 50, 58, 0.7);
    font-size: 12px;
}

.dg-quote-bar span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dg-quote-x {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(37, 50, 58, 0.1);
    color: #25323a;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.dg-composer-row {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.dg-composer-icon,
.dg-composer-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(37, 50, 58, 0.13);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.86);
    color: #31414b;
    cursor: pointer;
}

.dg-composer-icon.is-active {
    border-color: rgba(44, 159, 143, 0.5);
    background: rgba(223, 250, 245, 0.85);
    color: #1d7d72;
}

.dg-composer-icon:disabled {
    opacity: 0.5;
    cursor: default;
}

.dg-composer-send {
    width: auto;
    min-width: 44px;
    padding: 0 12px;
    border-color: rgba(44, 159, 143, 0.3);
    background: #2c9f8f;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 850;
}

.dg-composer-input {
    width: 100%;
    min-width: 0;
    height: 40px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid rgba(37, 50, 58, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #25323a;
    font: inherit;
    font-size: 14px;
    outline: none;
}

.dg-emoji-panel {
    display: none;
    margin-top: 8px;
    max-height: 0;
    overflow: hidden;
}

.dg-emoji-panel.is-open {
    display: block;
    max-height: 220px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(37, 50, 58, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    padding: 8px;
}

.dg-emoji-cat {
    margin: 4px 2px 6px;
    font-size: 12px;
    font-weight: 800;
    color: rgba(37, 50, 58, 0.6);
}

.dg-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
    margin-bottom: 6px;
}

.dg-emoji-item {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.65);
    cursor: pointer;
}

.dg-emoji-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.dg-emoji-empty {
    padding: 18px 10px;
    text-align: center;
    color: rgba(37, 50, 58, 0.5);
    font-size: 12px;
}

.dg-empty {
    padding: 18px 10px;
    color: rgba(37, 50, 58, 0.56);
    text-align: center;
    font-size: 13px;
    line-height: 1.45;
}

.dg-empty--chat {
    margin: auto 0;
}

.dg-winner-band {
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: center;
}

.dg-winner-band span,
.dg-winner-band small {
    color: rgba(37, 50, 58, 0.62);
    font-size: 13px;
}

.dg-winner-band strong {
    font-size: 24px;
    line-height: 1.2;
    color: #2c9f8f;
}

.dg-rank-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dg-rank-row,
.dg-history-row {
    min-height: 48px;
    display: grid;
    grid-template-columns: 28px 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    box-sizing: border-box;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.62);
}

.dg-rank-row.is-winner {
    background: rgba(255, 245, 209, 0.9);
}

.dg-rank-no {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(242, 183, 5, 0.18);
    color: #9b7200;
    font-weight: 900;
    font-size: 12px;
}

.dg-rank-avatar {
    width: 38px;
    height: 38px;
    border-radius: 8px;
}

.dg-rank-row strong {
    font-size: 17px;
    color: #25323a;
}

.dg-history-band {
    padding: 10px;
}

.dg-history-row {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    min-height: 38px;
    margin-top: 6px;
    font-size: 13px;
}

.dg-history-row span {
    color: rgba(37, 50, 58, 0.62);
}

.dg-history-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sgh-tile--draw-guess .sgh-tile__icon {
    border-color: rgba(44, 159, 143, 0.42);
    background: linear-gradient(160deg, #fffdf8 0%, #e2fbf6 100%);
    color: #1d7d72;
}

html[data-appearance="dark"] .sgh-tile--draw-guess .sgh-tile__icon {
    border-color: rgba(88, 214, 198, 0.4);
    background: linear-gradient(160deg, #244d4d 0%, #382f52 100%);
    color: #d9fff8;
}

@media (min-height: 760px) {
    .dg-play-layout {
        grid-template-rows: minmax(330px, 1.25fr) minmax(200px, 1fr);
    }
}

@media (max-width: 360px) {
    .dg-header {
        grid-template-columns: 38px minmax(0, 1fr) 58px;
    }

    .dg-options-band {
        grid-template-columns: 1fr;
    }

    .dg-footer--play {
        grid-template-columns: 0.62fr 0.62fr 1.36fr;
    }

    .dg-word-band {
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        gap: 6px;
    }

    .dg-word-band small {
        display: none;
    }

    .dg-word-btn {
        padding: 0 7px;
    }

    .dg-composer-row {
        gap: 6px;
    }

    .dg-composer-icon,
    .dg-composer-send {
        width: 36px;
        height: 36px;
    }

    .dg-composer-send {
        width: auto;
        min-width: 40px;
    }
}

html[data-appearance="dark"] .draw-guess-game {
    color: #edf7f4;
}

html[data-appearance="dark"] .dg-shell {
    background: linear-gradient(155deg, #1f2729 0%, #1b2b2e 48%, #2a2331 100%);
}

html[data-appearance="dark"] .dg-header,
html[data-appearance="dark"] .dg-footer {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(24, 31, 34, 0.76);
}

html[data-appearance="dark"] .dg-band,
html[data-appearance="dark"] .dg-word-band,
html[data-appearance="dark"] .dg-canvas-zone,
html[data-appearance="dark"] .dg-chat-zone,
html[data-appearance="dark"] .dg-winner-band,
html[data-appearance="dark"] .dg-rank-list,
html[data-appearance="dark"] .dg-history-band {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(29, 39, 43, 0.74);
    box-shadow: none;
}

html[data-appearance="dark"] .dg-icon-btn,
html[data-appearance="dark"] .dg-text-btn,
html[data-appearance="dark"] .dg-search-row input,
html[data-appearance="dark"] .dg-search-row button,
html[data-appearance="dark"] .dg-options-band select,
html[data-appearance="dark"] .dg-tool-btn,
html[data-appearance="dark"] .dg-word-band button,
html[data-appearance="dark"] .dg-word-btn,
html[data-appearance="dark"] .dg-mini-btn,
html[data-appearance="dark"] .dg-composer-icon,
html[data-appearance="dark"] .dg-composer-input,
html[data-appearance="dark"] .dg-secondary {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #edf7f4;
}

html[data-appearance="dark"] .dg-composer-send {
    border-color: rgba(44, 159, 143, 0.4);
    background: #2c9f8f;
    color: #fff;
}

html[data-appearance="dark"] .dg-composer-icon.is-active {
    border-color: rgba(88, 214, 198, 0.5);
    background: rgba(44, 159, 143, 0.22);
    color: #d9fff8;
}

html[data-appearance="dark"] .dg-canvas-send {
    background: rgba(29, 39, 43, 0.9);
    border-color: rgba(88, 214, 198, 0.5);
    color: #d9fff8;
}

html[data-appearance="dark"] .dg-emoji-panel.is-open {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(29, 39, 43, 0.7);
}

html[data-appearance="dark"] .dg-emoji-item {
    background: rgba(255, 255, 255, 0.06);
}

html[data-appearance="dark"] .dg-quote-bar,
html[data-appearance="dark"] .dg-bubble-quote,
html[data-appearance="dark"] .dg-feed-tip {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(237, 247, 244, 0.7);
}

html[data-appearance="dark"] .dg-band-title strong,
html[data-appearance="dark"] .dg-chat-title strong,
html[data-appearance="dark"] .dg-word-band strong,
html[data-appearance="dark"] .dg-header h3,
html[data-appearance="dark"] .dg-rank-row strong {
    color: #edf7f4;
}

html[data-appearance="dark"] .dg-friend-row,
html[data-appearance="dark"] .dg-rank-row,
html[data-appearance="dark"] .dg-history-row {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
}

html[data-appearance="dark"] .dg-friend-row.is-selected {
    border-color: rgba(88, 214, 198, 0.48);
    background: rgba(44, 159, 143, 0.22);
}

html[data-appearance="dark"] .dg-canvas-wrap {
    border-color: rgba(255, 255, 255, 0.14);
}

html[data-appearance="dark"] .dg-chat-bubble {
    color: #1f2a32;
}

/* ============ 设置入口（局数/词库下方） ============ */

.dg-settings-band {
    padding: 6px;
}

.dg-settings-entry {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    box-sizing: border-box;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dg-settings-entry:active {
    background: rgba(44, 159, 143, 0.08);
}

.dg-settings-entry__main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dg-settings-entry__main strong {
    font-size: 15px;
    color: #25323a;
}

.dg-settings-entry__main small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: rgba(37, 50, 58, 0.58);
}

.dg-settings-entry__chev {
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    color: rgba(37, 50, 58, 0.4);
}

.dg-chat-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ============ 游戏设置弹层 ============ */

.dg-set-mask {
    position: absolute;
    inset: 0;
    z-index: 100198;
    background: rgba(31, 42, 46, 0.42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
}

.dg-set-modal {
    width: 100%;
    max-width: 360px;
    max-height: min(76%, 560px);
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(37, 50, 58, 0.1);
    border-radius: 12px;
    background: linear-gradient(165deg, rgba(255, 252, 246, 0.99), rgba(240, 251, 248, 0.99));
    box-shadow: 0 18px 48px rgba(31, 42, 46, 0.28);
    overflow: hidden;
}

.dg-set-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 10px 10px 16px;
    border-bottom: 1px solid rgba(37, 50, 58, 0.09);
}

.dg-set-head strong {
    color: #25323a;
    font-size: 15px;
    letter-spacing: 3px;
}

.dg-set-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 6px 16px calc(14px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dg-set-body::-webkit-scrollbar { width: 0; height: 0; display: none; }

.dg-set-group__title {
    margin: 14px 0 4px;
    font-size: 11.5px;
    letter-spacing: 2px;
    color: #2c9f8f;
}

.dg-set-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(37, 50, 58, 0.12);
}

.dg-set-row__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dg-set-row__main strong {
    color: #25323a;
    font-size: 13.5px;
    font-weight: 700;
}

.dg-set-row__main small {
    color: rgba(37, 50, 58, 0.56);
    font-size: 11px;
    line-height: 1.5;
}

.dg-set-stepper {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dg-set-stepbtn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid rgba(37, 50, 58, 0.14);
    background: rgba(255, 255, 255, 0.9);
    color: #1d7d72;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.dg-set-stepbtn:active {
    background: rgba(223, 250, 245, 0.9);
}

.dg-set-num {
    width: 52px;
    height: 30px;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid rgba(37, 50, 58, 0.14);
    border-radius: 7px;
    background: #fff;
    color: #25323a;
    -webkit-text-fill-color: #25323a;
    caret-color: #2c9f8f;
    font: inherit;
    font-size: 14px;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.dg-set-num::-webkit-outer-spin-button,
.dg-set-num::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dg-set-num:focus {
    border-color: rgba(44, 159, 143, 0.6);
}

/* —— 开关 —— */
.dg-switch {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 26px;
    padding: 0;
    border-radius: 13px;
    border: 1px solid rgba(37, 50, 58, 0.16);
    background: rgba(37, 50, 58, 0.12);
    cursor: pointer;
    transition: background 0.22s ease, border-color 0.22s ease;
    -webkit-tap-highlight-color: transparent;
}

.dg-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(31, 42, 46, 0.25);
    transition: left 0.22s ease, background 0.22s ease;
}

.dg-switch.is-on {
    background: #2c9f8f;
    border-color: rgba(44, 159, 143, 0.7);
}

.dg-switch.is-on::after {
    left: 22px;
}

/* —— 手札参与者勾选 —— */
.dg-set-journal {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(44, 159, 143, 0.22);
    border-radius: 8px;
    background: rgba(223, 250, 245, 0.4);
}

.dg-set-journal__title {
    color: #1d7d72;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.dg-set-journal__hint {
    color: rgba(37, 50, 58, 0.56);
    font-size: 11px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.dg-journal-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dg-journal-chip {
    padding: 6px 13px;
    border-radius: 14px;
    border: 1px solid rgba(37, 50, 58, 0.16);
    background: rgba(255, 255, 255, 0.8);
    color: rgba(37, 50, 58, 0.66);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.dg-journal-chip.is-on {
    border-color: rgba(44, 159, 143, 0.7);
    color: #1d7d72;
    background: rgba(223, 250, 245, 0.92);
}

/* ============ 历史对局：可点展开回看 ============ */

.dg-history-row {
    grid-template-columns: 64px minmax(0, 1fr) auto auto;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(37, 50, 58, 0.08);
    font: inherit;
    text-align: left;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.dg-history-row:hover,
.dg-history-row.is-expanded {
    border-color: rgba(44, 159, 143, 0.45);
}

.dg-history-chev {
    flex: 0 0 auto;
    color: rgba(37, 50, 58, 0.44);
    font-size: 12px;
}

.dg-hisdetail {
    margin: -2px 0 6px;
    padding: 12px;
    border: 1px solid rgba(44, 159, 143, 0.28);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: rgba(255, 255, 255, 0.78);
}

.dg-hisdetail-meta {
    color: rgba(37, 50, 58, 0.62);
    font-size: 11.5px;
    line-height: 1.6;
    margin-bottom: 8px;
    word-break: break-word;
}

.dg-hisdetail-sec + .dg-hisdetail-sec {
    margin-top: 12px;
}

.dg-hisdetail-sec__title {
    color: #1d7d72;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.dg-hisdetail-sec__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 6px;
    padding: 4px 0;
    border: none;
    background: transparent;
    font: inherit;
    color: #1d7d72;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dg-hisdetail-sec__toggle:active {
    opacity: 0.75;
}

.dg-hisdetail-summary {
    padding: 10px 12px;
    border: 1px solid rgba(44, 159, 143, 0.2);
    border-radius: 7px;
    background: rgba(240, 251, 248, 0.75);
}

.dg-hisdetail-summary__text {
    color: #25323a;
    font-size: 12.5px;
    line-height: 1.75;
    word-break: break-word;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    white-space: pre-wrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dg-hisdetail-summary__text::-webkit-scrollbar { width: 0; height: 0; display: none; }

.dg-hisdetail-summary__hint {
    color: rgba(37, 50, 58, 0.56);
    font-size: 12px;
    line-height: 1.6;
}

.dg-hisdetail-sumbtn {
    margin-top: 8px;
    height: 32px;
    padding: 0 16px;
    border-radius: 7px;
    border: 1px solid rgba(44, 159, 143, 0.55);
    background: #2c9f8f;
    color: #fff;
    font: inherit;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dg-hisdetail-msgs {
    max-height: 42vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(37, 50, 58, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.66);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dg-hisdetail-msgs::-webkit-scrollbar { width: 0; height: 0; display: none; }

.dg-hisdetail-divider {
    text-align: center;
    color: rgba(37, 50, 58, 0.5);
    font-size: 11px;
    letter-spacing: 1px;
    padding: 2px 0;
}

.dg-hisdetail-msg {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
    line-height: 1.65;
    word-break: break-word;
}

.dg-hisdetail-msg b {
    font-size: 11px;
    font-weight: 800;
    color: #1d7d72;
}

.dg-hisdetail-msg b i {
    font-style: normal;
    font-weight: 400;
    color: rgba(37, 50, 58, 0.5);
    margin-left: 4px;
}

.dg-hisdetail-msg.is-user b {
    color: #b0722c;
}

.dg-hisdetail-msg span {
    color: #25323a;
}

/* 窄屏（小机型）微调：设置弹层贴边 */
@media (max-width: 360px) {
    .dg-set-mask { padding: 14px 10px; }
    .dg-set-body { padding: 4px 12px 12px; }
    .dg-history-row { grid-template-columns: 56px minmax(0, 1fr) auto auto; }
}

/* ============ 深色模式 ============ */

html[data-appearance="dark"] .dg-settings-entry__main strong,
html[data-appearance="dark"] .dg-set-head strong,
html[data-appearance="dark"] .dg-set-row__main strong,
html[data-appearance="dark"] .dg-hisdetail-summary__text,
html[data-appearance="dark"] .dg-hisdetail-msg span {
    color: #edf7f4;
}

html[data-appearance="dark"] .dg-settings-entry__main small,
html[data-appearance="dark"] .dg-settings-entry__chev,
html[data-appearance="dark"] .dg-set-row__main small,
html[data-appearance="dark"] .dg-set-journal__hint,
html[data-appearance="dark"] .dg-journal-chip,
html[data-appearance="dark"] .dg-hisdetail-meta,
html[data-appearance="dark"] .dg-hisdetail-summary__hint,
html[data-appearance="dark"] .dg-hisdetail-divider,
html[data-appearance="dark"] .dg-history-chev {
    color: rgba(237, 247, 244, 0.62);
}

html[data-appearance="dark"] .dg-set-mask {
    background: rgba(10, 14, 15, 0.6);
}

html[data-appearance="dark"] .dg-set-modal {
    border-color: rgba(255, 255, 255, 0.1);
    background: linear-gradient(165deg, rgba(31, 41, 45, 0.99), rgba(26, 37, 40, 0.99));
}

html[data-appearance="dark"] .dg-set-head {
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-appearance="dark"] .dg-set-row {
    border-color: rgba(255, 255, 255, 0.1);
}

html[data-appearance="dark"] .dg-set-stepbtn,
html[data-appearance="dark"] .dg-journal-chip {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
}

html[data-appearance="dark"] .dg-set-stepbtn {
    color: #7fe0d2;
}

html[data-appearance="dark"] .dg-set-num {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    color: #edf7f4;
    -webkit-text-fill-color: #edf7f4;
    caret-color: #7fe0d2;
}

html[data-appearance="dark"] .dg-switch {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.12);
}

html[data-appearance="dark"] .dg-switch.is-on {
    background: #2c9f8f;
    border-color: rgba(88, 214, 198, 0.6);
}

html[data-appearance="dark"] .dg-set-journal {
    border-color: rgba(88, 214, 198, 0.28);
    background: rgba(44, 159, 143, 0.12);
}

html[data-appearance="dark"] .dg-set-journal__title,
html[data-appearance="dark"] .dg-set-group__title,
html[data-appearance="dark"] .dg-hisdetail-sec__title,
html[data-appearance="dark"] .dg-hisdetail-sec__toggle,
html[data-appearance="dark"] .dg-hisdetail-msg b {
    color: #7fe0d2;
}

html[data-appearance="dark"] .dg-journal-chip.is-on {
    border-color: rgba(88, 214, 198, 0.55);
    color: #7fe0d2;
    background: rgba(44, 159, 143, 0.22);
}

html[data-appearance="dark"] .dg-hisdetail {
    border-color: rgba(88, 214, 198, 0.3);
    background: rgba(29, 39, 43, 0.8);
}

html[data-appearance="dark"] .dg-hisdetail-summary,
html[data-appearance="dark"] .dg-hisdetail-msgs {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

html[data-appearance="dark"] .dg-hisdetail-msg.is-user b {
    color: #f2c184;
}
