* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Hide content until role is determined */
.container.loading {
    visibility: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Lock Toggle */
.lock-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 16px;
    background: rgba(45, 55, 72, 0.8);
    border-radius: 8px;
    user-select: none;
}

.lock-toggle input {
    display: none;
}

.lock-slider {
    width: 40px;
    height: 22px;
    background: #4a5568;
    border-radius: 11px;
    position: relative;
    transition: background 0.2s;
}

.lock-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.lock-toggle input:checked + .lock-slider {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.lock-toggle input:checked + .lock-slider::after {
    transform: translateX(18px);
}

.lock-text {
    font-size: 0.9rem;
    color: #a0aec0;
    font-weight: 600;
}

.lock-toggle input:checked ~ .lock-text {
    color: #48bb78;
}

/* Locked button state */
#randomizeBtn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

#clearNumbersBtn.locked,
#clearBtn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.board-section {
    flex: 1;
    min-width: 600px;
}

.team-label {
    font-weight: bold;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #667eea;
}

.team-label.team-col {
    text-align: center;
    padding-left: 40px;
    margin-bottom: 10px;
}

.team-label.team-row {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    padding-right: 10px;
}

.grid-wrapper {
    display: flex;
    align-items: center;
}

.grid-container {
    display: grid;
    grid-template-columns: 40px repeat(10, 1fr);
    grid-template-rows: 40px repeat(10, 1fr);
    gap: 2px;
    background: #2d3748;
    padding: 2px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.corner-cell {
    background: #1a1a2e;
    border-radius: 8px 0 0 0;
}

.col-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.col-header:last-child {
    border-radius: 0 8px 0 0;
}

.row-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.row-header:last-of-type {
    border-radius: 0 0 0 8px;
}

.square {
    background: #1a1a2e;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
    text-align: center;
    padding: 4px;
    min-width: 50px;
    min-height: 50px;
    word-break: break-word;
    overflow: hidden;
}

.square:hover {
    filter: brightness(1.2);
    transform: scale(1.05);
    z-index: 10;
}

.square.filled {
    font-weight: 600;
}

.square.winner {
    outline: 3px solid #f6e05e;
    outline-offset: -3px;
    animation: pulse 1s infinite;
}

.square.winner::after {
    content: '🏆';
    position: absolute;
    font-size: 0.6rem;
    top: 2px;
    right: 2px;
}

.square {
    position: relative;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.square:last-child {
    border-radius: 0 0 8px 0;
}

/* Sidebar */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.score-feed, .payouts-section {
    background: rgba(45, 55, 72, 0.8);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.score-feed h2, .payouts-section h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.team-score {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.team-name {
    font-size: 0.875rem;
    color: #a0aec0;
    margin-bottom: 5px;
}

.score {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
}

.score-divider {
    font-size: 2rem;
    color: #4a5568;
}

.quarter-info {
    text-align: center;
    padding: 10px;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    margin-bottom: 15px;
}

.score-controls {
    text-align: center;
}

.payout-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payout-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.payout-item.final {
    background: linear-gradient(135deg, rgba(246, 224, 94, 0.2) 0%, rgba(236, 201, 75, 0.2) 100%);
    border: 1px solid rgba(246, 224, 94, 0.3);
}

.quarter-label {
    font-weight: bold;
    width: 50px;
    color: #667eea;
}

.winner {
    flex: 1;
    text-align: center;
    color: #a0aec0;
}

.winner:not(:empty):not([data-empty]) {
    color: #48bb78;
}

.amount {
    font-weight: bold;
    color: #48bb78;
}

.total-pot {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #4a5568;
    font-size: 1.2rem;
    font-weight: bold;
}

#totalPotDisplay {
    color: #f6e05e;
}

/* Settings Section */
.settings-section {
    background: rgba(45, 55, 72, 0.8);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.settings-section h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: #a0aec0;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Tooltip */
.tooltip-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    color: #a0aec0;
    transition: color 0.2s;
}

.tooltip-icon:hover,
.tooltip-icon:focus {
    color: #667eea;
    outline: none;
}

.tooltip-icon svg {
    display: block;
}

.tooltip-content {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    padding: 12px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: normal;
    color: #e2e8f0;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    text-align: left;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #2d3748;
}

.tooltip-icon:hover .tooltip-content,
.tooltip-icon:focus .tooltip-content {
    opacity: 1;
    visibility: visible;
}

.tooltip-content strong {
    color: #667eea;
}

/* Segmented Control for Payoff Type */
.segmented-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 4px;
    gap: 0;
}

.segmented-control input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented-control .segment {
    position: relative;
    z-index: 2;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: #a0aec0;
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s;
    user-select: none;
}

.segmented-control .segment:hover {
    color: #e2e8f0;
}

.segmented-control input[type="radio"]:checked + input + label:first-of-type,
.segmented-control input[type="radio"]:first-of-type:checked ~ label:first-of-type {
    color: #fff;
}

.segmented-control input[type="radio"]:last-of-type:checked ~ label:last-of-type {
    color: #fff;
}

.segment-highlight {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    transition: transform 0.2s ease;
    z-index: 1;
}

.segmented-control input[type="radio"]:last-of-type:checked ~ .segment-highlight {
    transform: translateX(100%);
}

/* Disabled state for non-admins */
.segmented-control.disabled .segment {
    cursor: default;
    pointer-events: none;
}

.segmented-control.disabled {
    opacity: 0.7;
}

/* Setting text input */
.setting-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.setting-input:focus {
    outline: none;
    border-color: #667eea;
}

.setting-input:disabled {
    color: #a0aec0;
    cursor: default;
}

.pot-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0 12px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.pot-input-wrapper:focus-within {
    border-color: #667eea;
}

.currency-symbol {
    color: #48bb78;
    font-weight: bold;
    font-size: 1.1rem;
}

.pot-input-wrapper input[type="number"] {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 8px;
    color: #e2e8f0;
    font-size: 1rem;
    width: 100%;
}

.pot-input-wrapper input[type="number"]:focus {
    outline: none;
}

.pot-input-wrapper input[type="number"]:disabled {
    color: #a0aec0;
    cursor: default;
}

/* Hide number input spinners */
.pot-input-wrapper input[type="number"]::-webkit-outer-spin-button,
.pot-input-wrapper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pot-input-wrapper input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Setting display (read-only values) */
.setting-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.setting-display .setting-label {
    margin-bottom: 0;
}

.setting-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #f6e05e;
}

/* Modal for entering names */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #2d3748;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #4a5568;
    border-radius: 8px;
    background: #1a1a2e;
    color: white;
}

