/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    background: #0d3b1e;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0d3b1e 0%, #1a5c2e 50%, #0d3b1e 100%);
    color: #e8f5e9;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#app {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ========== SCREEN LAYOUT ========== */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== HOME SCREEN ========== */
.home-screen {
    justify-content: center;
    align-items: center;
    gap: 30px;
    padding: 40px 20px;
}

.logo {
    filter: drop-shadow(0 4px 15px rgba(0,0,0,0.4));
    animation: float 3s ease-in-out infinite;
    color: #a5d6a7;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.home-screen h1 {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* ========== HEADER ========== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title,
.header > h2 {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    white-space: nowrap;
    pointer-events: none;
}

.header-title h2,
.header > h2 {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    margin: 0;
    text-align: center;
}

.header-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
    font-weight: 500;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #fff;
    padding: 6px;
    margin-left: -6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-icon:active {
    background: rgba(255,255,255,0.15);
}

.btn-icon .ico {
    font-size: 24px;
}

.badge {
    background: #2ecc71;
    color: #000;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-header {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-header:active {
    background: rgba(255,255,255,0.3);
}

.btn-header .ico {
    font-size: 18px;
}

/* ========== CONTENT ========== */
.content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== BUTTONS ========== */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #000;
    box-shadow: 0 4px 15px rgba(46,204,113,0.3);
}

.btn-secondary {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-success {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    color: #000;
    box-shadow: 0 4px 15px rgba(241,196,15,0.3);
}

.btn-danger {
    background: rgba(255,171,162,0.15);
    color: #ffaba2;
    border: 1px solid rgba(255,171,162,0.3);
}

.btn-full { width: 100%; }
.btn-small {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 10px;
}

.btn-back {
    background: none;
    border: none;
    color: #2ecc71;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    -webkit-tap-highlight-color: transparent;
}

.btn-remove {
    background: rgba(231,76,60,0.2);
    border: none;
    color: #e74c3c;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #a5d6a7;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input:focus {
    border-color: #2ecc71;
    background: rgba(255,255,255,0.15);
}

.input::placeholder { color: rgba(255,255,255,0.4); }

.input-row {
    display: flex;
    gap: 10px;
}

.input-row .input { flex: 1; }

/* ========== PLAYER LIST (SETUP) ========== */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    font-size: 15px;
}

.hint {
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    margin-top: 15px;
}

/* ========== CHIPS FOR PLAYERS ========== */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.chip {
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.chip.active {
    background: #2ecc71;
    border-color: #2ecc71;
    color: #000;
    font-weight: bold;
}
.chip-delete {
    margin-left: 8px;
    color: rgba(255,255,255,0.4);
    font-weight: bold;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 50%;
}
.chip.active .chip-delete {
    color: rgba(0,0,0,0.5);
}
.chip-delete:hover {
    color: #ffaba2 !important;
    background: rgba(255,171,162,0.2);
}

/* ========== GAME TABLE (BOARD) ========== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom:5px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
}

.bottom-actions {
    margin-top: 20px;
    padding-top: 15px;
    display: flex;
    gap: 10px;
}
.bottom-actions .btn {
    flex: 1;
    margin-bottom: 0;
    padding: 12px 5px; /* slightly smaller padding to fit multiple buttons */
    font-size: 14px;
}

.game-table, .round-table, .history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.game-table thead th, .round-table thead th, .history-table thead th {
    background: rgba(0,0,0,0.35);
    color: #a5d6a7;
    padding: 10px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.game-table tbody tr, .history-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}

.game-table tbody tr:nth-child(even), .history-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.03);
}

/* ========== DRAG AND DROP ========== */
.drag-handle {
    color: rgba(255,255,255,0.3);
    cursor: grab;
    text-align: center;
    padding: 10px 5px !important;
}
.drag-handle:active {
    cursor: grabbing;
    color: #fff;
}
tr.dragging {
    background: rgba(46, 204, 113, 0.2) !important;
    opacity: 0.9;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}


.game-table tbody tr.clickable { cursor: pointer; }
.game-table tbody tr.clickable:active { background: rgba(46,204,113,0.15); }

