/* Base & Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #111827;
    color: #e5e7eb;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    touch-action: manipulation;
}

/* App Layout */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

#hhh-header {
    height: 40px;
    background-color: #1f2937;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

#header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#header-brand {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}

.beta-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background-color: #eab308;
    color: #1f2937;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

#header-sep {
    color: #4b5563;
    font-size: 16px;
}

#header-mode-label {
    font-size: 14px;
    font-weight: 600;
    color: #9ca3af;
}

#header-buttons {
    display: flex;
    gap: 8px;
}

#btn-gear,
#btn-fullscreen,
#btn-new-hand {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-gear:hover,
#btn-fullscreen:hover,
#btn-new-hand:hover {
    color: #e5e7eb;
}

#btn-fullscreen {
    font-size: 20px;
}

/* Screen Management */
.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* Board Entry Screen */
#screen-board {
    padding: 12px;
    align-items: center;
    justify-content: space-evenly;
}

#board-slots {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.board-slot {
    width: 56px;
    height: 78px;
    border-radius: 6px;
    background-color: #374151;
    border: 2px solid #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    transition: all 0.2s;
}

.board-slot.active {
    border-color: #eab308;
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.5);
}

.board-slot.filled {
    background-color: #faf8f0;
    color: #1f2937;
}

.board-slot.skipped {
    background-color: #374151;
    border: 2px dashed #6b7280;
    color: #6b7280;
}

.board-slot.unknown-suit {
    background-color: #faf8f0;
    color: #6b7280;
}

.board-slot.unknown-rank {
    background-color: #faf8f0;
    color: #6b7280;
}

.slot-content {
    line-height: 1;
}

/* Card Grid */
#board-card-grid,
#hc-card-grid,
#card-edit-grid {
    width: 100%;
    align-self: stretch;
}

.card-grid {
    display: grid;
    grid-template-columns: 24px repeat(13, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
}

.card-grid-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    min-height: 34px;
}

.card-grid-label[data-suit="S"] { color: #94a3b8; }
.card-grid-label[data-suit="H"] { color: #fca5a5; }
.card-grid-label[data-suit="D"] { color: #93c5fd; }
.card-grid-label[data-suit="C"] { color: #86efac; }

.card-grid-cell {
    min-height: 34px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 3px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.card-grid-cell:active {
    transform: scale(0.92);
}

.card-grid-cell[data-suit="S"] {
    background-color: #334155;
    color: #e2e8f0;
}

.card-grid-cell[data-suit="H"] {
    background-color: #991b1b;
    color: #fca5a5;
}

.card-grid-cell[data-suit="D"] {
    background-color: #1e40af;
    color: #93c5fd;
}

.card-grid-cell[data-suit="C"] {
    background-color: #14532d;
    color: #86efac;
}

.card-grid-cell.card-used {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.card-usage-label {
    position: absolute;
    bottom: 0;
    right: 1px;
    font-size: 8px;
    font-weight: 700;
    color: #fbbf24;
    line-height: 1;
}

.card-grid-cell.card-disabled {
    opacity: 0.2;
    cursor: not-allowed;
    pointer-events: none;
}

/* Card extras row (?, skip buttons) */
.card-extras {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.card-unknown-btn {
    width: 44px;
    height: 38px;
    background-color: #4b5563;
    border: 2px solid #6b7280;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.card-unknown-btn:hover {
    background-color: #6b7280;
}

.skip-btn {
    width: 44px;
    height: 38px;
    background-color: #4b5563;
    border: 2px solid #6b7280;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.skip-btn:hover {
    background-color: #6b7280;
}

#board-hint {
    font-size: 14px;
    color: #9ca3af;
    text-align: center;
}

/* ============================================================
   TABLE ACTION SCREEN
   ============================================================ */

#screen-table {
    padding: 0;
}

/* Table Phase Management */
.table-phase {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.table-phase.active {
    display: flex;
}

.btn-edit-board {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 1;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.btn-edit-board:hover {
    color: #e5e7eb;
}

#eff-stack-row {
    position: absolute;
    top: 6px;
    right: 56px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

#eff-stack-warn {
    color: #eab308;
    font-size: 16px;
    line-height: 1;
}

#eff-stack-auto {
    color: #eab308;
    font-size: 13px;
}

#eff-stack-group {
    display: flex;
    align-items: center;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 4px;
    overflow: hidden;
}

#eff-stack-input {
    width: 58px;
    height: 30px;
    background: transparent;
    border: none;
    color: #e5e7eb;
    font-size: 13px;
    padding: 0 6px;
    text-align: right;
}

#eff-stack-input:focus {
    outline: none;
}

#eff-stack-group:focus-within {
    border-color: #eab308;
}

#eff-stack-label {
    color: #6b7280;
    font-size: 12px;
    padding: 0 6px 0 2px;
    user-select: none;
}

