/* ==========================================================================
   Components: buttons, forms, chips, badges, cards, rows, search, popovers, tables, dialog, toast
   ========================================================================== */

/* ----- buttons -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px; background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 14px; line-height: 1; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-2); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 15px; }
.btn-xl { min-height: 54px; padding: 0 34px; font-size: 18px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-danger { background: color-mix(in srgb, var(--c-red) 20%, var(--surface-2)); border-color: color-mix(in srgb, var(--c-red) 50%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--c-red) 32%, var(--surface-2)); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
  background: transparent; border: 0; border-radius: 8px; color: var(--text-2); transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle { display: inline-flex; }
.show-sm { display: none; }

.dot-count {
  position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--c-red); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 17px; text-align: center;
}
.avatar-btn { background: transparent; border: 0; padding: 4px; border-radius: 50%; }
.avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--av, var(--c-orange)); color: #160f02; font-weight: 800; font-size: 14px; flex: none;
}
.avatar-sm { width: 24px; height: 24px; font-size: 12px; vertical-align: middle; margin-right: 6px; }
.avatar-lg { width: 72px; height: 72px; font-size: 30px; }

/* ----- search ---------------------------------------------------------------------------- */
.search { position: relative; flex: 1 1 auto; max-width: 640px; margin: 0 auto; }
.search input {
  width: 100%; height: 40px; padding: 0 40px 0 42px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); outline: none; font-size: 15px; transition: border-color .12s, background .12s;
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--text-3); }
.search input:hover { border-color: var(--border-2); }
.search input:focus { background: var(--surface-2); border-color: var(--c-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-blue) 25%, transparent); }
.search-icon { position: absolute; left: 13px; top: 10px; color: var(--text-3); pointer-events: none; }
.search-clear { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; display: grid; place-items: center; background: transparent; border: 0; color: var(--text-2); border-radius: 6px; }
.search-clear:hover { background: var(--surface-3); color: var(--text); }
.search-close, .search-open { display: none; }

