/* === DIALOGS === */
dialog {
    border: none; border-radius: 14px; padding: 0;
    background: linear-gradient(180deg, #1e3328, #162820);
    color: var(--text); max-width: 340px; width: 90%;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
    font-family: inherit;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
dialog::backdrop {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.dialog-content { padding: 22px 20px; text-align: center; }
#discard-dialog .dialog-content { padding: 10px 16px 16px; }
#discard-dialog .dialog-header { font-size: 0.75rem; margin-bottom: 6px; letter-spacing: 1.5px; text-transform: uppercase; }
.dialog-header {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem; font-weight: 700;
    color: var(--gold-light); margin-bottom: 14px;
}
.dialog-content p { margin-bottom: 16px; opacity: 0.7; font-size: 0.88rem; line-height: 1.5; }

.dialog-seed-display {
    background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px; padding: 8px 12px; margin-bottom: 10px;
    display: flex; align-items: center; justify-content: space-between;
}
.dialog-label, .seed-history-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.dialog-seed-display code { font-family: monospace; font-size: 0.95rem; font-weight: 600; color: var(--gold-light); flex: 1; }
.seed-copy-btn.dialog-btn { padding: 4px 8px; font-size: 1rem; margin: 0; min-width: auto; line-height: 1; }

.dialog-content input[type="text"] {
    width: 100%; padding: 9px 12px; border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.2);
    color: var(--text); font-size: 1rem; font-family: monospace;
    margin-bottom: 14px; outline: none;
}
.dialog-content input[type="text"]:focus { border-color: var(--gold); }

/* New Game Dialog */
.newgame-seed-row {
    display: flex; gap: 6px; align-items: center; margin-bottom: 14px;
}
.newgame-seed-row input[type="text"] { margin-bottom: 0; flex: 1; }
.newgame-paste-btn.dialog-btn { padding: 9px 10px; font-size: 1rem; margin: 0; min-width: auto; line-height: 1; flex-shrink: 0; }
#newgame-seed-dialog { max-width: 260px; }
.newgame-actions { flex-wrap: wrap; gap: 8px; }
.newgame-actions .dialog-btn { flex: 1; min-width: 100%; }

/* Seed History */
.seed-history-section { margin-bottom: 14px; }
.seed-history-label {
    text-align: left; margin-bottom: 6px;
}
.seed-history-list {
    max-height: 220px; overflow-y: auto; display: flex;
    flex-direction: row; flex-wrap: wrap; gap: 5px 4px;
    -webkit-overflow-scrolling: touch;
}
.seed-history-item {
    display: flex; align-items: center; gap: 3px; padding: 4px 5px;
    background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.06);
    border-radius: 5px; cursor: pointer; transition: background 0.15s;
    font-family: inherit; color: var(--text); width: calc(20% - 4px); text-align: left;
    min-width: 0;
}
.seed-history-item:active { background: rgba(255,255,255,0.1); transform: scale(0.96); }
.sh-emoji { font-size: 0.5rem; flex-shrink: 0; line-height: 1; }
.sh-code { font-family: monospace; font-size: 0.68rem; font-weight: 600; color: var(--gold-light); overflow: hidden; text-overflow: ellipsis; }
.seed-history-list::-webkit-scrollbar { width: 4px; }
.seed-history-list::-webkit-scrollbar-track { background: transparent; }
.seed-history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.dialog-actions { display: flex; gap: 8px; justify-content: center; }
.dialog-btn {
    border: none; border-radius: 7px; padding: 9px 18px;
    font-size: 0.82rem; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: transform 0.1s;
}
.dialog-btn:active { transform: scale(0.96); }
.dialog-btn.primary {
    background: linear-gradient(180deg, var(--gold), #9a7830);
    color: #1a1a1a; box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.dialog-btn.secondary {
    background: rgba(255,255,255,0.08); color: var(--text-dim);
    border: 1px solid rgba(255,255,255,0.1);
}
.gameover-icon { font-size: 1.6rem; margin-bottom: 4px; letter-spacing: 4px; }
#gameover-dialog .dialog-actions { flex-direction: column; }
#gameover-dialog::backdrop { background: rgba(0,0,0,0.25); backdrop-filter: none; -webkit-backdrop-filter: none; }

/* === DISCARD GRID === */
.discard-grid {
    --dg-cell-h: clamp(26px, calc((100dvh - 80px) / 15), 44px);
    --dg-cell-w: calc(var(--dg-cell-h) * 1.35);
    display: grid;
    grid-template-columns: 22px repeat(4, var(--dg-cell-w));
    gap: 3px;
    margin-bottom: 4px;
    justify-content: center;
}

.dg-header {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem); font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 2px 0;
}
.dg-header.h-hearts   { color: var(--suit-hearts); }
.dg-header.h-spades   { color: var(--suit-spades); }
.dg-header.h-diamonds { color: var(--suit-diamonds); }
.dg-header.h-clubs    { color: var(--suit-clubs); }

.dg-rank-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(0.65rem, 1.8vw, 0.85rem); font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim);
}

