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

/* PAGE LAYOUT */
:root{
    --bg: #70c5ce;
    --panel: #ffffff;
    --muted: #6b7280;
    --accent: #0ea5a4;
    --accent-2: #06b6d4;
    --gold: #f59e0b;
    --silver: #9ca3af;
    --bronze: #d97706;
    --glass: rgba(255,255,255,0.85);
    --shadow: 0 8px 24px rgba(15,23,42,0.12);
    --radius: 12px;
    --text: #0b1220;
}

body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: linear-gradient(180deg, var(--bg) 0%, #93dfe7 100%);
    color: var(--text);
    text-align: center;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    padding-bottom: 2.5rem;
}

/* HEADER
   
*/
header {
    background-color: #0f1724;
    color: white;
    box-shadow: 0 4px 12px rgba(2,6,23,0.25);
}

/* Haupt-Container im Header: sorgt dafür, dass Logo links sitzt und Navigation rechts */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    gap: 1rem;
}

/* Brand: Logo + Titel (links) */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Logo-Bild: skaliert, behält Seitenverhältnis und sitzt links */
.brand .logo {
    width: 56px;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 6px; /* optional, kann entfernt werden */
    background: transparent;
}

/* Titel neben dem Logo; links ausgerichtet */
.brand .title {
    text-align: left;
    color: white;
}
.brand h1 { font-weight: 600; font-size: 1.05rem; margin: 0; line-height: 1; }
.brand .subtitle { font-size: 0.78rem; opacity: 0.9; margin-top: 0.15rem; }

/* Navigation rechts im Header */
.main-nav .nav-link {
    color: #cfeff3;
    text-decoration: none;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.03);
    font-weight: 600;
}
.main-nav .nav-link:hover { text-decoration: underline; opacity: 0.95; }

/* CENTER BOX (Welcome Page) */
.center-box {
    margin-top: 3rem;
}

#error-msg,
.error-msg {
    color: #ef4444;
    margin-top: 1rem;
    display: none;
}

#player-name {
    padding: 0.6rem;
    font-size: 1.1rem;
    width: 60%;
    max-width: 300px;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(2,6,23,0.08);
    background: rgba(255,255,255,0.9);
    color: var(--text);
    outline: none;
}

/* BUTTON - primary */
.btn {
    padding: 0.8rem 1.6rem;
    font-size: 1.05rem;
    background-color: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    font-weight: 700;
    margin-top: 1rem;
    box-shadow: 0 8px 20px rgba(14,165,164,0.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(14,165,164,0.22); }
.btn.secondary {
    background: white;
    color: var(--text);
    border: 1px solid rgba(2,6,23,0.06);
    box-shadow: 0 6px 14px rgba(2,6,23,0.06);
}

/* CANVAS */
canvas {
    display: block;
    margin: 1.5rem auto;
    background-color: #8addff;
    border: 2px solid #000;
    border-radius: 8px;
    max-width: 95vw;
    width: 400px;
}

/* SCORE */
#score-container {
    font-size: 1.5rem;
    font-weight: bold;
}

/* GAME OVER OVERLAY */
#game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2,6,23,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 1rem;
}

/* Card inside overlay */
.game-over-box {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,250,250,0.98));
    width: min(520px, 96%);
    border-radius: var(--radius);
    text-align: left;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    color: var(--text);
    border: 1px solid rgba(2,6,23,0.06);
}

/* Header section */
.game-over-box h2 {
    margin-bottom: 0.2rem;
    font-size: 1.35rem;
    font-weight: 700;
}
.game-over-box p { margin-bottom: 0.75rem; color: var(--muted); }

/* Final score badge */
.final-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    background: linear-gradient(90deg, #ffefc2, #ffd27a);
    border-radius: 999px;
    font-weight: 800;
    color: #6b3d00;
    box-shadow: 0 6px 18px rgba(245,158,11,0.15);
}

/* LEADERBOARD */
.leaderboard-wrap {
    margin-top: 0.8rem;
}

/* ordered list reset */
#leaderboard-list {
    list-style: none;
    margin-top: 1rem;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

/* each entry as a card */
#leaderboard-list li {
    background: white;
    border-radius: 10px;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 6px 18px rgba(2,6,23,0.06);
    border: 1px solid rgba(2,6,23,0.04);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#leaderboard-list li:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 30px rgba(2,6,23,0.08);
}

/* left part: rank and avatar */
.entry-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.rank {
    min-width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    font-weight: 800;
    color: white;
    background: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.02));
    box-shadow: inset 0 -6px 14px rgba(255,255,255,0.08);
    font-size: 0.95rem;
}

/* special colors for top 3 */
#leaderboard-list li:nth-child(1) .rank {
    background: linear-gradient(180deg, var(--gold), #d97706);
    color: #2b1300;
    box-shadow: 0 6px 18px rgba(245,158,11,0.16);
}
#leaderboard-list li:nth-child(2) .rank {
    background: linear-gradient(180deg, var(--silver), #6b7280);
    color: #071028;
    box-shadow: 0 6px 18px rgba(156,163,175,0.12);
}
#leaderboard-list li:nth-child(3) .rank {
    background: linear-gradient(180deg, var(--bronze), #b45309);
    color: #1a0f00;
    box-shadow: 0 6px 18px rgba(217,119,6,0.12);
}

/* avatar placeholder */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(14,165,164,0.12), rgba(6,182,212,0.06));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--accent);
    font-size: 0.95rem;
    border: 1px solid rgba(2,6,23,0.04);
}

/* middle: name */
.entry-name {
    font-weight: 700;
    color: var(--text);
    font-size: 0.98rem;
}

/* right: score */
.entry-score {
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--accent-2);
    min-width: 64px;
    text-align: right;
}

/* small muted text */
.entry-sub {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
}

/* Controls in overlay (buttons) */
.game-over-controls {
    margin-top: 1rem;
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    align-items: center;
}

/* play again / back to start button */
#play-again-btn {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    color: white;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    border: none;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(6,182,212,0.14);
}

/* secondary close / restart */
#close-game-over, #restart-btn {
    background: white;
    color: var(--text);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    border: 1px solid rgba(2,6,23,0.06);
    font-weight: 700;
    cursor: pointer;
}

/* HIDDEN CLASS */
.hidden {
    display: none !important;
}

/* FOOTER */
footer {
    background-color: #0f1724;
    color: white;
    padding: 1rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    box-shadow: 0 -4px 18px rgba(2,6,23,0.06);
}

/* MOBILE */
@media (max-width: 600px) {
    nav a { margin: 0 0.5rem; }
    #restart-btn, #start-btn, .btn { width: 74%; }
    .game-over-box { padding: 1rem; }
    #leaderboard-list li { padding: 0.55rem; }
    .entry-left { gap: 0.5rem; }
}