.game-app button {
    font-family: "Ciname", sans-serif;
}

/* ---------------------------------------------------------------
   Shell — clay page, safe-area aware
--------------------------------------------------------------- */
.game-app {
    width: min(96vw, 1160px);
    margin-inline: auto;
    padding: 10px 14px calc(18px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------
   Setup panel — chunky clay card
--------------------------------------------------------------- */
.panel {
    max-width: 900px;
    margin: 0 auto;
    background: var(--panel);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 22px 18px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.07),
        inset -3px -3px 12px rgba(0, 0, 0, 0.3),
        var(--shadow);
}

body.light-theme .panel {
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.55),
        inset -3px -3px 12px rgba(70, 43, 124, 0.1),
        var(--shadow);
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 1.3rem;
    text-align: center;
}

/* ---------------------------------------------------------------
   Form fields ≥52px, clay recessed
--------------------------------------------------------------- */
.dg-input {
    width: 100%;
    min-height: 52px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 1rem;
    font-family: "Nazanin", sans-serif;
    outline: none;
    direction: rtl;
    text-align: center;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22);
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-theme .dg-input {
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.dg-input:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.18),
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22);
}

#dgRoomCode {
    font-family: "Consolas", "Courier New", monospace;
    text-transform: uppercase;
    direction: ltr;
    letter-spacing: 4px;
}

/* ---------------------------------------------------------------
   Buttons — chunky clay, cyan accent, ≥52px targets
--------------------------------------------------------------- */
.dg-btn {
    border: 0;
    min-height: 56px;
    padding: 12px 26px;
    border-radius: 18px;
    font-size: 1.05rem;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease-out, opacity 0.2s, box-shadow 0.2s;
}

.dg-btn.primary {
    background: linear-gradient(135deg, #22d3ee, #0891b2);
    color: #fff;
    font-weight: 700;
    box-shadow:
        inset -3px -3px 8px rgba(0, 0, 0, 0.26),
        inset 2px 2px 6px rgba(255, 255, 255, 0.28),
        0 8px 18px rgba(8, 145, 178, 0.3),
        0 0 16px rgba(34, 211, 238, 0.18);
}

.dg-btn.primary:hover {
    opacity: 0.92;
}

.dg-btn.primary:active {
    transform: scale(0.96) translateY(1px);
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.3),
        inset 3px 3px 8px rgba(0, 0, 0, 0.2),
        0 3px 8px rgba(8, 145, 178, 0.25);
}

.dg-btn.secondary {
    background: var(--panel-strong);
    color: var(--text);
    box-shadow:
        inset -3px -3px 8px rgba(0, 0, 0, 0.25),
        inset 2px 2px 6px rgba(255, 255, 255, 0.08),
        0 6px 14px rgba(0, 0, 0, 0.2);
}

body.light-theme .dg-btn.secondary {
    background: var(--panel-strong);
    border: 2px solid rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -3px -3px 8px rgba(70, 43, 124, 0.08),
        0 6px 14px rgba(70, 43, 124, 0.08);
}

.dg-btn.secondary:active {
    transform: scale(0.96) translateY(1px);
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.3),
        inset 3px 3px 8px rgba(0, 0, 0, 0.2),
        0 3px 8px rgba(0, 0, 0, 0.2);
}

.dg-btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font-weight: 700;
    box-shadow:
        inset -3px -3px 8px rgba(0, 0, 0, 0.26),
        inset 2px 2px 6px rgba(255, 255, 255, 0.22),
        0 8px 20px rgba(239, 68, 68, 0.3);
}

.dg-btn.danger:active {
    transform: scale(0.96) translateY(1px);
}

.dg-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.dg-btn.small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 14px;
}

/* ---------------------------------------------------------------
   Play layout — mobile-first column, sidebar on desktop
--------------------------------------------------------------- */
.dg-play-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------------------------------------------------------------
   Timer — badge row + gradient bar
--------------------------------------------------------------- */
.dg-timer-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.dg-round-badge {
    font-size: 0.85rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
}

.dg-timer-seconds {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 1.6rem;
    font-weight: 700;
    min-width: 56px;
    text-align: center;
    direction: ltr;
}

.timer-bar-wrap {
    position: relative;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.timer-bar-fill {
    position: relative;
    height: 100%;
    border-radius: 10px;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

.timer-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(90deg, transparent 20%, rgba(255, 255, 255, 0.25) 50%, transparent 80%);
}

/* ---------------------------------------------------------------
   Word card + draw/prep controls
--------------------------------------------------------------- */
.dg-word-card {
    position: relative;
    text-align: center;
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.16), rgba(8, 145, 178, 0.07));
    border: 2px solid rgba(34, 211, 238, 0.25);
    border-radius: 24px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.07),
        inset -3px -3px 12px rgba(0, 0, 0, 0.26),
        0 10px 26px rgba(8, 145, 178, 0.14);
}

