@font-face {
  font-family: "LilitaOne";
  src: url("/fonts/LilitaOne-Regular.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

body {
  letter-spacing: 0.2em;
  padding-top: 55px;
}

#info-game {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

#main,
#loader,
#game,
#end {
  animation: 1s fadeIn ease-in;
  animation-fill-mode: forwards;
}

.card-title {
  font-size: calc(1.275rem + 0.3vw) !important;
}

.thumbnail-game {
  width: 379px;
  height: 575px;
}

.thumbnail-game-mini {
  height: 150px;
}

.thumbnail-avatar {
  width: 30px;
  height: 30px;
}

.logo,
.card-flag {
  width: 40px;
  height: 30px;
}

.nav-link {
  color: #fff !important;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.form-control:focus {
  border: 3px solid #ccc !important;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
    0 0 8px rgba(143, 141, 141, 0.6) !important;
}

.inputFromBottom:hover {
  background-color: pink;
  cursor: pointer;
}

.bg-secondary-dark {
  background-color: #333333;
}

.bg-danger-light {
  background-color: lightpink;
}

.text-danger-light {
  color: lightpink;
}

.letterFromBottom,
.inputFromBottom {
  animation: 1s fadeFromBottom ease;
  animation-fill-mode: forwards;
}

@keyframes fadeFromBottom {
  from {
    opacity: 0;
    transform: translateY(50%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Memory Game */
#game-images {
  height: 0;
  overflow: hidden;
}

.memory-case {
  opacity: 0.8;
}

.memory-case:hover {
  opacity: 0.6;
  cursor: pointer;
}

.tr-height {
  height: 45px;
}

@media (max-width: 576px) {
  .tr-height {
    height: 55px;
  }
  img {
    max-width: 100%;
  }

  .logo {
    display: none;
  }
}

@media (max-width: 768px) {
  .tr-height {
    height: 60px;
  }
}

@media (max-width: 992px) {
  .tr-height {
    height: 65px;
  }
}

@media (max-width: 1200px) {
  .tr-height {
    height: 80px;
  }
}

#unity-container {
  position: relative;
}
/* #unity-container.unity-desktop {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
} */
#unity-container.unity-mobile {
  position: fixed;
  width: 100%;
  height: 100%;
}
#unity-canvas {
  background: #231f20;
}
/* .unity-mobile #unity-canvas {
  width: 100%;
  height: 100%;
} */
#unity-loading-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
}
#unity-logo {
  width: 154px;
  height: 130px;
  background: url("/img/unity/unity-logo-dark.png") no-repeat center;
}
#unity-progress-bar-empty {
  width: 141px;
  height: 18px;
  margin-top: 10px;
  margin-left: 6.5px;
  background: url("/img/unity/progress-bar-empty-dark.png") no-repeat center;
}
#unity-progress-bar-full {
  width: 0%;
  height: 18px;
  margin-top: 10px;
  background: url("/img/unity/progress-bar-full-dark.png") no-repeat center;
}
#unity-footer {
  position: relative;
}
.unity-mobile #unity-footer {
  display: none;
}
#unity-webgl-logo {
  float: left;
  width: 204px;
  height: 38px;
  background: url("/img/unity/webgl-logo.png") no-repeat center;
}
#unity-build-title {
  float: right;
  margin-right: 10px;
  line-height: 38px;
  font-family: arial;
  font-size: 18px;
}
#unity-fullscreen-button {
  cursor: pointer;
  float: right;
  width: 38px;
  height: 38px;
  background: url("/img/unity/fullscreen-button.png") no-repeat center;
}
#unity-warning {
  position: absolute;
  left: 50%;
  top: 5%;
  transform: translate(-50%);
  background: white;
  padding: 10px;
  display: none;
}

#player-badge {
  height: 30px;
  font-size: 0.8em;
  white-space: nowrap;
}

/* Player progression badge — sticky bottom (mobile + desktop).
   The badge is rendered inside <header> for HTML simplicity but visually
   pinned to the bottom of the viewport via position: fixed. */
header.fixed-top > .bg-secondary-dark {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom); /* iOS home bar */
}