.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70; max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.suggest-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.suggest-item { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.suggest-item[aria-selected="true"], .suggest-item:hover { background: var(--surface-3); }
.suggest-item img { width: 56px; height: 32px; object-fit: cover; border-radius: 5px; flex: none; background: var(--surface-3); }
.suggest-item strong { display: block; font-weight: 650; }
.suggest-item small { color: var(--text-3); font-size: 12.5px; }
.suggest-item .icon { color: var(--text-3); }
.suggest-all { justify-content: space-between; margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; padding-top: 11px; color: var(--text-2); }
.suggest-empty { padding: 16px 12px; color: var(--text-2); font-size: 14px; }
.suggest mark { background: none; color: var(--c-orange); font-weight: 750; }

/* ----- popovers (user menu, notifications) --------------------------------------------- */
.menu-wrap { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow);
}
.popover a, .popover button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); }
.popover a:hover, .popover button:hover { background: var(--surface-3); }
.popover .icon { color: var(--text-2); }
.user-menu-head { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); display: grid; }
.user-menu-head span { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.notif-panel { width: min(360px, calc(100vw - 20px)); padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.notif-head a { width: auto; padding: 0; color: var(--c-blue); font-size: 13px; font-weight: 600; }
.notif-head a:hover { background: none; text-decoration: underline; }
.notif-items { max-height: 380px; overflow-y: auto; }
.popover .notif-item { align-items: flex-start; padding: 12px 14px; border-radius: 0; }
.notif-item.is-unread { background: color-mix(in srgb, var(--c-orange) 8%, transparent); }
.notif-item strong { display: block; font-size: 14px; font-weight: 650; }
.notif-item small { color: var(--text-3); }
.notif-item p { color: var(--text-2); font-size: 13px; }
.notif-empty { padding: 26px 16px; text-align: center; color: var(--text-2); font-size: 14px; }

/* ----- chips / badges / pills ----------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-center { justify-content: center; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); font-size: 13.5px; font-weight: 550; transition: background .12s, border-color .12s;
}
.chip small { color: var(--text-3); font-size: 12px; font-weight: 600; }
.chip:hover { background: var(--surface-3); border-color: var(--border-2); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.is-active small { color: inherit; }
.chip .icon { color: var(--tint, var(--text-2)); }
.chips-lg .chip { padding: 9px 16px; font-size: 14.5px; }
.chips-filter { margin: 4px 0 20px; }
.chip-more { color: var(--c-blue); }

.badge { display: inline-block; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; line-height: 1.5; }
.badge-new { background: var(--c-green); color: #04180b; }
.badge-upd { background: var(--c-blue); color: #03151d; }
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #fff; background: color-mix(in srgb, var(--tint, var(--c-orange)) 55%, #000); }
.dotsep { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; margin: 0 7px; vertical-align: middle; }

/* ----- game card ------------------------------------------------------------------------- */
.card { position: relative; min-width: 0; }
.card-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .28s ease; }
/* Card preview video */
.card-video { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; pointer-events: none; background: #000; transition: opacity .16s ease; }
.card-thumb.is-video-playing .card-video { opacity: 1; }
.card-thumb.is-video-playing > img { opacity: 0; }
.card-thumb::after { content: ""; position: absolute; inset: 0; background: rgb(0 0 0 / 0); transition: background .18s; pointer-events: none; }
.card-play {
  position: absolute; left: 50%; top: 50%; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 14px; opacity: 0; transform: translate(-50%, -40%); transition: opacity .16s, transform .16s; pointer-events: none;
}
.card-play .icon { width: 16px; height: 16px; fill: currentColor; }
.card .badge { position: absolute; left: 8px; top: 8px; z-index: 2; }
.card-body { padding: 9px 2px 0; }
.card-title { font-size: 14.5px; font-weight: 650; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--r); } /* whole card is one link target */
.card-meta { margin-top: 2px; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .icon { margin: -2px 3px 0 0; }
.fav-btn {
  position: absolute; z-index: 3; right: 7px; top: 7px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: rgb(12 13 15 / .72); color: #fff; opacity: 0; transition: opacity .14s, background .14s, transform .1s;
}
.fav-btn .icon { width: 17px; height: 17px; }
.fav-btn:hover { background: rgb(12 13 15 / .95); }
.fav-btn:active { transform: scale(.92); }
.fav-btn[aria-pressed="true"] { opacity: 1; color: var(--c-pink); }
.fav-btn[aria-pressed="true"] .icon, .fav-act[aria-pressed="true"] .icon { fill: currentColor; }
.card:focus-within .fav-btn, .card:hover .fav-btn { opacity: 1; }
@media (hover: hover) {
  .card:hover .card-thumb img { transform: scale(1.05); }
  .card:hover .card-thumb::after { background: rgb(0 0 0 / .38); }
  .card:hover .card-play, .card:focus-within .card-play { opacity: 1; transform: translate(-50%, -50%); }
}
@media (hover: none) { .fav-btn { opacity: 1; width: 30px; height: 30px; } }
.card:focus-within .card-thumb { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----- grids & horizontal rows ---------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px var(--gap); }
.row-section { margin: 30px 0; }
.row-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.row-head h2, .grid-title, .panel h2 { font-size: 20px; font-weight: 750; line-height: 1.25; letter-spacing: -.005em; }
.row-head p { color: var(--text-3); font-size: 13.5px; }
.row-tools { display: flex; align-items: center; gap: 4px; }
.see-all { margin-right: 6px; color: var(--c-blue); font-weight: 650; font-size: 13.5px; }
.see-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.row-arrow { width: 34px; height: 34px; background: var(--surface-2); }
.row-arrow[disabled] { opacity: .35; pointer-events: none; }
.row-scroll {
  display: grid; grid-auto-flow: column; grid-auto-columns: 220px; gap: var(--gap); overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scrollbar-width: none; padding: 2px 2px 4px; margin: 0 -2px;
}
.row-scroll::-webkit-scrollbar { display: none; }
.row-scroll > .card { scroll-snap-align: start; }
.grid-title { margin: 30px 0 14px; }

/* ----- empty / flash / pagination / tables / segmented --------------------------------- */
.empty { display: grid; justify-items: center; gap: 8px; padding: 44px 20px; border: 1px dashed var(--border-2); border-radius: var(--r); text-align: center; color: var(--text-2); }
.empty h2 { color: var(--text); font-size: 18px; font-weight: 700; }
.empty p { max-width: 460px; }
.empty .btn { margin-top: 8px; }
.empty-icon { width: 34px; height: 34px; color: var(--text-3); }

.flash { margin: 16px 0; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--border-2); background: var(--surface); font-size: 14.5px; }
.flash-ok { border-color: color-mix(in srgb, var(--c-green) 55%, transparent); background: color-mix(in srgb, var(--c-green) 12%, var(--surface)); }
.flash-error { border-color: color-mix(in srgb, var(--c-red) 55%, transparent); background: color-mix(in srgb, var(--c-red) 12%, var(--surface)); }
.flash-info { border-color: color-mix(in srgb, var(--c-blue) 55%, transparent); background: color-mix(in srgb, var(--c-blue) 10%, var(--surface)); }
.flash a { text-decoration: underline; text-underline-offset: 3px; }

.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px; margin: 32px 0 8px; }
.page-btn { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 650; font-size: 14px; }
.page-btn:hover { background: var(--surface-3); }
.page-btn.is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.page-gap { color: var(--text-3); padding: 0 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; font-weight: 750; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td a { color: var(--c-blue); }
.table code { background: var(--surface-3); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.segmented { display: inline-flex; padding: 3px; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.segmented a { padding: 7px 16px; border-radius: 7px; font-weight: 650; font-size: 14px; color: var(--text-2); }
.segmented a.is-active { background: var(--surface-3); color: var(--text); }
.fine { color: var(--text-3); font-size: 13px; }
.no-js-only { display: none; }
html:not(.js) .no-js-only { display: inline-flex; }

/* ----- forms ---------------------------------------------------------------------------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 650; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12.5px; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, .sortbar select, input.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; color: var(--text); outline: none;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .sortbar select:focus { border-color: var(--c-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-blue) 25%, transparent); }
.field.has-error input, .field.has-error textarea { border-color: var(--c-red); }
.field-error { color: #ff8a78; font-size: 13px; font-style: normal; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sortbar { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.sortbar select { width: auto; min-height: 36px; padding: 5px 10px; }
.radio { display: flex; gap: 10px; align-items: center; padding: 8px 4px; cursor: pointer; }
.radio input { accent-color: var(--c-orange); width: 18px; height: 18px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }

/* ----- dialog + toast --------------------------------------------------------------------- */
.dialog { width: min(440px, calc(100vw - 28px)); padding: 22px; background: var(--surface); color: var(--text); border: 1px solid var(--border-2); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(0 0 0 / .65); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { font-size: 18px; }
.form-msg { min-height: 1.2em; font-size: 13.5px; color: var(--text-2); }
.form-msg.is-error { color: #ff8a78; }
.form-msg.is-ok { color: var(--c-green); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 300; max-width: min(92vw, 420px); padding: 11px 18px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 14px; font-weight: 550;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: color-mix(in srgb, var(--c-red) 60%, transparent); }

.ad-slot { display: grid; place-items: center; min-height: 90px; margin: 16px 0; }

@media (max-width: 899.98px) {
  .header { gap: 4px; }
  .hide-sm { display: none !important; }
  .show-sm { display: inline-flex; }
  .search { display: none; }
  .search-open { display: inline-flex; }
  .header.is-searching .brand, .header.is-searching .header-actions, .header.is-searching .nav-toggle { display: none; }
  .header.is-searching .search { display: block; max-width: none; margin: 0; }
  .header.is-searching .search-close { display: grid; position: absolute; left: 0; top: 0; width: 40px; height: 40px; place-items: center; background: none; border: 0; color: var(--text-2); z-index: 2; }
  .header.is-searching .search-icon { display: none; }
  .header.is-searching .search input { padding-left: 42px; }
  .suggest { position: fixed; left: 8px; right: 8px; top: calc(var(--header-h) + 4px); max-height: calc(100dvh - var(--header-h) - 16px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 12px; }
  .row-scroll { grid-auto-columns: 168px; gap: 12px; }
  .row-arrow { display: none; }
  .row-section { margin: 24px 0; }
  .row-head h2, .grid-title, .panel h2 { font-size: 18px; }
}
@media (max-width: 519.98px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-scroll { grid-auto-columns: 150px; }
  .card-title { font-size: 14px; }
  .fav-btn { width: 28px; height: 28px; right: 5px; top: 5px; }
}