body.light-theme .dg-word-card {
    border-color: rgba(8, 145, 178, 0.3);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.6),
        inset -3px -3px 12px rgba(70, 43, 124, 0.08),
        0 10px 26px rgba(70, 43, 124, 0.06);
}

.dg-word {
    font-size: clamp(1.7rem, 7vw, 2.4rem);
    font-weight: 700;
    color: var(--text);
    margin: 6px 0;
    line-height: 1.3;
    word-break: break-word;
    background: linear-gradient(135deg, #67e8f9, #0891b2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dg-word-hint {
    font-family: "Nazanin", sans-serif;
    color: var(--muted);
    font-size: 0.85rem;
}

.dg-word-cat {
    display: inline-flex;
    justify-content: center;
    margin: 8px 0 4px;
}

.dg-cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: "Nazanin", sans-serif;
    font-size: 0.85rem;
    color: #67e8f9;
    background: rgba(34, 211, 238, 0.12);
    border: 2px solid rgba(34, 211, 238, 0.3);
    border-radius: 999px;
    padding: 4px 14px;
}

body.light-theme .dg-cat-badge {
    color: #0e7490;
    background: rgba(8, 145, 178, 0.1);
    border-color: rgba(8, 145, 178, 0.3);
}

.dg-hint-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    margin: 0;
}

#dgPrepCats .cat-item,
.dg-confirm .cat-item {
    min-height: 50px;
}

.dg-confirm {
    text-align: center;
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.16), rgba(8, 145, 178, 0.07));
    border: 2px solid rgba(34, 211, 238, 0.25);
    border-radius: 24px;
    padding: 18px 16px;
    margin-bottom: 14px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.07),
        inset -3px -3px 12px rgba(0, 0, 0, 0.26),
        0 10px 26px rgba(8, 145, 178, 0.14);
}

body.light-theme .dg-confirm {
    border-color: rgba(8, 145, 178, 0.3);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.6),
        inset -3px -3px 12px rgba(70, 43, 124, 0.08),
        0 10px 26px rgba(70, 43, 124, 0.06);
}

.dg-confirm-badge {
    display: inline-flex;
    justify-content: center;
    margin-bottom: 12px;
}

.dg-confirm-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.dg-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.dg-confirm-swapped {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #4ade80;
    font-family: "Nazanin", sans-serif;
    font-size: 0.9rem;
    padding: 0 6px;
}

.dg-confirm-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.dg-confirm-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #67e8f9;
    font-size: 0.85rem;
    font-family: "Nazanin", sans-serif;
    margin-top: 2px;
}

body.light-theme .dg-confirm-link {
    color: #0e7490;
}

/* ---------------------------------------------------------------
   Canvas — clay frame, 4:3 aspect, crosshair for drawer
--------------------------------------------------------------- */
.dg-canvas-wrap {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg-soft);
    border: 2px solid rgba(34, 211, 238, 0.4);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.08),
        inset -3px -3px 12px rgba(0, 0, 0, 0.3),
        0 12px 28px rgba(8, 145, 178, 0.18);
    touch-action: none;
    animation: dgCanvasGlow 5s ease-in-out infinite;
}

@keyframes dgCanvasGlow {
    0%, 100% {
        box-shadow:
            inset 2px 2px 8px rgba(255, 255, 255, 0.08),
            inset -3px -3px 12px rgba(0, 0, 0, 0.3),
            0 12px 28px rgba(8, 145, 178, 0.18),
            0 0 18px rgba(34, 211, 238, 0.26);
    }
    50% {
        box-shadow:
            inset 2px 2px 8px rgba(255, 255, 255, 0.08),
            inset -3px -3px 12px rgba(0, 0, 0, 0.3),
            0 12px 28px rgba(8, 145, 178, 0.18),
            0 0 28px rgba(34, 211, 238, 0.4);
    }
}

.dg-canvas-wrap.guesser-mode {
    touch-action: auto;
}

body.light-theme .dg-canvas-wrap {
    border-color: rgba(8, 145, 178, 0.45);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.6),
        inset -3px -3px 12px rgba(70, 43, 124, 0.08),
        0 12px 28px rgba(70, 43, 124, 0.06);
}

#dgCanvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    background: #fff;
    touch-action: none;
    border-radius: 12px;
}

.dg-canvas-wrap:not(.guesser-mode) #dgCanvas {
    cursor: crosshair;
}

/* ---------------------------------------------------------------
   Toolbar — swatches ≥44px, chips ≥48px, gaps ≥8px
--------------------------------------------------------------- */
.dg-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.06),
        inset -3px -3px 10px rgba(0, 0, 0, 0.28),
        var(--shadow);
}

.dg-tool-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.dg-tool-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

body.light-theme .dg-tool-divider {
    background: rgba(109, 40, 217, 0.2);
}

body.light-theme .dg-toolbar {
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -3px -3px 10px rgba(70, 43, 124, 0.08),
        var(--shadow);
}

.dg-color-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.35),
        inset 2px 2px 6px rgba(255, 255, 255, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease-out, box-shadow 0.15s;
}

