/* Import Ubuntu font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;700&display=swap');

/* Apply Ubuntu font to the entire document by default */
body, html {
    font-family: 'Ubuntu', sans-serif;
}
:root {
    --purple: rgb(123, 31, 162);
    --violet: rgb(103, 58, 183);
    --pink: rgb(244, 143, 177);
}

/* Global box-sizing to avoid layout inconsistencies */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Background + global layout */
body {
    background: linear-gradient(-45deg, #1a0f2e, #0f0820, #1f1240, #0d0619);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite, fadeIn 1s ease-out forwards;
    margin: 0;
    overflow: auto;
    /* allow text selection for accessibility */
    user-select: text;
    font-family: 'Ubuntu', sans-serif;
    color: #F9F6EF;
    min-height: 100vh;
    opacity: 0;
}

/* Main content wrapper */
#main {
    width: 90vw;
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 58px; /* keep site content below the fixed banner */
}

/* Particles canvas */
#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Title */
h1 {
    color: white;
    font-family: "Ubuntu", sans-serif;
    font-size: clamp(2em, 2vw, 4em);
    font-weight: 400;
    margin: 0;
    padding: 150px 0 40px 0;
    text-align: center;
}

h1 .magic {
    display: inline-block;
    position: relative;
}

h1 .magic .magic-text,
h2 .magic .magic-text {
    background: linear-gradient(to right, var(--purple), var(--violet), var(--pink), var(--purple));
    background-size: 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    white-space: nowrap;
    animation: background-pan 3s linear infinite;
}

@keyframes background-pan {
    from { background-position: 0% center; }
    to   { background-position: -200% center; }
}

/* ── Search wrapper ────────────────────────────────────────── */
.search-wrap {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px auto;
    position: relative;
}

#game-search {
    flex: 1;
    padding: 12px 42px 12px 18px; /* right padding leaves room for X */
    border-radius: 14px;
    background: #0f0f0f;
    color: #e5e5e5;
    border: 1px solid #1f1f1f;
    font-size: 15px;
    font-family: 'Ubuntu', sans-serif;
    transition: 0.25s ease;
    box-shadow: 0 0 0 2px #1a1a1a;
    width: 100%;
}

#game-search:focus {
    outline: none;
    background: #151515;
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

#game-search::placeholder {
    color: #777;
}

/* X clear button (consolidated) */
.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #888;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.2s ease;
}

.search-clear:hover {
    color: var(--pink);
}

/* ── Button grid ───────────────────────────────────────────── */
.button-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;   /* centers buttons, even when fewer than a full row */
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

.button-container button {
    flex: 0 1 280px;           /* won't grow past 280px, so they stay equal-sized */
    margin: 0;
    padding: 18px 20px;
    border: 2px solid var(--purple);
    border-radius: 12px;
    font-family: 'Ubuntu', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #F9F6EF;
    background: #190f26;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.button-container button:hover {
    transform: translateY(-4px);
    background: #25163a;
    border-color: var(--pink);
    box-shadow: 0 0 15px rgba(123, 31, 162, 0.7),
                0 0 30px rgba(244, 143, 177, 0.3);
}

.button-container button:active {
    transform: scale(0.95);
}

/* Button images */
.button-container button img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
    display: block;
}

/* Featured container */
#featured-container {
    background-color: rgba(244, 143, 177, 0.1);
    padding: 15px;
    border-left: 4px solid var(--pink);
    margin-bottom: 20px;
}

/* Update badge */
.update-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--purple), var(--violet));
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(123, 31, 162, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
}

.update-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(123, 31, 162, 0.6);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    /* ensure modal overlays the experimental banner */
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: linear-gradient(135deg, #242424 0%, #1a1a1a 100%);
    border: 2px solid var(--pink);
    border-radius: 15px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(244, 143, 177, 0.3);
    animation: slideUp 0.4s ease;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--pink);
    padding-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    background: linear-gradient(to right, var(--purple), var(--violet), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    font-size: 28px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--pink);
    font-size: 28px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.close-btn:hover {
    transform: scale(1.2);
}

.modal-body {
    color: #F9F6EF;
    line-height: 1.6;
    font-size: 16px;
}

.modal-body h3 {
    color: var(--pink);
    margin-top: 15px;
    margin-bottom: 8px;
}

.modal-body ul,
.modal-body ol {
    margin: 10px 0;
    padding-left: 20px;
}

.modal-body li {
    margin: 8px 0;
}

.modal-footer {
    margin-top: 25px;
    text-align: right;
}

.modal-footer button {
    background: linear-gradient(135deg, var(--purple), var(--violet));
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.modal-footer button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 31, 162, 0.4);
}

.modal-footer button:active {
    transform: translateY(0);
}

