:root {
    --bg: #ffffff;
    --surface: #f3f3f3;
    --text: #111111;
    --muted: #666666;
    --border: #dddddd;
    --link: #111111;
    --max-width: 780px;
}

[data-theme="dark"] {
    --bg: #111111;
    --surface: #1b1b1b;
    --text: #eeeeee;
    --muted: #aaaaaa;
    --border: #333333;
    --link: #ffffff;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--link); text-decoration-thickness: 0.08em; }

.site-header,
.site-main,
.site-footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem;
}

.site-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
}

.nav a,
.nav-dropdown-toggle {
    color: var(--muted);
    text-decoration: none;
}

.nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
}

.nav-dropdown {
    position: relative;
    padding-bottom: 0.25rem;
    margin-bottom: -0.25rem;
}

.nav-dropdown-toggle {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.nav-dropdown-toggle::after {
    content: "";
    display: inline-block;
    margin-left: 0.3rem;
    border-left: 0.25rem solid transparent;
    border-right: 0.25rem solid transparent;
    border-top: 0.3rem solid currentColor;
    vertical-align: middle;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    min-width: 9.5rem;
    margin-top: 0;
    padding: 0.35rem 0;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08);
    display: none;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.35rem 0.75rem;
    white-space: nowrap;
}

.language-switch,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    line-height: 1;
}

.theme-toggle {
    width: 1.2rem;
    height: 1.2rem;
    font-size: 0.95rem;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.language-switch:hover,
.language-switch:focus-visible,
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible,
.nav a:hover,
.nav a:focus-visible {
    color: var(--text);
}

.flag {
    display: inline-block;
    width: 1.35rem;
    height: 0.9rem;
    border: 1px solid var(--border);
    vertical-align: middle;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

.flag-de {
    background: linear-gradient(to bottom, #000 0 33.333%, #dd0000 33.333% 66.666%, #ffce00 66.666% 100%);
}

.flag-us {
    background:
        linear-gradient(#3c3b6e 0 0) left top / 40% 53.85% no-repeat,
        repeating-linear-gradient(to bottom, #b22234 0 7.69%, #fff 7.69% 15.38%);
}

.content h1 {
    font-size: clamp(2rem, 7vw, 4rem);
    line-height: 1.05;
    margin: 2rem 0 1rem;
}

.content p,
.content li {
    font-size: 1.05rem;
}

.thought {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.thought time {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.site-footer {
    display: none;
}

.portrait {
    margin: 0 auto 1.5rem;
    text-align: center;
}

.portrait img {
    display: block;
    width: min(260px, 100%);
    height: auto;
    margin: 0 auto;
    border-radius: 0;
    border: 0;
    background: transparent;
}

.thought h2 {
    font-size: 1.25rem;
    line-height: 1.25;
    margin: 0 0 0.25rem;
}

@media (max-width: 640px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        justify-content: flex-start;
    }

    .nav-dropdown-menu {
        right: auto;
        left: 0;
    }

    .site-header,
    .site-main,
    .site-footer {
        padding: 1rem;
    }
}

/* v2 utility bar: games/language/theme above the main menu */
.site-header {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
}

.header-tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    width: 100%;
}

.nav {
    justify-content: center;
    width: 100%;
}

.games-tool {
    position: relative;
    padding-bottom: 0.25rem;
    margin-bottom: -0.25rem;
}

.dice-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 1px solid var(--muted);
    border-radius: 0.22rem;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.dice-toggle:hover,
.dice-toggle:focus-visible,
.games-tool.is-open .dice-toggle {
    color: var(--text);
    border-color: var(--text);
}

.dice-icon {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
}

.dice-icon span {
    position: absolute;
    width: 0.22rem;
    height: 0.22rem;
    border-radius: 50%;
    background: currentColor;
}

.dice-icon span:nth-child(1) {
    top: 0.28rem;
    left: 0.28rem;
}

.dice-icon span:nth-child(2) {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dice-icon span:nth-child(3) {
    right: 0.28rem;
    bottom: 0.28rem;
}

.games-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    min-width: 9.5rem;
    margin-top: 0;
    padding: 0.35rem 0;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08);
    display: none;
}

.games-tool:hover .games-menu,
.games-tool:focus-within .games-menu,
.games-tool.is-open .games-menu {
    display: block;
}

.games-menu a {
    display: block;
    padding: 0.35rem 0.75rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.games-menu a:hover,
.games-menu a:focus-visible {
    color: var(--text);
}

@media (max-width: 640px) {
    .site-header {
        align-items: center;
    }

    .nav {
        justify-content: center;
        gap: 0.65rem;
    }
}


/* Utility bar fix: force tools above the main menu and keep the dice dropdown clickable */
.site-header {
    display: block !important;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.header-tools {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    width: 100%;
    margin: 0 0 0.85rem 0;
    position: relative;
    z-index: 20;
}

.nav {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: center !important;
    width: 100%;
    position: relative;
    z-index: 1;
}

.games-tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.dice-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 1px solid var(--muted);
    border-radius: 0.22rem;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    appearance: none;
}

.games-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 999;
    min-width: 10rem;
    padding: 0.35rem 0;
    background: var(--bg);
    border: 1px solid var(--border);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12);
    display: none;
    text-align: left;
}

.games-tool.is-open .games-menu,
.games-tool:focus-within .games-menu {
    display: block !important;
}

.games-menu a {
    display: block;
    padding: 0.4rem 0.8rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.games-menu a:hover,
.games-menu a:focus-visible {
    color: var(--text);
    background: var(--surface);
}

.language-switch,
.theme-toggle {
    position: relative;
    z-index: 21;
}

@media (max-width: 640px) {
    .site-header {
        display: block !important;
        padding: 1rem;
        text-align: center;
    }

    .header-tools {
        justify-content: center !important;
        margin-bottom: 0.8rem;
    }

    .nav {
        justify-content: center !important;
        gap: 0.65rem;
    }
}

/* Utility bar layout tweak: language/theme left, dice right, dice sized to flag height */
.header-tools {
    justify-content: flex-start !important;
    gap: 0.7rem;
}

.language-switch {
    order: 1;
}

.theme-toggle {
    order: 2;
}

.games-tool {
    order: 3;
    margin-left: auto;
}

.dice-toggle {
    width: 0.95rem !important;
    height: 0.95rem !important;
    border-radius: 0.16rem;
}

.dice-icon span {
    width: 0.15rem;
    height: 0.15rem;
}

.dice-icon span:nth-child(1) {
    top: 0.19rem;
    left: 0.19rem;
}

.dice-icon span:nth-child(3) {
    right: 0.19rem;
    bottom: 0.19rem;
}

.games-menu {
    left: auto;
    right: 0;
    transform: none;
}

@media (max-width: 640px) {
    .header-tools {
        justify-content: flex-start !important;
    }

    .games-tool {
        margin-left: auto;
    }
}