body.light-theme .dg-color-btn {
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow:
        inset -2px -2px 6px rgba(70, 43, 124, 0.16),
        inset 2px 2px 6px rgba(255, 255, 255, 0.7),
        0 4px 10px rgba(70, 43, 124, 0.12);
}

.dg-color-btn:active {
    transform: scale(0.9);
}

.dg-color-btn.active {
    transform: scale(1.12);
    border-color: #fff;
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.55),
        0 4px 12px rgba(0, 0, 0, 0.35);
}

.dg-size-btn {
    min-width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.14);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.24);
    transition: border-color 0.15s, background 0.15s, transform 0.15s ease-out;
}

body.light-theme .dg-size-btn {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.dg-size-btn:active {
    transform: scale(0.94);
}

.dg-size-btn.active {
    border-color: #22d3ee;
    background: rgba(34, 211, 238, 0.18);
    box-shadow:
        0 0 12px rgba(34, 211, 238, 0.25),
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22);
}

.dg-size-dot {
    display: inline-block;
    border-radius: 50%;
    background: var(--text);
    transition: background 0.15s;
}

body.light-theme .dg-size-dot {
    background: #17122b;
}

.dg-size-btn.active .dg-size-dot {
    background: #0e7490;
}

.dg-size-dot.erase {
    background: transparent;
    border: 2px solid var(--text);
    box-sizing: border-box;
}

body.light-theme .dg-size-dot.erase {
    border-color: #17122b;
}

.dg-size-btn.active .dg-size-dot.erase {
    border-color: #0e7490;
}

/* ---------------------------------------------------------------
   Guesses panel + feed
--------------------------------------------------------------- */
.dg-guesses-panel {
    background: var(--panel);
    border: 2px solid rgba(255, 255, 255, 0.07);
    border-radius: 22px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    max-height: 52vh;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.06),
        inset -3px -3px 10px rgba(0, 0, 0, 0.28),
        0 8px 22px rgba(0, 0, 0, 0.16);
}

body.light-theme .dg-guesses-panel {
    border-color: rgba(109, 40, 217, 0.13);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.55),
        inset -3px -3px 10px rgba(70, 43, 124, 0.08),
        0 8px 22px rgba(70, 43, 124, 0.06);
}

.dg-guesses-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
    text-align: center;
}

.dg-guess-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.dg-guess-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.2);
    animation: dg-slide-in 0.25s ease;
}

.dg-guess-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.dg-guess-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.dg-guess-like {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 44px;
    min-height: 44px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s ease-out, color 0.2s;
}

.dg-guess-like svg {
    width: 17px;
    height: 17px;
    stroke-width: 2;
}

.dg-guess-like:hover {
    color: var(--text);
}

.dg-guess-like.liked {
    color: #fb7185;
}

.dg-guess-like:active {
    transform: scale(0.9) translateY(1px);
}

@keyframes dg-slide-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.light-theme .dg-guess-item {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.dg-guess-item.dg-mine {
    border-color: rgba(34, 211, 238, 0.5);
    background: rgba(34, 211, 238, 0.1);
}

body.light-theme .dg-guess-item.dg-mine {
    background: rgba(8, 145, 178, 0.08);
}

.dg-guess-name {
    font-size: 0.8rem;
    color: var(--accent);
    white-space: nowrap;
}

.dg-guess-text {
    flex: 1;
    font-family: "Nazanin", sans-serif;
    text-align: right;
    word-break: break-word;
    color: var(--text);
}

.dg-guess-accept {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 12px;
    border: 0;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.25),
        inset 2px 2px 5px rgba(255, 255, 255, 0.22),
        0 4px 10px rgba(34, 197, 94, 0.3);
    transition: transform 0.2s ease-out, opacity 0.2s;
}

.dg-guess-accept:active {
    transform: scale(0.94) translateY(1px);
}

.dg-guess-accept:focus-visible,
.dg-guess-like:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

body.light-theme .dg-guess-like {
    color: #7a6a9e;
}

body.light-theme .dg-guess-like:hover {
    color: #4c3a6e;
}

body.light-theme .dg-guess-like.liked {
    color: #e11d48;
}

.dg-guess-input-row {
    display: flex;
    gap: 8px;
}

.dg-guess-input {
    flex: 1;
    min-width: 0;
    min-height: 52px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-radius: 16px;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: "Nazanin", sans-serif;
    outline: none;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-theme .dg-guess-input {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.dg-guess-input:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 3px rgba(34, 211, 238, 0.18),
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.2);
}

.dg-guess-input-row .dg-btn {
    min-height: 52px;
    flex-shrink: 0;
}

.dg-guess-done {
    color: #22c55e;
    font-size: 0.85rem;
    text-align: center;
    font-family: "Nazanin", sans-serif;
}

.dg-empty {
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.9rem;
    text-align: center;
    padding: 12px;
}

/* ---------------------------------------------------------------
   Full-screen drawing HUD (skribbl-style)
   Toggled on by `body.dg-playing` for a true canvas-first screen.
--------------------------------------------------------------- */
body.dg-playing {
    overflow: hidden;
}

