:root {
    --bg-app: #080c14;
    --bg-card: rgba(16, 22, 38, 0.65);
    --bg-card-hover: rgba(22, 32, 56, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --state-active: #00f2fe;
    --state-active-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --state-break: #ff0844;
    --state-break-gradient: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    --state-eliminated: #5f6b80;
    --state-eliminated-gradient: linear-gradient(135deg, #3a4150 0%, #5f6b80 100%);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --shadow-glow-active: 0 0 20px rgba(0, 242, 254, 0.25);
    --shadow-glow-break: 0 0 20px rgba(255, 8, 68, 0.25);
    --shadow-glow-alert: 0 0 25px rgba(255, 8, 68, 0.5);
    
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-clock: 'Share Tech Mono', monospace;
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Glassmorphism Styles */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Header layout */
.app-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    gap: 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(8, 12, 20, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.header-main {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.header-controls {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.app-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.spectator-badge {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
}

/* Master Clock Panel */
.clock-panel {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 16px 32px;
    gap: 24px;
}

.clock-section-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 180px;
}

.status-table-container {
    border-left: 1px solid var(--border-color);
    padding-left: 20px;
}

.status-table {
    border-collapse: collapse;
}

.status-table td {
    padding: 4px 8px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.status-table td strong {
    color: var(--text-primary);
    font-family: var(--font-clock);
    font-size: 14px;
    margin-left: 8px;
}

.clock-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.clock-display {
    font-family: var(--font-clock);
    font-size: 40px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    line-height: 1;
    margin: 4px 0;
}

.clock-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.clock-actions {
    display: flex;
    gap: 8px;
}

/* Container */
.app-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    padding: 32px 40px;
    gap: 32px;
    flex: 1;
}

.app-container.sidebar-hidden {
    grid-template-columns: 1fr;
}

.app-container.sidebar-hidden .sidebar-section {
    display: none;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

.grid-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.grid-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.grid-summary {
    display: flex;
    gap: 16px;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot.active { background-color: var(--state-active); }
.dot.break { background-color: var(--state-break); }
.dot.eliminated { background-color: var(--state-eliminated); }

/* Participants Grid */
.participants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* Card Styling */
.participant-card {
    position: relative;
    padding: 16px 20px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.participant-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--state-eliminated-gradient);
    transition: background 0.3s ease;
}

.participant-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Status specific card designs */
.participant-card.state-active::before {
    background: var(--state-active-gradient);
}
.participant-card.state-active {
    box-shadow: var(--shadow-glow-active);
    border-color: rgba(0, 242, 254, 0.2);
}

.participant-card.state-break::before {
    background: var(--state-break-gradient);
}
.participant-card.state-break {
    box-shadow: var(--shadow-glow-break);
    border-color: rgba(255, 8, 68, 0.2);
}

.participant-card.state-eliminated {
    opacity: 0.55;
}
.participant-card.state-eliminated .card-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Alert Flashing animation */
@keyframes pulse-alert {
    0% { box-shadow: 0 0 10px rgba(255, 8, 68, 0.3); border-color: rgba(255, 8, 68, 0.4); }
    50% { box-shadow: 0 0 25px rgba(255, 8, 68, 0.7); border-color: rgba(255, 8, 68, 0.8); }
    100% { box-shadow: 0 0 10px rgba(255, 8, 68, 0.3); border-color: rgba(255, 8, 68, 0.4); }
}

.participant-card.alert-active {
    animation: pulse-alert 1.5s infinite;
}

/* Card contents */
.card-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.card-right {
    display: flex;
    align-items: center;
}

.card-name {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.clickable-name {
    cursor: pointer;
    transition: color 0.2s ease;
}
.clickable-name:hover {
    color: var(--state-active);
    text-decoration: underline;
}

.card-status-text {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 99px;
}
.status-text-in_game {
    background: rgba(0, 242, 254, 0.1);
    color: var(--state-active);
}
.status-text-on_break {
    background: rgba(255, 8, 68, 0.1);
    color: var(--state-break);
}
.status-text-eliminated {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.quota-value {
    font-family: var(--font-clock);
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
}

.state-break .quota-value {
    color: #ff4e50;
    text-shadow: 0 0 8px rgba(255, 78, 80, 0.3);
}

.alert-active .quota-value {
    color: #ff3366;
    animation: blink-text 1s infinite;
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.quota-subtext {
    font-size: 11px;
    color: var(--text-muted);
}

/* Button styles */
.btn {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--state-active-gradient);
    color: #000000;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.2);
}
.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: var(--state-break-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(255, 8, 68, 0.2);
}
.btn-danger:hover {
    box-shadow: 0 4px 20px rgba(255, 8, 68, 0.4);
    transform: translateY(-1px);
}

.btn-end-break {
    color: #000000;
}

.btn-small {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-full {
    width: 100%;
}

/* Sidebar Section */
.sidebar-section {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    height: fit-content;
    max-height: calc(100vh - 170px);
    position: sticky;
    top: 138px;
}

@media (max-width: 1024px) {
    .sidebar-section {
        position: static;
        height: auto;
        max-height: none;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.activity-feed {
    flex: 1;
    min-height: 0;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.feed-placeholder {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    margin-top: 40px;
}

.feed-item {
    font-size: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.feed-time {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 10px;
}

.feed-desc {
    color: var(--text-primary);
    word-break: break-word;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.system-status {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.text-green {
    color: #10b981;
}

/* Dialog Styles */
dialog {
    margin: auto;
    background: none;
    border: none;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.glass-dialog {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
}

#correctionsDialog.glass-dialog {
    max-width: 800px;
}

.dialog-content {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.dialog-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.btn-close:hover {
    color: #ffffff;
}

.dialog-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 60vh;
}

.dialog-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Dialog Forms & Fields */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input, .form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 14px;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--state-active);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.2);
}

.form-help {
    font-size: 11px;
    color: var(--text-muted);
}

.dialog-tip {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Settings List in Dialog */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-row {
    display: grid;
    grid-template-columns: 40px 1fr 100px;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.settings-row.allow-delete {
    grid-template-columns: 40px 1fr 80px 40px;
}

.btn-settings-delete {
    padding: 6px;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.btn-settings-delete:hover {
    color: #ff3366;
    transform: scale(1.1);
}

.settings-row-id {
    font-weight: 800;
    color: var(--text-muted);
}

.settings-row input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 13px;
}

.settings-row input:focus {
    outline: none;
    border-color: var(--state-active);
}

/* Setup Dialog & List */
.setup-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 45vh;
    overflow-y: auto;
    padding-right: 4px;
    margin-top: 12px;
}

.setup-row {
    display: grid;
    grid-template-columns: 30px 1fr 80px 40px;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    animation: fadeIn 0.2s ease-out;
}

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

.setup-row-num {
    font-weight: 800;
    color: var(--text-muted);
}

.setup-row input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 13px;
    transition: border-color 0.2s ease;
}

.setup-row input:focus {
    outline: none;
    border-color: var(--state-active);
    box-shadow: 0 0 6px rgba(0, 242, 254, 0.15);
}

.btn-setup-delete {
    padding: 6px;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.btn-setup-delete:hover {
    color: #ff3366;
    transform: scale(1.1);
}

/* Input Validation Errors */
.setup-row input.input-error, .settings-row input.input-error {
    border-color: var(--state-break) !important;
    box-shadow: 0 0 8px rgba(255, 8, 68, 0.35) !important;
    background: rgba(255, 8, 68, 0.08) !important;
}

/* Corrections Grid Layout */
.corrections-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .corrections-grid {
        grid-template-columns: 1fr;
    }
}

.corrections-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.corrections-history h4, .corrections-add h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.event-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 4px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    font-size: 12px;
}

.history-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-type {
    font-weight: 700;
}
.history-item-type.CHECK_IN { color: var(--state-active); }
.history-item-type.CHECK_OUT { color: var(--state-break); }
.history-item-type.ELIMINATE { color: var(--state-eliminated); }

.history-item-time {
    color: var(--text-muted);
    font-family: monospace;
}

.history-item-actions {
    display: flex;
    gap: 6px;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--state-active);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    animation: slide-in 0.3s ease forwards;
    min-width: 250px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast.toast-danger {
    border-left-color: var(--state-break);
}

@keyframes slide-in {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}
