/* Masse und Farben 1:1 aus der alten spielejahr/index.php */

@font-face {
    font-family: "RbtvSans";
    src: url("../fonts/RBTVSans-Bold.otf");
}

@font-face {
    font-family: "Joystix";
    src: url("../fonts/joystix-monospace.otf");
}

body {
    font-family: 'RbtvSans', sans-serif;
    font-weight: bold;
    background-color: black;
    color: white;
    overflow: hidden;
    background-image: url("../img/spielejahr-bg.png");
}

.placement {
    margin-left: -54px;
    width: 40px;
    text-align: right;
    color: white;
}

.game {
    position: absolute;
    display: flex;
    align-items: center;
    width: 800px;
    height: 50px;
    font-size: 20px;
    border-color: white;
    border-width: 2px;
    border-style: solid;
    color: white;
    background-color: black;
}

.name {
    margin-left: 20px;
    /* alte Seite lief im Quirks-Modus, dort galt die einheitenlose 18 als 18px */
    font-size: 18px;
    width: 600px;
    text-transform: uppercase;
}

.redScore {
    position: absolute;
    right: 230px;
    display: none;
    font-size: 16px;
}

.forumScore {
    position: absolute;
    right: 150px;
    display: none;
    font-size: 16px;
}

.chatScore {
    position: absolute;
    right: 70px;
    display: none;
    font-size: 16px;
}

.score {
    background-color: white;
    color: black;
    position: absolute;
    left: 745px;
    height: 50px;
    display: flex;
    align-items: center;
    width: 57px;
    justify-content: center;
    font-size: 20px;
}

/* gerade neu aufgedecktes Spiel */
.current {
    background-color: white;
    color: black;
}

.first {
    border-color: #dac875;
    color: #dac875;
}

.firstScore {
    background-color: #dac875;
}

.firstPlacement {
    color: #dac875;
}

.second {
    border-color: #b0bfc8;
    color: #b0bfc8;
}

.secondScore {
    background-color: #b0bfc8;
}

.secondPlacement {
    color: #b0bfc8;
}

.third {
    border-color: #9e6b5b;
    color: #9e6b5b;
}

.thirdScore {
    background-color: #9e6b5b;
}

.thirdPlacement {
    color: #9e6b5b;
}

#legend1 {
    position: absolute;
    top: 70px;
    left: 635px;
    font-size: 16px;
    display: none;
}

#legend2 {
    position: absolute;
    top: 280px;
    left: 1535px;
    font-size: 16px;
    display: none;
}

.legendForum {
    margin-left: 10px;
}

.legendChat {
    margin-left: 15px;
}

#actions {
    position: absolute;
    z-index: 5;
}

#elements {
    position: absolute;
}

#message {
    font-family: sans-serif;
    font-weight: normal;
}

.notice {
    color: #ff8080;
}

/* ---------- Themes (frueher per talkId im Code verdrahtet) ---------- */

/* 2024: schmale Kacheln */
body.theme-compact .game {
    width: 380px;
}

body.theme-compact .score {
    left: 325px;
}

body.theme-compact .name {
    width: 310px;
}

/* 1994-1998: Retro mit Joystix und Glow */
body.theme-retro {
    background-image: url("../img/retro-bg.png");
    font-family: "Joystix";
}

body.theme-retro .game {
    box-shadow: rgb(255 255 255) 0px 0px 0.5em 0px inset, rgb(255 255 255) 0px 0px 0.5em 0px;
}

body.theme-retro .game.third {
    box-shadow: rgb(158 107 91) 0px 0px 0.5em 0px inset, rgb(158 107 91) 0px 0px 0.5em 0px;
}

body.theme-retro .game.second {
    box-shadow: rgb(176 191 200) 0px 0px 0.5em 0px inset, rgb(176 191 200) 0px 0px 0.5em 0px;
}

body.theme-retro .game.first {
    box-shadow: rgb(218 200 117) 0px 0px 0.5em 0px inset, rgb(218 200 117) 0px 0px 0.5em 0px;
}

body.theme-retro .score {
    font-size: 16px;
}

/* ?transparent fuer OBS */
body.transparent {
    background-image: none;
    background-color: transparent;
}

/* ---------- Startseite (ohne ?id) ---------- */

a.overviewYear {
    text-decoration: none;
}

a.overviewYear:hover {
    background-color: white;
    color: black;
}

/* Logo ueber der zweiten Spalte (Spalte 2 beginnt bei left 1000, top 250) */
#logo {
    position: absolute;
    top: 20px;
    left: 1000px;
    width: 802px;
    height: 210px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

#logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#logo:hover img,
#logo:focus-visible img {
    filter: brightness(1.15);
}

#createModal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
}

#createModal[hidden] {
    display: none;
}

#createModal .modalBox {
    position: relative;
    width: 600px;
    max-width: calc(100vw - 32px);
    height: 960px;
    max-height: calc(100vh - 32px);
    background-color: white;
    border: 2px solid white;
}

#createModal iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#createModal .modalClose {
    position: absolute;
    top: 4px;
    right: 8px;
    border: none;
    background: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Admin-Ansicht (?admin=…) ----------
   Unabhaengig von der Bildschirmgroesse: statt der 1920x1080-Tafel ein Raster aus Karten
   in Tafel-Reihenfolge (CSS order). Die Stream-Positionen werden weiter gespeichert. */

body.admin {
    margin: 0;
    overflow: auto;
    background-attachment: fixed;
    background-size: cover;
}