/* ── Chips ─────────────────────────────────────────────────── */
.chip,
#chip-fav,
#chip-recent,
#chip-all {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    margin: 6px;
    background: #190f26;
    border: 2px solid var(--purple);
    border-radius: 12px;
    color: #F9F6EF;
    font-family: 'Ubuntu', sans-serif;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chip:hover,
#chip-fav:hover,
#chip-recent:hover,
#chip-all:hover {
    transform: translateY(-4px);
    background: #25163a;
    border-color: var(--pink);
    box-shadow: 0 0 15px rgba(123, 31, 162, 0.7),
                0 0 30px rgba(244, 143, 177, 0.3);
}

.chip:active,
#chip-fav:active,
#chip-recent:active,
#chip-all:active {
    transform: scale(0.95);
}

.chip.active {
    background: #25163a;
    border-color: var(--pink);
    box-shadow: 0 0 15px rgba(123, 31, 162, 0.7),
                0 0 30px rgba(244, 143, 177, 0.3);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 10px; }
::-webkit-scrollbar-track { background: #0d0619; }
::-webkit-scrollbar-thumb {
    background: var(--purple);
    border-radius: 10px;
    border: 2px solid #0d0619;
}
::-webkit-scrollbar-thumb:hover { background: var(--pink); }

/* Settings buttons */
.settings-section button {
    background: #190f26;
    border: 2px solid var(--purple);
    border-radius: 12px;
    padding: 10px 18px;
    color: #F9F6EF;
    font-family: 'Ubuntu', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin: 6px 6px 6px 0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.settings-section button:hover {
    transform: translateY(-2px);
    background: #25163a;
    border-color: var(--pink);
    box-shadow: 0 0 12px rgba(123, 31, 162, 0.7),
                0 0 24px rgba(244, 143, 177, 0.3);
}

/* Loading text */
#loading {
    text-align: center;
    font-size: 18px;
    opacity: 0.7;
    margin-top: 20px;
}

/* Surprise Me flash */
#surprise-btn.flash {
    animation: flash 0.4s ease;
}

@keyframes flash {
    0%   { box-shadow: 0 0 0px  var(--pink); }
    50%  { box-shadow: 0 0 20px var(--pink); }
    100% { box-shadow: 0 0 0px  var(--pink); }
}

/* Back to top */
#backTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #190f26;
    border: 2px solid var(--purple);
    border-radius: 50%;
    padding: 10px 14px;
    color: #F9F6EF;
    cursor: pointer;
    transition: 0.3s;
}

#backTop:hover {
    background: #25163a;
    border-color: var(--pink);
    box-shadow: 0 0 15px rgba(123, 31, 162, 0.7);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .modal-content {
        padding: 25px;
        margin: 20px;
    }
    .modal-header h2 { font-size: 22px; }
}

@media (max-width: 480px) {
    .modal-content  { padding: 20px; }
    .update-badge   { padding: 6px 12px; font-size: 12px; }
    .button-container button { flex: 1 1 100%; }
}

/* Experimental version banner */
.experimental-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 9999;
  display: block;
  padding: 14px 20px;
  background: linear-gradient(
    90deg,
    var(--purple),
    var(--violet),
    var(--pink),
    var(--purple)
  );
  background-size: 200% 100%;
  animation: background-pan 3s linear infinite;
  color: white;
  font-family: "Ubuntu", sans-serif;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 18px rgba(123, 31, 162, 0.35);
  transition:
    filter 0.2s ease,
    box-shadow 0.2s ease;
}
.experimental-banner:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 24px rgba(123, 31, 162, 0.5);
}

/* Changelog history */
.modal-footer{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap}
.version-history{display:inline-block;position:relative}
.version-history-toggle{background:linear-gradient(135deg,var(--purple),var(--violet));border:none;color:white;padding:12px 30px;border-radius:5px;cursor:pointer;font-size:16px;font-weight:600;transition:all .3s ease}
.version-history-toggle:hover{transform:translateY(-2px);box-shadow:0 6px 20px rgba(123,31,162,.4)}
.version-history-list{position:absolute;right:0;bottom:calc(100% + 10px);width:min(520px,80vw);max-height:55vh;overflow:auto;padding:12px;background:#1a1a1a;border:1px solid var(--pink);border-radius:12px;text-align:left;box-shadow:0 10px 30px rgba(0,0,0,.5)}
.version-history-list details{padding:10px 0;border-bottom:1px solid rgba(244,143,177,.18)}
.version-history-list details:last-child{border-bottom:0}
.version-history-list summary{cursor:pointer;color:var(--pink);font-weight:600}
.history-entry{padding:8px 4px;color:#F9F6EF}
.history-entry h3{color:var(--pink);font-size:15px}
.history-entry ul{margin:8px 0;padding-left:20px}
@media(max-width:560px){.version-history-list{right:auto;left:0;width:min(88vw,520px)}}