.game-table td, .history-table td {
    padding: 12px 8px;
    text-align: center;
    vertical-align: middle;
}

.round-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.round-table td {
    padding: 8px 4px;
    vertical-align: middle;
}

td.player-name, th:first-child {
    text-align: left;
    font-weight: 600;
    padding-left: 12px;
    white-space: nowrap;
}

.center { text-align: center; }

.positive { color: #2ecc71; font-weight: 700; }
.negative { color: #ffaba2; font-weight: 700; }

.btn-edit-round {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    padding: 4px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-edit-round:active { background: rgba(46,204,113,0.2); }

/* ========== SVG ICONS ========== */
.ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    flex-shrink: 0;
}
.ico svg { width: 100%; height: 100%; }
.ico-lg { width: 80px; height: 80px; color: #a5d6a7; }
.ico-empty { width: 50px; height: 50px; opacity: 0.4; }

/* ========== ROUND FORM ELEMENTS ========== */
.winner-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
}

.winner-cell input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #2ecc71;
    cursor: pointer;
}

.select-small {
    padding: 6px 4px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    min-width: 55px;
}

.select-small:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.select-small option {
    background: #1a5c2e;
    color: #fff;
}

.input-small {
    width: 55px;
    padding: 6px 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    text-align: center;
    outline: none;
}

.input-small:focus { border-color: #2ecc71; }

/* ========== ROUND INFO ========== */
.round-info {
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.4);
    margin-bottom: 16px;
}

/* ========== HISTORY CARDS ========== */
.history-card {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.history-card:active {
    background: rgba(255,255,255,0.12);
    transform: scale(0.98);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-date {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.history-rounds {
    font-size: 12px;
    color: #a5d6a7;
}

.history-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-player {
    padding: 4px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.history-delete {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    background: #c90000;
    border-radius: 10px;    
}

.history-delete:hover { color:#ffa39a }

/* ========== EMPTY STATE ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
}

.empty-state-icon {
    font-size: 50px;
    opacity: 0.4;
}

.empty-state-text {
    font-size: 15px;
    color: rgba(255,255,255,0.4);
    text-align: center;
}

/* ========== BOTTOM ACTIONS ========== */
.bottom-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding:0;
    margin-top: auto;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ========== CONFIRM MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: #1a5c2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
}

.modal h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #fff;
}

.modal p {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.modal-buttons .btn { flex: 1; }

/* ========== RESPONSIVE: SMALL MOBILE ========== */
@media (max-width: 380px) {
    .game-table td, .game-table th { padding: 8px 4px; font-size: 12px; }
    .round-table td { padding: 6px 2px; }
    .select-small { font-size: 11px; min-width: 48px; padding: 5px 2px; }
    .input-small { width: 45px; padding: 5px 4px; font-size: 13px; }
    .player-name { font-size: 12px !important; }
}

/* ========== RESPONSIVE: TABLET & UP ========== */
@media (min-width: 600px) {
    .content { padding: 24px 32px; }

    .header { padding: 16px 32px; }
    .header h2 { font-size: 22px; }

    .home-screen { gap: 40px; }
    .logo { font-size: 100px; }
    .home-screen h1 { font-size: 36px; }
    .btn-group { max-width: 400px; }
    .btn { padding: 16px 32px; font-size: 18px; border-radius: 16px; }

    .form-group label { font-size: 15px; }
    .input { padding: 14px 18px; font-size: 17px; }

    .player-item { padding: 12px 18px; font-size: 16px; }

    .game-table td, .game-table th,
    .history-table td, .history-table th { padding: 14px 16px; font-size: 16px; }
    .game-table thead th, .history-table thead th { font-size: 13px; padding: 12px 16px; }

    .round-table td { padding: 12px 10px; }
    .select-small { font-size: 14px; min-width: 75px; padding: 8px 6px; }
    .input-small { width: 70px; padding: 8px 10px; font-size: 16px; }

    td.player-name { font-size: 16px; padding-left: 16px; }

    .history-card { padding: 18px 22px; }
    .history-date { font-size: 17px; }
    .history-rounds { font-size: 13px; }
    .history-player { font-size: 14px; padding: 5px 14px; }

    .round-info { font-size: 15px; }
    .badge { font-size: 13px; padding: 5px 14px; }
}

/* ========== RESPONSIVE: DESKTOP ========== */
@media (min-width: 800px) {
    .content { padding:4px; }
    .header { padding: 18px 48px; }
    .header h2 { font-size: 24px; }

    .home-screen { gap:10px; padding: 10px}
    .logo { font-size: 120px; }
    .home-screen h1 { font-size: 42px; }
    .btn-group { max-width: 450px; }
    .btn { padding: 18px 36px; font-size: 19px; }

    .game-table td, .game-table th,
    .history-table td, .history-table th { padding:5px 20px; font-size: 17px; }
    .game-table thead th, .history-table thead th { font-size: 14px; padding: 14px 20px; }

    .round-table td { padding:2px 12px; }
    .select-small { font-size: 15px; min-width: 90px; padding: 10px 8px; border-radius: 8px; }
    .input-small { width: 80px; padding: 10px 12px; font-size: 17px; border-radius: 8px; }

    td.player-name { font-size:20px; padding-left:15px; }

    .table-container { border-radius: 16px; }

    .winner-cell { gap: 8px; }
    .winner-cell input[type="checkbox"] { width: 22px; height: 22px; }

    .modal { max-width: 420px; padding: 32px; border-radius: 20px; }
    .modal h3 { font-size: 22px; }
    .modal p { font-size: 16px; }
}

/* ============================================================
   MARRIAGE CARD GAME STYLING
   ============================================================ */
.card-table-arena {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 24px;
}

.opponents-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 2px;
    -webkit-overflow-scrolling: touch;
}

.opp-badge {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    min-width: 105px;
    flex-shrink: 0;
}

.opp-badge.active-turn {
    border-color: #2ecc71;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
    background: rgba(46, 204, 113, 0.15);
}

.opp-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.opp-meta {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.table-felt {
    background: radial-gradient(circle at center, #1b5e20 0%, #0d381e 100%);
    border: 2px solid #2e7d32;
    border-radius: 16px;
    padding: 16px 12px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.6);
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: relative;
    min-height: 120px;
}

.felt-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.felt-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-deck-stack {
    width: 60px;
    height: 84px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: 2px solid #fff;
    border-radius: 8px;
    box-shadow: 2px 3px 6px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    transition: transform 0.15s;
}

.card-deck-stack:active {
    transform: scale(0.95);
}

.playing-card {
    width: 58px;
    height: 84px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    border: 1.5px solid #dcdde1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}

.playing-card.red {
    color: #e74c3c;
}

.playing-card.black {
    color: #2c3e50;
}

.playing-card.selected {
    transform: translateY(-12px);
    border: 2px solid #f1c40f;
    box-shadow: 0 6px 16px rgba(241, 196, 15, 0.6);
}

.playing-card.is-maal {
    border: 2px solid #e67e22;
    box-shadow: 0 0 10px rgba(230, 126, 34, 0.6);
}

.card-corner {
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-center-suit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    line-height: 1;
    pointer-events: none;
}

.maal-tag {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    background: #e67e22;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    text-transform: uppercase;
}

.hand-section {
    background: rgba(0,0,0,0.25);
    border-radius: 14px;
    padding: 10px 8px;
}

.hand-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 12px 2px 6px 2px;
}

.game-controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    justify-content: center;
}

.btn-game-action {
    flex: 1;
    min-width: 130px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
}

/* Card reordering and drag styles */
.playing-card.dragging {
    opacity: 0.6;
    transform: scale(1.12);
    box-shadow: 0 10px 24px rgba(0,0,0,0.6);
    z-index: 100;
    pointer-events: none !important;
}
.playing-card.drag-over {
    outline: 2px dashed #f1c40f !important;
    transform: scale(1.06);
}

/* Drawn card highlight & badge */
.playing-card.just-drawn {
    border: 2.5px solid #00d2d3 !important;
    animation: pulseDrawn 1.5s infinite;
}
@keyframes pulseDrawn {
    0% { box-shadow: 0 0 8px rgba(0, 210, 211, 0.6); }
    50% { box-shadow: 0 0 20px rgba(0, 210, 211, 1); }
    100% { box-shadow: 0 0 8px rgba(0, 210, 211, 0.6); }
}
.drawn-badge {
    position: absolute;
    top: -8px;
    right: -6px;
    background: #00d2d3;
    color: #0d2b1b;
    font-size: 8px;
    font-weight: 900;
    padding: 1px 5px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    text-transform: uppercase;
    z-index: 10;
    letter-spacing: 0.5px;
}

/* Hand reorder toolbar */
.hand-nudge-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(241, 196, 15, 0.15);
    border: 1px solid rgba(241, 196, 15, 0.4);
    border-radius: 8px;
    padding: 4px 8px;
    margin-bottom: 8px;
    gap: 6px;
}
.hand-nudge-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}
.hand-nudge-btn:active {
    background: #f1c40f;
    color: #000;
}

/* Declare Mode & Selection */
.playing-card.declare-selected {
    border: 2.5px solid #2ecc71 !important;
    box-shadow: 0 0 14px rgba(46, 204, 113, 0.8) !important;
    transform: translateY(-8px);
}
.declare-badge {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    background: #2ecc71;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
}

/* Public Declared Melds Section on Table */
.declared-melds-container {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 8px 10px;
}
.declared-melds-title {
    font-size: 12px;
    font-weight: 700;
    color: #f1c40f;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.player-declared-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.player-declared-row:last-child {
    border-bottom: none;
}
.player-declared-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    min-width: 80px;
    flex-shrink: 0;
}
.declared-cards-list {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Mini playing cards for public declared melds */
.mini-card {
    width: 32px;
    height: 46px;
    background: #ffffff !important;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    border: 1px solid #dcdde1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2px;
    box-sizing: border-box;
    user-select: none;
    flex-shrink: 0;
}
.mini-card.red { color: #e74c3c !important; }
.mini-card.black { color: #222222 !important; }
.mini-card-corner {
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
}
.mini-card-center {
    font-size: 14px;
    text-align: center;
    line-height: 1;
}

/* 3-Group Declare Selector Styles */
.declare-group-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    background: rgba(0,0,0,0.3);
    padding: 4px;
    border-radius: 10px;
}
.declare-group-tab {
    flex: 1;
    padding: 8px 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.8);
    transition: all 0.2s;
    user-select: none;
    touch-action: manipulation;
}
.declare-group-tab.tab-g1.active {
    background: #0984e3;
    border-color: #74b9ff;
    color: #fff;
    box-shadow: 0 0 10px rgba(9, 132, 227, 0.7);
}
.declare-group-tab.tab-g2.active {
    background: #6c5ce7;
    border-color: #a29bfe;
    color: #fff;
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.7);
}
.declare-group-tab.tab-g3.active {
    background: #00b894;
    border-color: #55efc4;
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.7);
}

