/* ── Spieleportal – Dark Theme ── */

:root {
    --bg-primary:   #0d1117;
    --bg-surface:   #161b22;
    --bg-card:      #1c2230;
    --bg-hover:     #222a38;
    --border:       #30363d;
    --text-primary: #e0e0e0;
    --text-muted:   #8b949e;
    --accent:       #3fb950;
    --accent-hover: #2ea043;
    --accent-dim:   rgba(63, 185, 80, 0.15);
    --blue:         #58a6ff;
    --amber:        #d29922;
    --red:          #f85149;
    --radius:       8px;
    --radius-lg:    12px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */

.page-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Navbar ── */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.navbar-brand:hover { text-decoration: none; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.navbar-user strong {
    color: var(--text-primary);
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--red);
    border-color: var(--border);
}
.btn-danger:hover {
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--red);
}

.btn-play {
    background: var(--accent);
    color: #fff;
    padding: 12px 32px;
    font-size: 16px;
    border-radius: var(--radius);
}
.btn-play:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(63, 185, 80, 0.3);
}

.btn-bot {
    background: var(--blue);
    color: #fff;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: var(--radius);
}
.btn-bot:hover {
    background: #388bfd;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ── Cards ── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-body {
    padding: 24px;
}

/* ── Login / Register ── */

.auth-card {
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.auth-header {
    text-align: center;
    padding: 32px 24px 0;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    margin: 20px 24px 0;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-error {
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius);
    color: var(--red);
    font-size: 13px;
    display: none;
}

.form-error.visible {
    display: block;
}

/* ── Dashboard ── */

.dashboard-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.game-card {
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
}

.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.game-card-accent {
    height: 4px;
    width: 100%;
}

.game-card-accent.volto    { background: linear-gradient(90deg, #d4a44a, #c98523); }
.game-card-accent.barragoon { background: linear-gradient(90deg, var(--blue), #388bfd); }

.game-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-card h3 {
    font-size: 20px;
    font-weight: 700;
}

.game-card p {
    color: var(--text-muted);
    font-size: 14px;
    flex: 1;
}

.game-card-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.game-card-stats strong {
    color: var(--text-primary);
}

.game-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

/* ── Rankings Table ── */

.ranking-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.ranking-tab {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.ranking-tab.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.ranking-tab:hover:not(.active) {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}

.rank-1 { background: #ffd700; color: #000; }
.rank-2 { background: #c0c0c0; color: #000; }
.rank-3 { background: #cd7f32; color: #fff; }

.elo-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Test Page ── */

.test-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.test-controls label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.test-controls select,
.test-controls input {
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.test-controls select:focus,
.test-controls input:focus {
    border-color: var(--accent);
}

.test-status {
    flex: 1;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
}

.test-status.success { color: var(--accent); }
.test-status.error   { color: var(--red); }

.test-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}

.test-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    min-height: 0;
}

.test-panel:last-child {
    border-right: none;
}

.test-panel-header {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.test-panel-header .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 8px;
}

.test-panel-header .dot.connected { background: var(--accent); }

.test-panel iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--bg-primary);
    min-height: 600px;
}

/* ── Lobby ── */

.lobby-status {
    font-size: 10px;
    color: var(--text-muted);
    transition: color 0.3s;
}

.lobby-status.connected {
    color: var(--accent);
}

.lobby-time-select {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}

.lobby-time-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.game-card-waiting {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--accent-dim);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--accent);
}

.waiting-dot-anim {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: lobbyPulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes lobbyPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.8); }
}

/* Open Games */

.open-games-list {
    min-height: 60px;
}

.open-game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.open-game-item:last-child {
    border-bottom: none;
}

.open-game-item:hover {
    background: var(--bg-hover);
}

.open-game-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.open-game-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.open-game-badge.volto {
    background: rgba(212, 164, 74, 0.2);
    color: #d4a44a;
}

.open-game-badge.barragoon {
    background: rgba(88, 166, 255, 0.2);
    color: var(--blue);
}

.open-game-creator {
    font-weight: 600;
    font-size: 14px;
}

.open-game-detail {
    color: var(--text-muted);
    font-size: 13px;
}

.btn-join {
    background: var(--blue);
    color: #fff;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-join:hover {
    background: #388bfd;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

/* Match Overlay */

.match-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.match-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.match-overlay-box {
    text-align: center;
    padding: 48px 56px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent);
    max-width: 440px;
    width: 90%;
    animation: matchPop 0.4s ease;
}

@keyframes matchPop {
    0%   { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.match-overlay-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.match-overlay-box h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.match-overlay-box p {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 24px;
}

.btn-match-start {
    display: inline-flex;
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    border-radius: var(--radius);
    animation: matchBtnGlow 2s ease-in-out infinite;
}

@keyframes matchBtnGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.4); }
    50%      { box-shadow: 0 0 20px 4px rgba(63, 185, 80, 0.3); }
}

.btn-match-start:hover {
    text-decoration: none;
}

.match-overlay-hint {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    margin-bottom: 0 !important;
    margin-top: 16px !important;
}

/* ── Toast-Nachrichten ── */

#toast-container {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}

.toast--visible {
    opacity: 1;
    transform: translateX(0);
}

.toast--success { border-left: 3px solid var(--accent); }
.toast--error   { border-left: 3px solid var(--red); }
.toast--info    { border-left: 3px solid var(--blue); }
.toast--warning { border-left: 3px solid var(--amber); }

.toast__icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast--success .toast__icon { color: var(--accent); }
.toast--error   .toast__icon { color: var(--red); }
.toast--info    .toast__icon { color: var(--blue); }
.toast--warning .toast__icon { color: var(--amber); }

.toast__msg  { flex: 1; line-height: 1.4; }

.toast__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.toast__close:hover { color: var(--text-primary); }

/* ── Profil-Dropdown ── */

.navbar-profile {
    position: relative;
}

.navbar-profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.navbar-profile-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.navbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.navbar-chevron {
    color: var(--text-muted);
    font-size: 10px;
    transition: transform 0.15s;
}

.navbar-profile.open .navbar-chevron {
    transform: rotate(180deg);
}

.navbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    display: none;
}

.navbar-profile.open .navbar-dropdown {
    display: block;
}

.navbar-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.navbar-dropdown-header .name {
    font-weight: 700;
    font-size: 14px;
}

.navbar-dropdown-header .email {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.navbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.navbar-dropdown-item:hover {
    background: var(--bg-hover);
}

.navbar-dropdown-item.danger {
    color: var(--red);
}

/* ── Portal-Logo (SVG-Icon) ── */

.navbar-logo-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

/* ── Loading Skeleton ── */

.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeletonShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.skeleton-cell {
    height: 14px;
    border-radius: 4px;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .game-grid {
        grid-template-columns: 1fr;
    }
    .test-panels {
        grid-template-columns: 1fr;
    }
    .navbar {
        padding: 12px 16px;
    }
    .dashboard-content {
        padding: 20px 16px;
    }
}
