/* 子屏游戏 · 你画我猜（独立样式） */
.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 + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, 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, env(safe-area-inset-right, 0px)) 14px max(12px, 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;
}

.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, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(12px, 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) 48px 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 {
    height: 30px;
    border: 1px solid rgba(37, 50, 58, 0.12);
    border-radius: 8px;
    background: #fff;
    color: #25323a;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.dg-play-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(290px, 52cqh) 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 {
    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-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) 54px minmax(86px, 0.7fr);
    gap: 8px;
    align-items: center;
    padding-top: 8px;
}

.dg-tool-group {
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.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;
}

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

.dg-chat-bubble {
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--dg-bubble, #ffb6b9) 58%, transparent);
    border-radius: 8px;
    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-chat-bubble strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.2;
}

.dg-chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.45;
}

.dg-chat-bubble small {
    display: block;
    margin-top: 6px;
    color: rgba(37, 50, 58, 0.58);
    font-size: 11px;
    line-height: 1.25;
}

.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, 54cqh) 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) 44px;
    }

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

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-secondary {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #edf7f4;
}

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;
}