body.dg-playing .game-topbar {
    display: none;
}

body.dg-playing .sh-navbar {
    display: none;
}

.dg-hud {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: flex;
    flex-direction: column;
    background: radial-gradient(1200px 700px at 80% -10%, rgba(34, 211, 238, 0.16), transparent 60%),
        radial-gradient(900px 600px at 10% 110%, rgba(139, 92, 246, 0.18), transparent 60%),
        var(--bg);
}

body.light-theme .dg-hud {
    background: radial-gradient(1200px 700px at 80% -10%, rgba(34, 211, 238, 0.14), transparent 60%),
        radial-gradient(900px 600px at 10% 110%, rgba(139, 92, 246, 0.12), transparent 60%),
        var(--bg);
}

.dg-hud-top {
    flex: 0 0 auto;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    background: linear-gradient(180deg, rgba(20, 16, 40, 0.88), rgba(20, 16, 40, 0.5));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-theme .dg-hud-top {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.62));
}

.dg-round-chip {
    flex: 0 0 auto;
    font-family: "Nazanin", sans-serif;
    font-size: 0.85rem;
    color: #67e8f9;
    background: rgba(34, 211, 238, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 999px;
    padding: 5px 12px;
    white-space: nowrap;
}

body.light-theme .dg-round-chip {
    color: #0e7490;
    background: rgba(8, 145, 178, 0.1);
    border-color: rgba(8, 145, 178, 0.3);
}

.dg-hud-word {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.dg-hud-top .dg-timer-seconds {
    flex: 0 0 auto;
    font-size: 1.35rem;
    min-width: 46px;
}

.dg-secret-word {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #67e8f9, #0891b2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dg-drawer-caption {
    font-family: "Nazanin", sans-serif;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: nowrap;
}

.dg-word-cell-inline {
    display: inline-flex;
    gap: 2px;
    font-size: clamp(1.1rem, 4vw, 1.5rem);
}

.dg-guess-word {
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dg-word-category {
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.9rem;
    white-space: nowrap;
}

.dg-word-dashes-inline {
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
    direction: rtl;
}

.dg-word-dash {
    display: inline-block;
    width: clamp(18px, 3vw, 26px);
    aspect-ratio: 1;
    border: 2px solid var(--accent);
    border-radius: 2px;
    box-sizing: border-box;
}

.dg-word-gap {
    display: inline-block;
    width: 0.5em;
}

.dg-word-cell {
    display: inline-block;
    min-width: 0.6em;
    text-align: center;
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    padding: 2px 1px;
    font-size: 1.5rem;
    font-weight: 700;
}

.dg-timer-strip {
    flex: 0 0 auto;
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.dg-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #22d3ee, #0891b2);
    transition: width 0.4s linear;
}

.dg-hud:not(.dg-hud-prep) .dg-timer-strip {
    display: none;
}

/* Stage: full remaining space, canvas fit with 4:3 letterbox */
.dg-hud-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px calc(14px + env(safe-area-inset-right)) 8px calc(14px + env(safe-area-inset-left));
}

.dg-canvas-frame {
    --dg-timer-progress: 100%;
    position: relative;
    width: min(100%, calc((100svh - 200px) * 1.333));
    max-width: 100%;
    padding: 3px;
    aspect-ratio: 4 / 3;
    border-radius: 19px;
    background: conic-gradient(from -90deg, #22d3ee 0 var(--dg-timer-progress), rgba(255, 255, 255, 0.12) var(--dg-timer-progress) 100%);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), 0 0 24px rgba(34, 211, 238, 0.18);
}

body.light-theme .dg-canvas-frame {
    background: conic-gradient(from -90deg, #0891b2 0 var(--dg-timer-progress), rgba(70, 43, 124, 0.16) var(--dg-timer-progress) 100%);
    box-shadow: 0 18px 40px rgba(70, 43, 124, 0.16), 0 0 24px rgba(8, 145, 178, 0.14);
}

.dg-hud-stage #dgCanvas {
    display: block;
    width: min(100%, calc((100svh - 200px) * 1.333));
    max-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    background: #fff;
    border-radius: 16px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.4),
        inset -2px -2px 8px rgba(0, 0, 0, 0.12),
        0 18px 40px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(34, 211, 238, 0.18);
    touch-action: none;
}

.dg-canvas-frame #dgCanvas {
    width: 100%;
    max-width: none;
    height: 100%;
}

.dg-hud[data-role="drawer"] .dg-hud-stage #dgCanvas {
    cursor: crosshair;
}

.dg-hud[data-role="guesser"] .dg-hud-stage #dgCanvas {
    pointer-events: none;
    touch-action: auto;
}

body.light-theme .dg-hud-stage #dgCanvas {
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.8),
        inset -2px -2px 8px rgba(70, 43, 124, 0.1),
        0 18px 40px rgba(70, 43, 124, 0.18);
}