.playing-card.in-g1 {
    border: 2.5px solid #0984e3 !important;
    box-shadow: 0 0 12px rgba(9, 132, 227, 0.8) !important;
    transform: translateY(-8px);
}
.playing-card.in-g2 {
    border: 2.5px solid #6c5ce7 !important;
    box-shadow: 0 0 12px rgba(108, 92, 231, 0.8) !important;
    transform: translateY(-8px);
}
.playing-card.in-g3 {
    border: 2.5px solid #00b894 !important;
    box-shadow: 0 0 12px rgba(0, 184, 148, 0.8) !important;
    transform: translateY(-8px);
}

.group-tag {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
}
.group-tag.tag-g1 { background: #0984e3; }
.group-tag.tag-g2 { background: #6c5ce7; }
.group-tag.tag-g3 { background: #00b894; }

/* Grouped display on table felt */
.declared-groups-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.declared-group-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 3px 5px;
}
.declared-group-title {
    font-size: 9px;
    font-weight: 800;
    color: #f1c40f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.declared-group-divider {
    color: rgba(255,255,255,0.3);
    font-size: 14px;
    font-weight: 900;
}

/* Your Hand: Multi-Row Wrapping with Overlapping Cards (NO horizontal scroll) */
#hand-scroll-container {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px 2px !important;
    box-sizing: border-box !important;
    gap: 10px !important;
}

.hand-card-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: flex-end !important;
    width: 100% !important;
    padding: 14px 4px 4px 4px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.hand-card-row .playing-card {
    width: 78px !important;
    height: 116px !important;
    border-radius: 9px !important;
    border: 1.5px solid #bdc3c7 !important;
    box-shadow: -2px 3px 7px rgba(0, 0, 0, 0.45) !important;
    margin-left: -48px !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 5px 6px !important;
    flex-shrink: 0 !important;
    position: relative !important;
    background: #ffffff !important;
    transition: transform 0.16s ease, box-shadow 0.16s ease !important;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.hand-card-row .playing-card:first-child {
    margin-left: 0 !important;
}

.hand-card-row .playing-card:hover {
    transform: translateY(-8px) !important;
}

.hand-card-row .playing-card.selected {
    transform: translateY(-20px) !important;
    border: 3px solid #f1c40f !important;
    box-shadow: 0 8px 22px rgba(241, 196, 15, 0.8), 0 0 10px #f1c40f !important;
}

.hand-card-row .playing-card.is-maal {
    border: 2.5px solid #e67e22 !important;
    box-shadow: -2px 0 8px rgba(230, 126, 34, 0.7), -2px 3px 6px rgba(0,0,0,0.4) !important;
}

.hand-card-row .playing-card.is-maal.selected {
    border: 3px solid #f1c40f !important;
    box-shadow: 0 8px 22px rgba(241, 196, 15, 0.8), 0 0 12px #e67e22 !important;
}

.hand-card-row .playing-card.just-drawn {
    border: 3px solid #00d2d3 !important;
    box-shadow: 0 0 14px rgba(0, 210, 211, 0.9) !important;
}

.playing-card.is-master,
.hand-card-row .playing-card.is-master,
.mini-card.is-master {
    background: #ffffff url('images/master.png') no-repeat center center !important;
    background-size: cover !important;
    border: none !important;
    box-shadow: 0 0 10px rgba(214, 48, 49, 0.5) !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.hand-card-row .card-corner {
    font-size: 20px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1px !important;
    width: 28px !important;
}

.hand-card-row .corner-rank {
    font-size: 20px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    letter-spacing: -0.5px !important;
}

.hand-card-row .corner-suit {
    font-size: 18px !important;
    line-height: 1 !important;
    margin-top: 1px !important;
}

.hand-card-row .card-center-suit {
    font-size: 40px !important;
    line-height: 1 !important;
    opacity: 0.9 !important;
}

.hand-card-row .maal-tag {
    font-size: 9px !important;
    font-weight: 800 !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    bottom: -6px !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5) !important;
}

.hand-card-row .drawn-badge {
    font-size: 8px !important;
    font-weight: 900 !important;
    padding: 2px 4px !important;
    top: -9px !important;
    right: -4px !important;
}

.corner-maal-star {
    font-size: 12px !important;
    color: #e67e22 !important;
    line-height: 1 !important;
    margin-top: 1px !important;
    font-weight: 900 !important;
}

@media (max-width: 420px) {
    .hand-card-row .playing-card {
        width: 72px !important;
        height: 108px !important;
        margin-left: -46px !important;
        padding: 4px 5px !important;
    }
    .hand-card-row .corner-rank {
        font-size: 18px !important;
    }
    .hand-card-row .corner-suit {
        font-size: 16px !important;
    }
    .hand-card-row .card-center-suit {
        font-size: 34px !important;
    }
}

@media (max-width: 350px) {
    .hand-card-row .playing-card {
        width: 66px !important;
        height: 100px !important;
        margin-left: -43px !important;
        padding: 3px 4px !important;
    }
    .hand-card-row .corner-rank {
        font-size: 16px !important;
    }
    .hand-card-row .corner-suit {
        font-size: 14px !important;
    }
    .hand-card-row .card-center-suit {
        font-size: 30px !important;
    }
}




