:root {
    --bg: #0f1117;
    --card-bg: #1a1d27;
    --border: #2a2d3a;
    --text: #e1e4ed;
    --text-secondary: #8b90a0;
    --accent: #6c8cff;
    --accent-hover: #809cff;
    --online: #34d399;
    --offline: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --transition: 0.2s ease;
    --unavailable: #f97316;
    --frost-bg: rgba(15, 17, 23, 0.55);
    --frost-bg-strong: rgba(15, 17, 23, 0.7);
    --frost-border: rgba(255, 255, 255, 0.08);
    --frost-blur: blur(14px) saturate(140%) brightness(0.9);
    --frost-highlight: rgba(255, 255, 255, 0.06);
    --frost-gradient: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.01) 45%,
        rgba(255, 255, 255, 0.03) 100%
    );
    --frost-shadow: inset 0 1px 0 var(--frost-highlight),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.4);
}

.dashboard {
    position: relative;
    z-index: 1;
    transition: opacity 0.4s ease;
    will-change: transform, opacity;
}

body:has(.info-badge:hover) .dashboard {
    opacity: 0;
}

body.ui-hidden .dashboard {
    opacity: 0;
    pointer-events: none;
}

body.ui-hidden .info-badge {
    opacity: 0;
}

body.ui-hidden .reload-badge {
    opacity: 0;
    pointer-events: none;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(1000px 700px at 20% 20%, rgba(108, 140, 255, 0.10), transparent 60%),
        radial-gradient(800px 600px at 80% 70%, rgba(52, 211, 153, 0.06), transparent 55%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.dashboard {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.header {
    text-align: center;
    padding-bottom: 4px;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text);
}

.header h1::after {
    content: '_';
    display: inline-block;
    margin-left: 2px;
    animation: blink-cursor 1s step-end infinite;
}

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

.server-card {
    position: relative;
    background: var(--frost-gradient), var(--frost-bg);
    border: 1px solid var(--frost-border);
    border-radius: var(--radius);
    padding: 20px;
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    box-shadow: var(--frost-shadow);
    transition: border-color var(--transition);
    will-change: transform;
}

.server-card:hover {
    border-color: #3a3f55;
}

.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card-top h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-badge.online {
    background: rgba(52, 211, 153, 0.1);
    color: var(--online);
}
.status-badge.online .status-dot {
    background: var(--online);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.status-badge.offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--offline);
}

.status-badge.offline .status-dot {
    background: var(--offline);
}

.status-badge.starting {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}
.status-badge.starting .status-dot {
    background: var(--warning);
    animation: pulse 1.2s infinite;
}

.status-badge .status-info-icon {
    display: none;
    font-size: 1.0rem;
    font-weight: bold;
    line-height: 1;
}

.status-badge.unavailable {
    background: rgba(249, 115, 22, 0.1);
    color: var(--unavailable);
    position: relative;
    cursor: help;
}

.status-badge.unavailable .status-dot {
    display: none;
}
.status-badge.unavailable .status-info-icon {
    display: inline-block;
}

.status-badge.unavailable::after {
    content: "Server is in use already.";
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.status-badge.unavailable:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.status-badge.online,
.status-badge.offline,
.status-badge.starting,
.status-badge.unavailable {
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.expand-toggle {
    width: 100%;
    background: var(--frost-gradient), var(--frost-bg);
    border: 1px solid var(--frost-border);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 10px 14px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 2;
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
    transition: border-radius 0.2s ease, color var(--transition);
}

.expand-toggle:hover {
    border-color: #4a4f66;
    color: var(--text);
}

.server-card.panel-open .expand-toggle {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.expanded-panel {
    margin-top: -1px;
    border-style: solid;
    border-color: var(--frost-border);
    border-width: 0 1px;
    border-top-width: 0;
    border-radius: 0 0 8px 8px;
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    background: var(--frost-gradient), var(--frost-bg);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
    transition: max-height 0.35s ease, padding 0.35s ease, border-width 0.35s ease, border-color 0.35s ease;
    position: relative;
    z-index: 1;
    will-change: transform, max-height, padding;
    contain: layout style;
}

.expanded-panel > * {
    transform: translateZ(0);
    backface-visibility: hidden;
}

.server-card.panel-open .expanded-panel {
    border-color: var(--frost-border);
    border-width: 1px;
    border-top-width: 0;
    max-height: 2000px;
    padding: 16px;
}

.server-card:hover .expand-toggle {
    border-color: #4a4f66;
}

.toggle-arrow {
    font-size: 1.6rem;
    display: inline-block;
    transition: transform 0.25s ease;
    transform-origin: center;
    line-height: 1;
}

.server-card.panel-open .toggle-arrow {
    transform: rotate(90deg);
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.section-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.uptime-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 5px;
    gap: 6px;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--frost-border);
    border-radius: 7px;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform 0.1s ease;
    background: var(--frost-gradient), var(--frost-bg);
    color: var(--text);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
}

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

.action-btn.start {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.action-btn.restart {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.action-btn.stop {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.action-btn.forward {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Mouse/trackpad devices only */
@media (hover: hover) and (pointer: fine) {
    .action-btn:hover {
        border-color: #4a4f66;
    }

    .action-btn.start:hover {
        background: #22c55e;
        color: #ffffff;
        border-color: #22c55e;
        box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
    }

    .action-btn.restart:hover {
        background: #f97316;
        color: #ffffff;
        border-color: #f97316;
        box-shadow: 0 0 12px rgba(249, 115, 22, 0.4);
    }

    .action-btn.stop:hover {
        background: #ef4444;
        color: #ffffff;
        border-color: #ef4444;
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    }

    .action-btn.forward:hover {
        background: #3b82f6;
        color: #ffffff;
        border-color: #3b82f6;
        box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
    }
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;
}

.details-table td {
    padding: 5px 6px;
    vertical-align: top;
}

.details-table td:first-child {
    color: var(--text-secondary);
    width: 45%;
}

.details-table td:last-child {
    color: var(--text);
}

.details-table td.hidden-label {
    display: none !important;
}

.details-table td.full-width-cell {
    display: block !important;
    width: 100% !important;
    padding-left: 0;
    overflow: hidden;
}

.players-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.players-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.players-label {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.player-count {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.player-list-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    overflow: hidden;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--frost-gradient), var(--frost-bg);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    padding: 4px 10px 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--frost-border);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
    overflow: hidden;
}

.player-avatar {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: block;
    object-fit: contain;
    flex-shrink: 0;
}

.player-username {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.models-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.models-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.models-label {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.model-name {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.model-list-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    overflow: hidden;
}

.model-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--frost-gradient), var(--frost-bg);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--frost-border);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
    overflow: hidden;
    max-width: 100%;
    min-width: 0;
}

.model-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: bold;
    font-size: 12px;
    color: #fff;
    text-transform: uppercase;
}

.model-name-text {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.server-card:hover .expanded-panel {
    border-color: var(--frost-border);
}

.toast {
    position: relative;
    background: var(--frost-gradient), var(--frost-bg-strong);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--frost-border);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    max-width: 90vw;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    text-align: center;
    line-height: 1.4;
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    box-shadow: inset 0 1px 0 var(--frost-highlight);
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

.toast.clickable {
    cursor: pointer;
}

@media (max-width: 500px) {
    .toast {
        max-width: 85vw;
        font-size: 0.85rem;
    }
}

@media (max-width: 500px) {
    .card-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .action-buttons {
        flex-direction: column;
    }
    .action-btn {
        width: 100%;
    }
}

.info-badge {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--frost-gradient), var(--frost-bg-strong);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    color: rgba(200, 200, 200, 0.6);
    box-shadow: inset 0 1px 0 var(--frost-highlight), 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.3s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.info-badge:hover {
    transform: scale(1.08);
    background: var(--frost-bg-strong);
}

.info-badge:active {
    transform: scale(0.94);
}

.reload-badge {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--frost-gradient), var(--frost-bg-strong);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
    color: rgba(200, 200, 200, 0.6);
    box-shadow: inset 0 1px 0 var(--frost-highlight), 0 4px 14px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.3s ease;
    cursor: pointer;
    border: none;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.reload-badge:hover {
    transform: scale(1.08);
    background: var(--frost-bg-strong);
}

.reload-badge:active {
    transform: scale(0.94);
}

.toast.show .reload-badge {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toast-like-btn:hover {
    color: #22c55e;
}

#toast-dislike-btn:hover {
    color: #ef4444;
}

.toast-close-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toast-container.show-active {
    opacity: 1;
    visibility: visible;
}

.reload-badge svg {
    width: 18px;
    height: 18px;
}

.toast {
    position: relative;
    overflow: hidden;
}

.toast-score {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, rgba(34,197,94,0.35), rgba(34,197,94,0.18));
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}

#toast-message,
.toast-close-btn,
.reload-badge {
    position: relative;
    z-index: 1;
}

#toast-message {
    transition: opacity 0.2s ease;
    opacity: 1;
}


.toast-close-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--frost-bg-strong);
    border: 1px solid var(--frost-border);
    color: var(--text);
    font-size: 12px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.toast.show .toast-close-btn {
    display: flex;
}

.toast.showing-score #toast-message {
    opacity: 0;
}

@keyframes toast-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

.toast.limit-reached {
    animation: toast-shake 0.4s ease;
}

@media (max-width: 480px) {
    .info-badge {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
    .info-badge h1 {
        font-size: 28px;
    }
}

.auth-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.auth-modal-overlay.show {
    display: flex;
}

.auth-modal {
    background: var(--frost-gradient), var(--frost-bg-strong);
    border: 1px solid var(--frost-border);
    border-radius: var(--radius);
    padding: 22px;
    width: 260px;
    box-shadow: var(--frost-shadow);
    -webkit-backdrop-filter: var(--frost-blur);
    backdrop-filter: var(--frost-blur);
}

.auth-modal h3 {
    margin: 0 0 14px;
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}

.auth-modal input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--frost-border);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 8px;
}