.dg-hud-endpick {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    z-index: 3;
    min-width: 46px;
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(20, 16, 40, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease-out;
}

.dg-hud-endpick svg {
    width: 1.3em;
    height: 1.3em;
}

.dg-hud-endpick:active {
    transform: scale(0.92) translateY(1px);
}

/* Prep / confirm overlay cards */
.dg-prep-wrap {
    width: min(92vw, 420px);
    margin: 0 auto;
}

.dg-prep-card {
    text-align: center;
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.16), rgba(8, 145, 178, 0.06));
    border: 2px solid rgba(34, 211, 238, 0.25);
    border-radius: 26px;
    padding: 22px 18px;
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.07),
        inset -3px -3px 12px rgba(0, 0, 0, 0.26),
        0 18px 40px rgba(0, 0, 0, 0.35);
}

body.light-theme .dg-prep-card {
    border-color: rgba(8, 145, 178, 0.3);
    box-shadow:
        inset 2px 2px 8px rgba(255, 255, 255, 0.6),
        inset -3px -3px 12px rgba(70, 43, 124, 0.08),
        0 18px 40px rgba(70, 43, 124, 0.12);
}

.dg-hud-card-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 6px;
}

.dg-hud-card-sub {
    font-family: "Nazanin", sans-serif;
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0 0 14px;
}

.dg-hud-card-badge {
    display: inline-flex;
    justify-content: center;
    margin-bottom: 12px;
}

.dg-prep-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* Reused glass button in the HUD */
.dg-hud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 50px;
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: var(--panel-strong);
    color: var(--text);
    font-family: "Nazanin", sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease-out, opacity 0.2s, box-shadow 0.2s;
}

.dg-hud-btn svg {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
}

.dg-hud-btn.primary {
    background: linear-gradient(135deg, #22d3ee, #0891b2);
    color: #fff;
    font-weight: 700;
}

.dg-hud-btn.secondary {
    background: var(--panel-strong);
}

.dg-hud-btn.danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

body.light-theme .dg-hud-btn.danger {
    color: #dc2626;
}

.dg-hud-btn.subtle {
    min-height: 40px;
    padding: 6px 14px;
    font-size: 0.85rem;
    box-shadow: none;
}

.dg-hud-btn:active {
    transform: scale(0.96) translateY(1px);
}

.dg-hud-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Floating edge toolbar (drawer only) — glassmorphism column */
.dg-hud-toolbar {
    position: fixed;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(2, auto);
    align-content: flex-start;
    gap: 8px;
    padding: 10px;
    background: rgba(20, 16, 40, 0.6);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    box-shadow: var(--shadow);
}

body.light-theme .dg-hud-toolbar {
    background: rgba(255, 255, 255, 0.72);
}

.dg-hud[data-role="drawer"] .dg-hud-stage {
    padding-inline-end: calc(160px + env(safe-area-inset-right));
}

.dg-tool-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dg-hud-tool-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.dg-hud-tool-label {
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
}

.dg-hud-tool-item:focus-within .dg-hud-tool-label,
.dg-hud-tool-item:hover .dg-hud-tool-label {
    color: var(--text);
}
body.light-theme .dg-tool-cluster + .dg-tool-cluster {
    border-top-color: rgba(109, 40, 217, 0.16);
}

.dg-hud-tool {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 3px;
    border: 2px solid rgba(255, 255, 255, 0.16);
    background: var(--panel-strong);
    color: var(--text);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.14),
        inset -2px -2px 0 rgba(0, 0, 0, 0.28),
        0 2px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease-out, background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.dg-hud-tool svg {
    width: 1.05em;
    height: 1.05em;
}

.dg-hud-tool:active {
    transform: scale(0.9);
}

.dg-hud-tool.active {
    background: #1d4ed8;
    border-color: #93c5fd;
    color: #fff;
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.18), inset -2px -2px 0 rgba(0, 0, 0, 0.24);
}

.dg-hud-tool.danger {
    color: #f87171;
}

.dg-hud-tool.danger.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #f87171;
}

body.light-theme .dg-hud-tool.active {
    color: #0e7490;
}

/* Undo icon points right (arrowRight); flip for RTL "بازگشت" feel */
.dg-undo svg {
    transform: scaleX(-1);
}

.dg-color-chip {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 11px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    background: var(--panel);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        inset -2px -2px 6px rgba(0, 0, 0, 0.35),
        inset 2px 2px 6px rgba(255, 255, 255, 0.45),
        0 3px 8px rgba(0, 0, 0, 0.22);
    transition: transform 0.15s ease-out, box-shadow 0.15s;
}

body.light-theme .dg-color-chip {
    border-color: rgba(255, 255, 255, 0.9);
}

.dg-color-chip:active {
    transform: scale(0.9);
}

.dg-color-chip.active {
    transform: scale(1.1);
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.55), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dg-color-chip.wide {
    width: 34px;
    height: 34px;
    min-width: 34px;
}