.dg-cell {
    width: var(--dg-cell-w); height: var(--dg-cell-h);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(0.85rem, 2.5vw, 1.1rem); font-weight: 700;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.1);
}
.dg-cell.empty {
    opacity: 0.15;
}
.dg-cell.filled {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.12);
}
.dg-cell.filled.hearts   { color: var(--suit-hearts); }
.dg-cell.filled.spades   { color: var(--suit-spades); }
.dg-cell.filled.diamonds { color: var(--suit-diamonds); }
.dg-cell.filled.clubs    { color: var(--suit-clubs); }
.dg-cell.on-table {
    opacity: 0.5;
    font-size: clamp(0.7rem, 2vw, 0.95rem);
}
.dg-cell.ace-check {
    font-size: clamp(0.75rem, 2.2vw, 1rem);
}

/* === SETTINGS === */
.settings-list { text-align: left; }
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.settings-row:last-of-type { border-bottom: none; }
.settings-label { font-size: 0.85rem; font-weight: 500; }
.settings-toggle {
    display: flex; gap: 0;
    background: rgba(0,0,0,0.25);
    border-radius: 6px; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.toggle-opt {
    border: none; background: transparent;
    color: var(--text-dim); font-size: 0.75rem; font-weight: 500;
    font-family: inherit; padding: 6px 12px;
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.toggle-opt.active {
    background: rgba(201,168,76,0.25);
    color: var(--gold-light); font-weight: 600;
}
.toggle-opt:active { transform: scale(0.95); }
.settings-toggle.triple .toggle-opt { padding: 6px 10px; }
.settings-divider {
    border: none; border-top: 1px solid rgba(255,255,255,0.08);
    margin: 8px 0;
}
.settings-about { text-align: center; padding: 8px 0 4px; }
.settings-about-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem; font-weight: 700; font-style: italic;
    color: var(--gold-light); margin-bottom: 2px;
}
.settings-about-version { font-size: 0.72rem; color: var(--text-dim); margin-bottom: 4px; }
.settings-about-dev { font-size: 0.72rem; color: var(--text-dim); opacity: 0.7; }
#settings-dialog { max-width: 300px; }

/* === HELP === */
.help-body {
    text-align: left; font-size: 0.82rem; line-height: 1.45;
    color: var(--text); opacity: 0.85;
    max-height: 80dvh; overflow-y: auto;
    padding-right: 4px;
}
.help-body b {
    color: var(--gold-light); display: inline-block;
    margin-top: 2px; font-size: 0.84rem;
}
.help-body b:first-child { margin-top: 0; }
.help-body hr {
    border: none; border-top: 1px solid rgba(255,255,255,0.1);
    margin: 5px 0;
}