/* ============================================================
   STREET PROGRESS
   ============================================================ */

#street-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    flex-shrink: 0;
}

.street-indicator {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
}

.street-indicator.active {
    background-color: #eab308;
    color: #1f2937;
}

.street-indicator.completed {
    color: #22c55e;
}

.street-separator {
    color: #4b5563;
    font-size: 14px;
}

/* ============================================================
   POSITION GRID
   ============================================================ */

#position-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: center;
    padding: 8px 12px;
    flex: 1;
    align-items: center;
    overflow: hidden;
}

.position-btn {
    flex: 0 1 86px;
    min-width: 44px;
    min-height: 52px;
    background-color: #1f2937;
    border: 2px solid #374151;
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.position-btn:hover {
    background-color: #293548;
}

.position-btn.selected {
    border-color: #eab308;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
}

.position-btn.acted-fold {
    background-color: #991b1b;
    opacity: 0.5;
}

.position-btn.acted-prior {
    opacity: 0.5;
}

.position-btn.acted-check {
    background-color: #166534;
}

.position-btn.acted-call {
    background-color: #1e40af;
}

.position-btn.acted-bet {
    background-color: #9333ea;
}

.position-btn.acted-raise {
    background-color: #c2410c;
}

.position-btn.acted-straddle {
    background-color: #b45309;
}

.position-btn.acted-allin {
    background-color: #dc2626;
}

.position-btn.acted-allin.acted-prior {
    opacity: 0.5;
}

.position-btn.is-hero {
    border-left: 4px solid #eab308;
}

.position-btn.is-hero.selected {
    border-color: #eab308;
    border-left-width: 4px;
}

.pos-label {
    font-size: 13px;
    font-weight: 700;
    color: #eab308;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
}

.pos-action {
    font-size: 11px;
    color: #d1d5db;
    margin-top: 2px;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ============================================================
   ACTION BAR
   ============================================================ */

#action-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    padding: 8px 12px;
    background-color: #1f2937;
    border-top: 1px solid #374151;
    flex-shrink: 0;
}

.action-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover:not(.action-disabled) {
    transform: scale(1.05);
}

.action-btn.action-disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.action-btn.btn-fold {
    background-color: #991b1b;
    color: #fca5a5;
}

.action-btn.btn-fold:hover {
    background-color: #7f1d1d;
}

.action-btn.btn-checkcall.btn-check-mode {
    background-color: #166534;
    color: #86efac;
}

.action-btn.btn-checkcall.btn-check-mode:hover {
    background-color: #14532d;
}

.action-btn.btn-checkcall.btn-call-mode {
    background-color: #1e40af;
    color: #93c5fd;
}

.action-btn.btn-checkcall.btn-call-mode:hover {
    background-color: #1e3a8a;
}

.action-btn.btn-betraise {
    background-color: #9333ea;
    color: #e9d5ff;
}

.action-btn.btn-betraise:hover {
    background-color: #7e22ce;
}

.action-btn.btn-allin {
    background-color: #dc2626;
    color: #ffffff;
}

.action-btn.btn-allin:hover {
    background-color: #b91c1c;
}

.action-btn.btn-straddle {
    background-color: #b45309;
    color: #fde68a;
}

.action-btn.btn-straddle:hover {
    background-color: #92400e;
}

.action-btn.btn-hero {
    background-color: #eab308;
    color: #1f2937;
}

.action-btn.btn-hero:hover {
    background-color: #d97706;
}

.action-btn.btn-undo {
    background-color: #6b7280;
    color: #d1d5db;
}

.action-btn.btn-undo:hover {
    background-color: #4b5563;
}

.btn-advance {
    padding: 0 16px;
    height: 48px;
    background-color: #3b82f6;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-advance:hover {
    background-color: #2563eb;
}

.btn-back {
    padding: 0 16px;
    height: 48px;
    background-color: #d97706;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background-color: #b45309;
}

/* ============================================================
   INLINE AMOUNT INPUT
   ============================================================ */

#inline-amount {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    align-items: center;
    justify-content: center;
    background-color: #111827;
    border-top: 1px solid #374151;
    flex-shrink: 0;
}

#inline-amount-input {
    width: 140px;
    padding: 10px 12px;
    background-color: #374151;
    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 16px;
}

#inline-amount-input:focus {
    outline: none;
    border-color: #eab308;
}

/* ============================================================
   HOLE CARD ENTRY
   ============================================================ */