.dg-color-more {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: var(--bg-soft);
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: color 0.15s, border-color 0.15s;
}

.dg-color-more svg {
    width: 1.1em;
    height: 1.1em;
}

.dg-color-more.active,
.dg-color-more:hover {
    color: #67e8f9;
    border-color: rgba(34, 211, 238, 0.4);
}

/* Popover of the full palette */
.dg-color-popover {
    position: absolute;
    top: 50%;
    left: calc(100% + 12px);
    transform: translateY(-50%);
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    width: 150px;
    padding: 10px;
    background: rgba(20, 16, 40, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 7;
}

body.light-theme .dg-color-popover {
    background: rgba(255, 255, 255, 0.95);
}

.dg-color-popover.dg-open {
    display: flex;
}

/* Bottom guess ticker */
.dg-ticker {
    flex: 0 0 auto;
    z-index: 4;
    padding: 10px 12px;
    background: rgba(20, 16, 40, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-theme .dg-ticker {
    background: rgba(255, 255, 255, 0.72);
}

.dg-ticker-track {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(34, 211, 238, 0.5) transparent;
}

.dg-ticker-track::-webkit-scrollbar {
    height: 4px;
}

.dg-ticker-track::-webkit-scrollbar-thumb {
    background: rgba(34, 211, 238, 0.5);
    border-radius: 4px;
}

.dg-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 6px 12px;
    animation: dg-chip-in 0.25s ease;
}

.dg-chip-name {
    color: var(--accent);
    font-size: 0.78rem;
    white-space: nowrap;
    font-weight: 700;
}

.dg-chip-text {
    color: var(--text);
    font-family: "Nazanin", sans-serif;
    font-size: 0.9rem;
    white-space: nowrap;
}

.dg-chip.dg-mine {
    border-color: rgba(34, 211, 238, 0.5);
    background: rgba(34, 211, 238, 0.14);
}

.dg-chip-close {
    border-color: rgba(251, 191, 36, 0.65);
    background: rgba(245, 158, 11, 0.16);
    animation: dg-chip-in 0.25s ease, dg-close-pulse 1.4s ease-in-out infinite;
}

.dg-chip-correct {
    border-color: rgba(74, 222, 128, 0.85);
    background: rgba(34, 197, 94, 0.22);
    animation: dg-chip-in 0.25s ease, dg-correct-glow 1.4s ease-in-out infinite;
}

.dg-chip-placeholder {
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
    font-size: 0.85rem;
}

.dg-chip-like {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    min-width: 32px;
    min-height: 32px;
    padding: 2px 7px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    touch-action: manipulation;
    transition: color 0.2s, transform 0.15s ease-out;
}

.dg-chip-like svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.dg-chip-like.liked {
    color: #fb7185;
}

.dg-chip-like:active {
    transform: scale(0.88) translateY(1px);
}

.dg-chip-like:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 1px;
}

.dg-chip-win {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-inline-start: 2px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: #fbbf24;
    cursor: pointer;
    touch-action: manipulation;
    transition: color 0.2s, transform 0.15s ease-out;
}

.dg-chip-win svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.dg-chip-win:hover {
    color: #fde68a;
}

.dg-chip-win:active {
    transform: scale(0.88) translateY(1px);
}

.dg-chip-win:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 1px;
}

.dg-chip-like-badge,
.dg-guess-like-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: var(--muted);
    pointer-events: none;
}

.dg-chip-like-badge svg,
.dg-guess-like-badge svg {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.dg-chip-like-badge.liked,
.dg-guess-like-badge.liked {
    color: #fb7185;
}

/* Guess input dock (guesser only) — above the canvas */
.dg-guess-field {
    flex: 0 0 auto;
    z-index: 4;
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(20, 16, 40, 0.6);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-theme .dg-guess-field {
    background: rgba(255, 255, 255, 0.72);
}

.dg-guess-field .dg-guess-input {
    flex: 1;
    min-width: 0;
    min-height: 50px;
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
    border-radius: 16px;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: "Nazanin", sans-serif;
    outline: none;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s;
}

body.light-theme .dg-guess-field .dg-guess-input {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.12);
}

.dg-guess-field .dg-guess-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.dg-send-btn {
    flex: 0 0 auto;
    min-width: 50px;
    min-height: 50px;
    padding: 0 16px;
}

.dg-guess-done {
    position: absolute;
    top: calc(54px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 8;
    color: #22c55e;
    font-size: 0.85rem;
    font-family: "Nazanin", sans-serif;
    background: rgba(20, 16, 40, 0.7);
    padding: 5px 14px;
    border-radius: 999px;
    pointer-events: none;
}

/* Ticker / canvas animations */
@keyframes dg-chip-in {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dg-close-pulse {
    0%, 100% {
        box-shadow: 0 0 0 rgba(251, 191, 36, 0);
    }
    50% {
        box-shadow: 0 0 14px rgba(251, 191, 36, 0.55);
    }
}

@keyframes dg-correct-glow {
    0%, 100% {
        box-shadow: 0 0 0 rgba(74, 222, 128, 0);
    }
    50% {
        box-shadow: 0 0 16px rgba(74, 222, 128, 0.6);
    }
}


/* ---------------------------------------------------------------
   Results / finished — winner banner + score cards
--------------------------------------------------------------- */
.dg-winner-banner {
    text-align: center;
    padding: 18px;
    border-radius: 22px;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.1));
    border: 2px solid rgba(34, 197, 94, 0.35);
    margin-bottom: 16px;
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.07),
        inset -2px -2px 8px rgba(0, 0, 0, 0.22),
        0 8px 20px rgba(34, 197, 94, 0.12);
}