/* Legenden gehoeren zur Stream-Tafel */
body.admin #legend1,
body.admin #legend2 {
    display: none !important;
}

#adminBar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    min-height: 56px;
    padding: 8px 20px;
    box-sizing: border-box;
    background-color: rgba(10, 12, 24, 0.94);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
    font-family: 'RbtvSans', sans-serif;
    font-size: 15px;
}

#adminBar button,
#adminBar input {
    font: inherit;
    font-weight: bold;
    border-radius: 6px;
}

#adminBar button {
    padding: 8px 16px;
    color: white;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
}

#adminBar button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#adminBar button.primary {
    color: black;
    background-color: #dac875;
    border-color: #dac875;
}

#adminBar button.primary:hover {
    background-color: #e8d88c;
}

#adminBar button:disabled {
    opacity: 0.5;
    cursor: default;
}

.adminTitle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.adminBadge {
    padding: 2px 8px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: black;
    background-color: #dac875;
    border-radius: 4px;
}

.adminYear {
    font-size: 18px;
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adminAdd {
    display: flex;
    flex: 1 1 260px;
    gap: 8px;
    max-width: 440px;
    margin: 0;
}

.adminAdd input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    color: white;
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.adminAdd input:focus {
    outline: none;
    border-color: #dac875;
}

.adminStats {
    margin-left: auto;
    color: #b0bfc8;
    white-space: nowrap;
}

.adminActions {
    display: flex;
    align-items: center;
    gap: 10px 16px;
}

.adminStatus {
    font-size: 14px;
    white-space: nowrap;
}

.adminStatus:empty {
    display: none;
}

.adminStatus.dirty {
    color: #ffb347;
}

.adminStatus.dirty::before {
    content: "● ";
}

.adminStatus.saving {
    color: #b0bfc8;
}

.adminStatus.saved {
    color: #7fd17f;
}

.adminStatus.saved::before {
    content: "✓ ";
}

.adminStatus.error {
    color: #ff8080;
}

/* Karten-Raster */
body.admin #elements {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 640px), 1fr));
    gap: 10px 28px;
    padding: 20px;
}

body.admin .game {
    position: static;
    box-sizing: border-box;
    width: auto;
    height: auto;
    min-height: 56px;
    gap: 12px;
    padding-left: 10px;
}

body.admin .placement {
    flex: none;
    width: 36px;
    margin: 0;
}

body.admin .name {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

body.admin .redScore,
body.admin .forumScore,
body.admin .chatScore {
    position: static;
    flex: none;
}

body.admin .game .redScore::before,
body.admin .game .forumScore::before,
body.admin .game .chatScore::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-family: sans-serif;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

body.admin .game .redScore input,
body.admin .game .forumScore input,
body.admin .game .chatScore input {
    box-sizing: border-box;
    width: 68px;
    height: 30px;
    font: inherit;
    font-size: 16px;
    text-align: center;
    color: white;
    background-color: #16182a;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 5px;
}

body.admin .game input:focus {
    outline: none;
    border-color: #dac875;
    box-shadow: 0 0 0 2px rgba(218, 200, 117, 0.35);
}

body.admin .game input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Gesamtwertung: nur Anzeige, sieht aus wie in der Zuschaueransicht */
body.admin .score {
    position: static;
    flex: none;
    align-self: stretch;
    width: 64px;
    height: auto;
}

body.admin .game .score input {
    width: 100%;
    height: 100%;
    padding: 0;
    font: inherit;
    text-align: center;
    color: inherit;
    background: transparent;
    border: none;
    box-shadow: none;
    pointer-events: none;
}

body.admin .game:focus-within {
    box-shadow: 0 0 0 2px #dac875;
}

/* frisch hinzugefuegtes Spiel (weisse Kachel) */
body.admin .game.current .redScore::before,
body.admin .game.current .forumScore::before,
body.admin .game.current .chatScore::before {
    color: rgba(0, 0, 0, 0.55);
}

.removeGame {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 6px;
    padding: 0;
    color: rgba(255, 255, 255, 0.45);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
}

.removeGame svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.removeGame:hover,
.removeGame:focus-visible {
    color: #ff8080;
    border-color: rgba(255, 128, 128, 0.5);
    background-color: rgba(255, 128, 128, 0.12);
    outline: none;
}

.game.current .removeGame {
    color: rgba(0, 0, 0, 0.45);
}

/* schmale Bildschirme: Name ueber den Wertungen */
@media (max-width: 640px) {
    /* oben Titel, Schnitt und "Spiel hinzufuegen"; Status und Knoepfe als Leiste unten */
    #adminBar {
        gap: 8px;
        padding: 8px 12px;
        /* backdrop-filter wuerde die feste Leiste unten an die Kopfzeile binden */
        backdrop-filter: none;
        background-color: #0a0c18;
    }

    .adminTitle {
        flex: 1 1 auto;
    }

    .adminStats {
        font-size: 13px;
    }

    .adminAdd {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .adminActions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        background-color: #0a0c18;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
    }

    .adminStatus {
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal;
    }

    body.admin {
        padding-bottom: 72px;
    }

    body.admin #elements {
        padding: 12px;
    }

    body.admin .game {
        flex-wrap: wrap;
        padding: 8px 0 8px 8px;
    }

    body.admin .name {
        flex-basis: calc(100% - 60px);
    }

    body.admin .redScore {
        margin-left: 48px;
    }

    body.admin .score {
        align-self: center;
        height: 40px;
        margin-left: auto;
    }
}