#hole-card-entry {
    align-items: center;
    justify-content: space-evenly;
    padding: 12px;
}

#hc-header {
    font-size: 16px;
    font-weight: 600;
    color: #eab308;
    text-align: center;
}

#hc-player-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.hc-player-btn.hc-folded {
    opacity: 0.5;
    border-style: dashed;
}

.hc-player-btn.hc-entered {
    background-color: #14532d;
    border-color: #374151;
}

.hc-player-btn.hc-entered.selected {
    background-color: #1f2937;
    border-color: #eab308;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
}

#hc-card-slots {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.hc-slot {
    width: 48px;
    height: 68px;
    border-radius: 6px;
    background-color: #374151;
    border: 2px solid #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.2s;
}

.hc-slot.active {
    border-color: #eab308;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
}

.hc-slot.filled {
    background-color: #faf8f0;
    color: #1f2937;
}

.hc-slot.skipped {
    background-color: #374151;
    border: 2px dashed #6b7280;
    color: #6b7280;
}

.hc-slot.unknown-suit {
    background-color: #faf8f0;
    color: #6b7280;
}

#hc-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#btn-hc-skip {
    padding: 10px 24px;
    background-color: #4b5563;
    border: none;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-hc-skip:hover {
    background-color: #6b7280;
}

/* ============================================================
   WINNER ENTRY
   ============================================================ */

#winner-entry {
    align-items: center;
    justify-content: center;
    padding: 12px;
    gap: 16px;
}

#winner-header {
    font-size: 16px;
    font-weight: 600;
    color: #eab308;
    text-align: center;
}

#winner-player-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.winner-player-btn {
    min-width: 44px;
    flex-shrink: 1;
    min-height: 48px;
    background-color: #1f2937;
    border: 2px solid #374151;
    border-radius: 8px;
    padding: 6px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #e5e7eb;
}

.winner-player-btn:hover {
    background-color: #293548;
}

.winner-player-btn.winner-selected {
    border-color: #eab308;
    background-color: #422006;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.4);
    color: #eab308;
}

#winner-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: #1f2937;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #374151;
    display: flex;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #d1d5db;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    background-color: #374151;
    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: #eab308;
}

.settings-section-label {
    font-size: 13px;
    font-weight: 700;
    color: #eab308;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 20px;
    margin-bottom: 12px;
    padding-top: 12px;
    border-top: 1px solid #374151;
}

.form-group-checkbox {
    margin-bottom: 10px;
}

.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #d1d5db;
    cursor: pointer;
    min-height: 44px;
    padding: 4px 0;
}

.form-group-checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: #eab308;
    cursor: pointer;
    flex-shrink: 0;
}

.settings-note {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    margin-top: 12px;
    line-height: 1.4;
}

.btn-primary {
    padding: 10px 24px;
    background-color: #eab308;
    border: none;
    border-radius: 6px;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background-color: #d97706;
}

.btn-secondary {
    padding: 10px 24px;
    background-color: #4b5563;
    border: none;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #6b7280;
}

/* ============================================================
   HAND HISTORY MODAL
   ============================================================ */

.modal-content-wide {
    max-width: 520px;
}

#hand-history-text {
    width: 100%;
    padding: 12px;
    background-color: #111827;
    border: 1px solid #4b5563;
    border-radius: 6px;
    color: #e5e7eb;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

#hand-history-text:focus {
    outline: none;
    border-color: #eab308;
}

/* ============================================================
   COMMUNITY CARDS (Table Action Mode)
   ============================================================ */

#community-cards {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 12px;
    flex-shrink: 0;
    min-height: 44px;
}

.community-card {
    width: 40px;
    height: 56px;
    border-radius: 4px;
    background-color: #374151;
    border: 2px solid #4b5563;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.community-card.filled {
    background-color: #faf8f0;
    color: #1f2937;
}

.community-card.skipped {
    background-color: #374151;
    border: 2px dashed #6b7280;
    color: #6b7280;
}

.community-card.unknown-suit {
    background-color: #faf8f0;
    color: #6b7280;
}

.community-card.dimmed {
    opacity: 0.25;
    cursor: default;
    pointer-events: none;
}

.community-cards-preflop-hint {
    font-size: 11px;
    color: #4b5563;
    font-style: italic;
}

/* ============================================================
   CARD EDIT MODAL
   ============================================================ */

.modal-content-fullwidth {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
}

#card-edit-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    gap: 6px;
}

/* Production version badge */
.version-badge {
    position: fixed;
    bottom: 8px;
    right: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 11px;
    font-family: monospace;
    pointer-events: none;
    user-select: none;
    z-index: 9999;
}