body.light-theme .dg-winner-banner {
    box-shadow:
        inset 2px 2px 6px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.06);
}

.dg-winner-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.dg-winner-word {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 6px;
}

.dg-score-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.dg-score-card {
    background: var(--bg-soft);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 14px;
    text-align: center;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.05),
        inset -2px -2px 8px rgba(0, 0, 0, 0.2);
}

body.light-theme .dg-score-card {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.12);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08);
}

.dg-score-name {
    font-size: 0.9rem;
    margin-bottom: 4px;
    word-break: break-word;
    color: var(--text);
}

.dg-score-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

.dg-score-round {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: "Nazanin", sans-serif;
}

/* ---------------------------------------------------------------
   Toast
--------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: calc(84px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.dg-toast {
    background: var(--bg-soft);
    border: 2px solid rgba(34, 211, 238, 0.3);
    color: var(--text);
    font-family: "Nazanin", sans-serif;
    font-size: 0.95rem;
    padding: 10px 22px;
    border-radius: 999px;
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.4),
        inset 2px 2px 6px rgba(255, 255, 255, 0.08),
        inset -2px -2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: min(90vw, 420px);
    text-align: center;
}

.dg-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---------------------------------------------------------------
   End-round winner picker
--------------------------------------------------------------- */
.dg-winner-pick-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dg-winner-pick {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    background: var(--panel-strong);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    color: var(--text);
    font-family: "Nazanin", sans-serif;
    font-size: 1rem;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.06),
        inset -2px -2px 8px rgba(0, 0, 0, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease-out, background 0.2s, box-shadow 0.2s;
}

.dg-winner-pick svg {
    width: 1.15em;
    height: 1.15em;
}

.dg-winner-pick:hover {
    background: var(--panel);
}

.dg-winner-pick:active {
    transform: scale(0.97) translateY(1px);
}

.dg-winner-pick:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.dg-winner-pick.danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

body.light-theme .dg-winner-pick {
    background: #fff;
    border-color: rgba(109, 40, 217, 0.14);
    box-shadow:
        inset 2px 2px 5px rgba(255, 255, 255, 0.6),
        inset -2px -2px 8px rgba(70, 43, 124, 0.08),
        0 2px 6px rgba(70, 43, 124, 0.06);
}

body.light-theme .dg-winner-pick.danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ---------------------------------------------------------------
   Loading
--------------------------------------------------------------- */
.game-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60svh;
    font-size: 1.2rem;
    color: var(--muted);
}

/* ---------------------------------------------------------------
   Accessibility: visible keyboard focus
--------------------------------------------------------------- */
.dg-btn:focus-visible,
.dg-color-btn:focus-visible,
.dg-size-btn:focus-visible,
.dg-guess-accept:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.dg-input:focus-visible,
.dg-guess-input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------
   Motion preferences
--------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .dg-canvas-wrap,
    .dg-guess-item,
    .dg-chip,
    .dg-chip-close,
    .dg-chip-correct {
        animation: none;
    }
    .dg-btn,
    .dg-color-btn,
    .dg-size-btn,
    .dg-guess-accept,
    .dg-guess-item,
    .dg-toast,
    .dg-winner-pick,
    .dg-hud-btn,
    .dg-hud-tool,
    .dg-color-chip,
    .dg-chip-like,
    .dg-hud-endpick {
        transition: none;
    }
    .timer-bar-fill,
    .dg-timer-fill {
        transition: none !important;
    }
}

/* ---------------------------------------------------------------
   Tablet (≥641px)
--------------------------------------------------------------- */
@media (min-width: 641px) {
    .game-app {
        padding: 16px 24px calc(24px + env(safe-area-inset-bottom));
    }
    .panel {
        padding: 28px;
    }
    .dg-play-layout {
        gap: 20px;
    }
}

/* ---------------------------------------------------------------
   Desktop (≥1024px)
--------------------------------------------------------------- */
@media (min-width: 1024px) {
    .game-app {
        padding: 20px 28px calc(28px + env(safe-area-inset-bottom));
    }
    .dg-play-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
        gap: 24px;
    }
    .dg-guesses-panel {
        max-height: none;
        min-height: 320px;
    }
}