.auth-modal input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-modal-error {
    color: var(--offline);
    font-size: 12px;
    min-height: 16px;
    margin-bottom: 6px;
}

.auth-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.auth-modal-actions button {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--frost-border);
    background: var(--frost-bg);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    transition: background var(--transition), border-color var(--transition);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.auth-modal-actions button:hover {
    border-color: var(--accent);
}

.auth-modal-actions button[type="submit"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.auth-modal-actions button[type="submit"]:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.phone-stream-section {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.45s ease, opacity 0.3s ease;
}

.phone-stream-section.stream-active {
    max-height: 1200px;
    opacity: 1;
    grid-template-rows: 1fr;
}

.phone-stream-container {
    position: relative;
    width: 100%;
    aspect-ratio: 9 / 20;
    margin-top: 8px;
}

#android-stream {
    display: block;
    width: 100%;
    height: 100%;
    clip-path: inset(5px round 10px);
}

.fullscreen-btn-wrap {
    display: none;
}

.fullscreen-btn-wrap.visible {
    display: block;
    width: 100%;
}

.fullscreen-btn-wrap > .fullscreen-btn {
    width: 100%;
    white-space: nowrap;
}

#android-stream:fullscreen {
    width: 100vw;
    height: 100vh;
    background: #000;
}

#android-stream:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    background: #000;
}