.modal-content input:focus {
    outline: none;
    border-color: #667eea;
}

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

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

.btn-secondary {
    background: #4a5568;
}

.btn-danger {
    background: linear-gradient(135deg, #fc8181 0%, #e53e3e 100%);
}

.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.4);
}

.btn-blue {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}

.btn-blue:hover {
    box-shadow: 0 4px 15px rgba(66, 153, 225, 0.4);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .board-section {
        min-width: auto;
        width: 100%;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .score-feed, .payouts-section, .settings-section {
        flex: 1;
        min-width: 280px;
    }
}

@media (max-width: 600px) {
    .square {
        min-width: 35px;
        min-height: 35px;
        font-size: 0.6rem;
    }
    
    .col-header, .row-header {
        font-size: 0.9rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
}

/* Share Modal */
.share-modal-content {
    max-width: 500px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #a0aec0;
}

.form-group input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #4a5568;
    border-radius: 8px;
    background: #1a1a2e;
    color: white;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input.input-locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #12121f;
}

.share-lock-section {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.share-lock-section .lock-toggle {
    margin: 0;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a0aec0;
}

.password-toggle:hover {
    opacity: 1;
}

.eye-icon {
    width: 20px;
    height: 20px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #718096;
    font-size: 0.8rem;
}

.share-links {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.link-copy {
    display: flex;
    gap: 10px;
}

.link-copy input {
    flex: 1;
    font-size: 0.85rem;
}

/* Role Indicator */
.role-indicator {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 10px;
}

.role-indicator.admin {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.role-indicator.player {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
}

.role-indicator.guest {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
}

/* Modal close button */
.modal-close-btn {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid #2d3748;
    border-radius: 50%;
    font-size: 1.2rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-close-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.modal-content {
    position: relative;
}

/* Share warning */
.share-warning {
    color: #f6ad55;
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(246, 173, 85, 0.1);
    border: 1px solid rgba(246, 173, 85, 0.3);
    border-radius: 8px;
}

/* Access Modal */
.access-modal-content {
    max-width: 400px;
    text-align: center;
}

.access-modal-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.access-description {
    color: #a0aec0;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.role-toggle {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

.toggle-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.toggle-option:hover {
    background: rgba(102, 126, 234, 0.2);
}

.toggle-option input[type="radio"] {
    display: none;
}

.toggle-option input[type="radio"]:checked + .toggle-label {
    color: #667eea;
}

.toggle-option:has(input:checked) {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

.toggle-label {
    font-weight: 600;
    font-size: 1rem;
}

.access-error {
    background: rgba(229, 62, 62, 0.2);
    border: 1px solid #e53e3e;
    color: #fc8181;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* Share note */
.share-note {
    color: #a0aec0;
    font-size: 0.9rem;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.toast-notification.success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.toast-notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Player Save Button */
#playerSaveBtn {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    transition: all 0.2s;
}

#playerSaveBtn.has-changes {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    animation: pulseGlow 2s infinite;
}

#playerSaveBtn:disabled {
    opacity: 0.7;
    cursor: default;
    transform: none;
    box-shadow: none;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(72, 187, 120, 0.5); }
    50% { box-shadow: 0 0 20px rgba(72, 187, 120, 0.8); }
}

/* Save Confirmation Modal */
.save-confirm-content {
    max-width: 450px;
    text-align: center;
}

.save-confirm-warning {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.save-confirm-note {
    color: #a0aec0;
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(246, 173, 85, 0.1);
    border: 1px solid rgba(246, 173, 85, 0.3);
    border-radius: 8px;
}

.save-confirm-note strong {
    color: #f6ad55;
}