/* ---------------------------------------------------------------
   Phones in landscape: canvas + panel compact side by side
--------------------------------------------------------------- */
@media (orientation: landscape) and (max-width: 1023px) {
    .game-app {
        padding: 4px 14px calc(12px + env(safe-area-inset-bottom));
    }
    .dg-play-layout {
        grid-template-columns: minmax(0, 1fr) 260px;
        gap: 14px;
    }
    .dg-play-layout > div:first-child {
        min-width: 0;
    }
    .dg-canvas-wrap {
        margin-inline: auto;
        max-width: min(100%, calc((100svh - 300px) * 1.333));
    }
    .dg-timer-head {
        gap: 8px;
        margin-bottom: 6px;
    }
    .timer-bar-wrap {
        margin-bottom: 8px;
    }
    .dg-word-card {
        margin-bottom: 8px;
        padding: 12px;
    }
    .dg-toolbar {
        gap: 6px;
        padding: 8px;
    }
    .dg-toolbar .dg-btn.small {
        min-height: 44px;
        padding: 6px 12px;
    }
    .dg-guesses-panel {
        max-height: none;
    }
}

/* ---------------------------------------------------------------
   Short portrait phones (e.g. 375×667): tighten vertical rhythm
--------------------------------------------------------------- */
@media (max-width: 1023px) and (orientation: portrait) and (max-height: 700px) {
    .game-app {
        padding: 6px 12px calc(12px + env(safe-area-inset-bottom));
    }
    .panel {
        padding: 18px 14px;
    }
    .dg-canvas-wrap {
        margin-inline: auto;
        max-width: min(100%, calc((100svh - 300px) * 1.333));
    }
    .dg-timer-head {
        gap: 8px;
        margin-bottom: 6px;
    }
    .timer-bar-wrap {
        margin-bottom: 8px;
    }
    .dg-word-card {
        margin-bottom: 8px;
        padding: 12px;
    }
    .dg-toolbar {
        gap: 6px;
        padding: 8px;
    }
    .dg-toolbar .dg-btn.small {
        min-height: 44px;
        padding: 6px 12px;
    }
    .dg-guesses-panel {
        max-height: 34vh;
    }
    .dg-score-display {
        gap: 8px;
    }
}

/* ---------------------------------------------------------------
   Icon sizing for inline SVGs in buttons
--------------------------------------------------------------- */
.dg-btn svg {
    width: 1.25em;
    height: 1.25em;
    vertical-align: -0.25em;
}

.dg-guess-accept svg {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
}

/* ---------------------------------------------------------------
   Mobile (≤640px) — compact toolbar rows
--------------------------------------------------------------- */
@media (max-width: 640px) {
    .dg-toolbar {
        gap: 6px;
        padding: 10px;
    }
    .dg-tool-row {
        gap: 6px;
    }
    .dg-color-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        border-width: 2.5px;
    }
    .dg-size-btn {
        min-width: 38px;
        height: 38px;
    }
    .dg-toolbar .dg-btn.small {
        min-height: 40px;
        padding: 4px 10px;
        font-size: 0.85rem;
    }
    .dg-toolbar .dg-btn.small svg {
        width: 1.1em;
        height: 1.1em;
    }
    .dg-tool-divider {
        height: 20px;
    }
}

/* ---------------------------------------------------------------
   HUD mobile adjustments (≤640px) — compact edge toolbar
--------------------------------------------------------------- */
@media (max-width: 640px) {
    .dg-hud-toolbar {
        inset-inline-end: 8px;
        inset-inline-start: 8px;
        top: auto;
        bottom: calc(72px + env(safe-area-inset-bottom));
        transform: none;
        display: flex;
        grid-template-columns: none;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        padding: 8px;
        border-radius: 18px;
    }
    .dg-hud[data-role="drawer"] .dg-hud-stage {
        padding-inline-end: calc(14px + env(safe-area-inset-right));
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }
    .dg-tool-cluster {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    .dg-tool-cluster + .dg-tool-cluster {
        border-top: 0;
        border-inline-start: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 0;
        padding-inline-start: 8px;
    }
    .dg-hud-tool {
        width: 38px;
        height: 38px;
        min-width: 38px;
        border-radius: 3px;
    }
    .dg-hud-tool svg {
        width: 1em;
        height: 1em;
    }
    .dg-hud-tool-label {
        font-size: 0.6rem;
    }
    .dg-color-chip {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-width: 2px;
    }
    .dg-color-more {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    .dg-color-popover {
        left: 50%;
        right: auto;
        top: auto;
        bottom: calc(100% + 10px);
        transform: translateX(-50%);
        width: 170px;
    }
    .dg-hud-stage {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }
    .dg-canvas-frame {
        width: min(100%, calc((100svh - 280px) * 1.333));
        border-radius: 12px;
    }
    .dg-hud-top {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: 8px;
    }
    .dg-word-cell {
        font-size: 1.15rem;
    }
    .dg-round-chip {
        font-size: 0.75rem;
        padding: 4px 9px;
    }
    .dg-hud-top .dg-timer-seconds {
        font-size: 1.1rem;
        min-width: 36px;
    }
}