/* Free vertical space at the bottom so the sticky badge doesn't cover content. */
body.has-player-badge {
    padding-bottom: calc(50px + env(safe-area-inset-bottom));
}

/* In focus mode (mobile game pages) the whole header is hidden so we don't
   need the bottom padding either — recover the screen space. */
@media (max-width: 767.98px) {
    body.game-page.has-player-badge {
        padding-bottom: 0;
    }
}

/* Game card tiles (used on home + games list).
   Uses tertiary-bg (not body-bg) so cards remain visible in dark mode. */
.game-card {
    background: var(--bs-tertiary-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-card-wrapper {
    display: flex;
    width: 100%;
}

.game-card:hover,
.game-card:focus-visible {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    outline: none;
}

.game-card-thumb {
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: var(--bs-tertiary-bg);
}

.game-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.game-card-body {
    padding: 0.85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.game-card-body h3 {
    font-weight: 600;
    line-height: 1.2;
}

/* Truncate description AND reserve 3 lines of space so the play count
   below stays at a consistent vertical position across all sibling cards. */
.game-card-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(3 * 1.4em);
}

/* Pin the play count at the bottom of the card body — aligns across siblings */
.game-card-plays {
    margin-top: auto;
}

/* Favorite star overlay on game cards (logged-in users only). */
.game-card-favorite {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    transition: transform 0.15s ease, background-color 0.2s ease;
}

.game-card-favorite:hover,
.game-card-favorite:focus-visible {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.game-card-favorite.is-favorited {
    background: var(--bs-danger);
    color: #fff;
}

/* "See all" links — discrete navigation CTA */
.see-all-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--bs-danger);
    font-weight: 600;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    transition: gap 0.2s ease;
}

.see-all-link:hover,
.see-all-link:focus-visible {
    color: var(--bs-danger);
    text-decoration: underline;
    gap: 0.65rem;
    outline: none;
}

/* Post (article) cards */
.post-card {
    background: var(--bs-body-bg);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
    color: inherit;
    padding: 1.25rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.post-card:hover,
.post-card:focus-visible {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    color: inherit;
    outline: none;
}

.post-card-category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-danger);
    margin-bottom: 0.75rem;
}

.post-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.5rem;
    color: var(--bs-emphasis-color);
}

.post-card-description {
    color: var(--bs-secondary-color);
    font-size: 0.95rem;
    line-height: 1.45;
    flex-grow: 1;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--bs-secondary-color);
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color);
}

.post-card-read {
    color: var(--bs-danger);
    font-weight: 600;
    transition: gap 0.2s ease;
}

.post-card:hover .post-card-read,
.post-card:focus-visible .post-card-read {
    text-decoration: underline;
}

/* Latest scores feed (home) */
.latest-scores {
    background: var(--bs-body-bg);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.latest-scores li + li {
    border-top: 1px solid var(--bs-border-color);
}

.latest-score-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.latest-score-item:hover,
.latest-score-item:focus-visible {
    background-color: var(--bs-tertiary-bg);
    color: inherit;
    outline: none;
}

.latest-score-avatar {
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.latest-score-content {
    flex-grow: 1;
    min-width: 0;
}

.latest-score-line {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    line-height: 1.2;
}

.latest-score-user {
    color: var(--bs-emphasis-color);
}

.latest-score-sep {
    color: var(--bs-secondary-color);
}

.latest-score-game {
    color: var(--bs-body-color);
    font-weight: 500;
}

.latest-score-time {
    font-size: 0.78rem;
    display: block;
    margin-top: 0.15rem;
}

.latest-score-points {
    flex-shrink: 0;
    background: var(--bs-danger);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    line-height: 1;
}

/* Accessibility: skip-to-content link, only visible on keyboard focus */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bs-danger);
    color: #fff;
    padding: 0.6rem 1rem;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    border-bottom-right-radius: 6px;
    transition: top 0.15s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    color: #fff;
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Remove default focus outline jump on main when skip link is used */
main:focus {
    outline: none;
}

/* Theme toggle button — show sun on dark theme, moon on light theme */
.theme-toggle {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: #fff;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    color: #fff;
    opacity: 0.85;
    outline: none;
}

[data-bs-theme="light"] .theme-icon-sun { display: none; }
[data-bs-theme="light"] .theme-icon-moon { display: inline-block; }
[data-bs-theme="dark"]  .theme-icon-sun  { display: inline-block; }
[data-bs-theme="dark"]  .theme-icon-moon { display: none; }

/* btn-outline-danger — dark mode readability: keep red border (brand), white text */
[data-bs-theme="dark"] .btn-outline-danger {
    color: #fff;
}

/* Form controls — explicit dark mode (defensive override) */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-color: #6c757d !important;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.3) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: var(--bs-secondary-color);
    opacity: 0.7;
}

[data-bs-theme="dark"] .form-check-input {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--bs-danger);
    border-color: var(--bs-danger);
}

/* Article raw content (post.content from DB) may contain legacy Bootstrap fixed-color
   classes (text-dark, bg-light, etc.). Override them inside <article> so the content
   reads properly in both light and dark themes. */
[data-bs-theme="dark"] article .text-dark,
[data-bs-theme="dark"] article a.text-dark {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] article .bg-light {
    background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] article .badge.bg-light.text-dark,
[data-bs-theme="dark"] article .badge.bg-light {
    background-color: var(--bs-secondary-bg) !important;
    color: var(--bs-body-color) !important;
}

/* SEO body block — collapsible on mobile, auto-expanded on desktop.
   Pattern: short hook below breadcrumb + long SEO body after content. */
.seo-body {
    margin-top: 2.5rem;
    border-top: 1px solid var(--bs-border-color);
    padding-top: 1.5rem;
}

.seo-body-summary {
    cursor: pointer;
    color: var(--bs-danger);
    font-weight: 600;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.seo-body-summary::-webkit-details-marker {
    display: none;
}

.seo-body-summary::after {
    content: '▾';
    transition: transform 0.2s ease;
    display: inline-block;
}

.seo-body[open] .seo-body-summary::after {
    transform: rotate(180deg);
}

.seo-body-content {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Desktop: auto-expand the SEO body and hide the toggle */
@media (min-width: 768px) {
    .seo-body-summary {
        display: none;
    }
    .seo-body > :not(summary) {
        display: block !important;
    }
}

/* Headings — scale down on mobile (display-* utilities are too big on phones).
   Applies site-wide so every page using Bootstrap display utilities benefits. */
@media (max-width: 767.98px) {
    .display-1 { font-size: 2rem; }
    .display-2 { font-size: 1.75rem; }
    .display-3 { font-size: 1.5rem; }
    .display-4 { font-size: 1.5rem; }
    .display-5 { font-size: 1.35rem; }
    .display-6 { font-size: 1.25rem; }

    .lead { font-size: 1rem; }
}

/* Game focus mode — mobile only.
   On phones, hide site chrome (header, footer, breadcrumb, game menu, description)
   and replace it with a slim brand bar (logo · game name · exit) at the top.
   The game card fills the viewport below. */
.game-focus-bar {
    display: none;
}

@media (max-width: 767.98px) {
    body.game-page {
        padding-top: 0;
    }

    body.game-page header.fixed-top,
    body.game-page footer,
    body.game-page .skip-link,
    body.game-page .game-chrome {
        display: none !important;
    }

    body.game-page .game-board {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    /* Game card fills the viewport on mobile in focus mode.
       Page remains scrollable if content overflows. Padding-top matches the
       brand bar height (55px = same as the regular site navbar) — content
       elements provide their own internal breathing via mt-3 etc. */
    body.game-page .game-board > .card {
        min-height: 100vh;
        min-height: 100dvh;
        padding-top: 55px !important;
        background-color: var(--bs-body-bg) !important;
        border: none !important;
        border-radius: 0 !important;
    }

    /* Tighten the .stats spacing — keep the timer's visual identity (bg/border/rounded)
       but remove its m-1 outer margin so it sits flush against the bar. */
    body.game-page .game-board .stats {
        margin: 0 0 0.5rem 0 !important;
    }

    /* During PLAY (status='playing' → .game-screen exists): hide the brand bar
       and float just the X exit icon at top-right. Frees ~36px for the game. */
    body.game-page:has(.game-screen) .game-focus-brand,
    body.game-page:has(.game-screen) .game-focus-title {
        display: none;
    }
    body.game-page:has(.game-screen) .game-focus-bar {
        position: fixed;
        top: 0.4rem;
        right: 0.4rem;
        left: auto;
        bottom: auto;
        height: auto;
        padding: 0;
        background: transparent;
        border-bottom: none;
        z-index: 1050;
    }
    body.game-page:has(.game-screen) .game-focus-exit {
        width: 32px;
        height: 32px;
        background: var(--bs-body-bg);
        border: 1px solid var(--bs-border-color);
        border-radius: 50%;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    }
    body.game-page:has(.game-screen) .game-board > .card {
        padding-top: 55px !important;
    }

    /* Brand bar fixed at top, replaces the hidden site header.
       Height matches the regular site navbar (~55px) so the visual transition
       between "browsing" and "playing" feels seamless. */
    body.game-page .game-focus-bar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 55px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 0.75rem;
        z-index: 1050;
        background: var(--bs-body-bg);
        border-bottom: 1px solid var(--bs-border-color);
    }

    .game-focus-brand {
        display: inline-flex;
        align-items: center;
        flex-shrink: 0;
    }
    .game-focus-brand img {
        width: 32px;
        height: 32px;
        border-radius: 6px;
    }

    .game-focus-title {
        flex: 1;
        text-align: center;
        font-weight: 600;
        font-size: 1rem;
        color: var(--bs-body-color);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0 0.5rem;
    }

    .game-focus-exit {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 32px;
        height: 32px;
        color: var(--bs-body-color);
        text-decoration: none;
    }

    .game-focus-exit:hover,
    .game-focus-exit:focus-visible {
        color: var(--bs-danger);
        outline: none;
    }
}

/* Image upload modal — merged from former image.css to save one HTTP request */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    margin: 20% auto;
    padding: 20px;
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    width: 80%;
}

.close {
    background: transparent;
    border: none;
    color: var(--bs-secondary-color);
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.close:hover,
.close:focus-visible {
    color: var(--bs-body-color);
    outline: 2px solid var(--bs-danger);
    outline-offset: 2px;
}

/* Accessibility: respect users who set prefers-reduced-motion in their OS.
   Forces animations and transitions off — gives stable rendering for
   vestibular-disorder users without removing the styles themselves. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* About page — peak markers on section titles, snow-toned stat cards. */

.about-article {
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
}

.about-section {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.about-section:last-child {
    border-bottom: none;
}

.about-section-title {
    position: relative;
    padding-left: 1.5rem;
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.about-section-title::before {
    content: '▲';
    position: absolute;
    left: 0;
    top: 0.1em;
    color: var(--bs-danger);
    font-size: 0.85em;
}

/* Stats cards — snow-capped feel */
.about-stat {
    text-align: center;
    padding: 1.25rem 0.75rem;
    background: linear-gradient(180deg, var(--bs-tertiary-bg) 0%, var(--bs-body-bg) 100%);
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.about-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.about-stat-value {
    font-family: "LilitaOne", "Luckiest Guy", cursive;
    font-size: 2.5rem;
    line-height: 1;
    color: var(--bs-danger);
    margin-bottom: 0.25rem;
}

.about-stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    font-weight: 600;
}

/* Feature list with mountain peak bullets */
.about-features {
    margin-top: 1rem;
}

.about-features li {
    position: relative;
    padding: 0.5rem 0 0.5rem 2rem;
    border-bottom: 1px dashed var(--bs-border-color);
}

.about-features li:last-child {
    border-bottom: none;
}

.about-features li::before {
    content: '';
    position: absolute;
    left: 0.4rem;
    top: 0.85rem;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 12px solid var(--bs-danger);
}

.about-features li::after {
    content: '';
    position: absolute;
    left: 0.65rem;
    top: 0.85rem;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 6px solid #fff;
    opacity: 0.85;
}

[data-bs-theme="dark"] .about-features li::after {
    border-bottom-color: var(--bs-body-color);
    opacity: 0.5;
}
