/* ── Reset ─────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root {
  --bg:         #0d0f0d;
  --surface:    #141714;
  --surface-2:  #1b1e1b;
  --border:     #252825;
  --border-2:   #2f342f;
  --green:      #2ecc71;
  --green-dim:  #1a7a42;
  --green-glow: rgba(46,204,113,.12);
  --green-muted:#1d4a2a;
  --red:        #e55353;
  --red-bg:     rgba(229,83,83,.1);
  --yellow:     #f0a500;
  --yellow-bg:  rgba(240,165,0,.1);
  --text:       #e8ece8;
  --text-muted: #6b7d6b;
  --text-dim:   #3d4d3d;
  --white:      #ffffff;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --radius:     8px;
  --sidebar-w:  300px;
  --header-h:   52px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ── Loading ───────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.loading-inner { text-align: center; }
.loading-inner h2 { font-size: 1.2rem; font-weight: 600; margin: 1rem 0 .4rem; color: var(--text); letter-spacing: .05em; }
.loading-inner p  { font-size: .8rem; color: var(--text-muted); margin-top: .75rem; }
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border-2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: .75rem auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── S logo ────────────────────────────────────────── */
.s-logo {
  width: 64px; height: 64px;
  background: var(--green-muted);
  border: 1px solid var(--green-dim);
  color: var(--green);
  border-radius: 12px; font-size: 2rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center; margin: 0 auto;
  box-shadow: 0 0 24px var(--green-glow);
}
.s-logo-sm {
  width: 28px; height: 28px;
  background: var(--green-muted);
  border: 1px solid var(--green-dim);
  color: var(--green);
  border-radius: 6px; font-size: 1rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ── Header ────────────────────────────────────────── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 1rem;
  display: flex; align-items: center; gap: .75rem;
  height: 100%;
}
.title {
  font-size: 1rem; font-weight: 700;
  color: var(--text);
  letter-spacing: .08em;
  text-transform: uppercase;
  flex: 1;
}
.header-right { display: flex; align-items: center; gap: .5rem; }

.mode-toggle { display: flex; gap: .3rem; }
.mode-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: .3rem .75rem;
  border-radius: 5px;
  font-size: .75rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  text-transform: uppercase; letter-spacing: .05em;
}
.mode-btn:hover { border-color: var(--green); color: var(--green); }
.mode-btn.active {
  background: var(--green-muted);
  border-color: var(--green-dim);
  color: var(--green);
}
.sidebar-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: .3rem .6rem;
  border-radius: 5px; font-size: .9rem; cursor: pointer; transition: all .15s;
}
.sidebar-toggle-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Layout ────────────────────────────────────────── */
.app { min-height: 100vh; }
.layout {
  display: flex; max-width: 1200px;
  margin: 0 auto; align-items: flex-start;
  padding-bottom: 3rem;
}
.game-col { flex: 1; min-width: 0; padding: 1rem; }

/* ── How to play ───────────────────────────────────── */
.how-to-play { margin-bottom: .75rem; }
.how-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: .28rem .7rem;
  border-radius: 5px; font-size: .75rem;
  cursor: pointer; transition: all .15s;
  letter-spacing: .03em;
}
.how-btn:hover { border-color: var(--green); color: var(--green); }
.how-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-top: .4rem;
  font-size: .82rem; line-height: 1.65;
  color: var(--text-muted);
}
.legend { display: flex; gap: .4rem; margin: .5rem 0; flex-wrap: wrap; }
.chip {
  padding: .18rem .6rem; border-radius: 4px;
  font-weight: 600; font-size: .75rem;
  border: 1px solid;
}
.chip.correct   { background: rgba(46,204,113,.1); color: var(--green); border-color: var(--green-dim); }
.chip.close     { background: var(--yellow-bg);    color: var(--yellow); border-color: rgba(240,165,0,.3); }
.chip.incorrect { background: var(--red-bg);       color: var(--red);    border-color: rgba(229,83,83,.3); }

/* ── Status bar ────────────────────────────────────── */
.status-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .6rem;
}
.status-text   { font-size: .75rem; color: var(--text-muted); letter-spacing: .03em; text-transform: uppercase; }
.guess-counter { font-size: .75rem; font-weight: 700; color: var(--green); letter-spacing: .05em; }

/* ── Search ────────────────────────────────────────── */
.input-area { margin-bottom: .75rem; }
.search-wrap { position: relative; }
.search-input {
  width: 100%;
  padding: .65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus {
  border-color: var(--green-dim);
  box-shadow: 0 0 0 3px var(--green-glow);
}
.search-input:disabled {
  background: var(--surface-2); cursor: not-allowed; color: var(--text-muted);
}

.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  max-height: 320px; overflow-y: auto;
  z-index: 100; box-shadow: var(--shadow);
}
.dropdown-item {
  padding: .5rem .75rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem;
  transition: background .1s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover, .dropdown-item.active { background: var(--surface-2); }
.dropdown-item.no-result  { color: var(--text-muted); font-style: italic; cursor: default; font-size: .82rem; }
.dropdown-item.already    { opacity: .35; cursor: not-allowed; }
.di-thumb { width: 38px; height: 38px; object-fit: contain; border-radius: 5px; background: var(--surface-2); flex-shrink: 0; border: 1px solid var(--border); }
.di-thumb-ph { width: 38px; height: 38px; flex-shrink: 0; background: var(--surface-2); border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--text-dim); border: 1px solid var(--border); }
.di-info { min-width: 0; flex: 1; }
.di-name { font-weight: 600; font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.di-meta { font-size: .72rem; color: var(--text-muted); }
.di-price { font-weight: 700; font-size: .85rem; color: var(--green); white-space: nowrap; }
.di-thumb-ph { color: var(--text-dim); }
mark { background: var(--green-muted); color: var(--green); border-radius: 2px; padding: 0 1px; }

/* ── Guess table ───────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-bottom: .75rem; }
.guess-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.guess-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  padding: .5rem .4rem;
  font-size: .7rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.guess-table thead th.col-product { text-align: left; padding-left: .75rem; }
.guess-table tbody tr { border-bottom: 1px solid var(--border); animation: rowIn .2s ease; }
.guess-table tbody tr:last-child { border-bottom: none; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.guess-table td { padding: .5rem .4rem; text-align: center; vertical-align: middle; font-size: .82rem; }
.guess-table td.col-product { text-align: left; padding-left: .75rem; }
.cell-product { display: flex; align-items: center; gap: .5rem; }
.cell-thumb { width: 34px; height: 34px; object-fit: contain; border-radius: 4px; background: var(--surface-2); flex-shrink: 0; border: 1px solid var(--border); }
.cell-thumb-ph { width: 34px; height: 34px; flex-shrink: 0; background: var(--surface-2); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: .9rem; color: var(--text-dim); border: 1px solid var(--border); }
.cell-name  { font-weight: 600; font-size: .83rem; color: var(--text); line-height: 1.3; }
.cell-brand { font-size: .7rem; color: var(--text-muted); }

/* Hint states */
.hint-correct   { background: rgba(46,204,113,.1);  color: #2ecc71; font-weight: 600; }
.hint-close     { background: rgba(240,165,0,.1);   color: #f0a500; font-weight: 600; }
.hint-incorrect { background: rgba(229,83,83,.08);  color: #e55353; font-weight: 600; }
.hint-unknown   { background: transparent;           color: var(--text-muted); }

.price-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.price-main { font-size: .85rem; font-weight: 700; }
.price-arrow { font-size: .85rem; line-height: 1; }
.price-sub  { font-size: .65rem; opacity: .7; }

.empty-state {
  text-align: center; padding: 2.5rem;
  color: var(--text-muted); font-size: .82rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
  letter-spacing: .03em;
}

/* ── Game over ─────────────────────────────────────── */
.game-over-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-top: .75rem;
  animation: rowIn .25s ease;
}
.game-over-icon { font-size: 2.2rem; margin-bottom: .4rem; }
.game-over-panel h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .25rem; letter-spacing: .03em; }
.game-over-panel p  { color: var(--text-muted); font-size: .83rem; margin-bottom: .75rem; }

.answer-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: .8rem 1rem;
  margin: .6rem 0 .9rem;
  text-align: left;
  font-size: .83rem; line-height: 1.7;
}
.answer-card-inner { display: flex; gap: .75rem; align-items: flex-start; }
.answer-img { width: 68px; height: 68px; object-fit: contain; border-radius: 6px; background: var(--surface); flex-shrink: 0; border: 1px solid var(--border); }
.answer-img-ph { width: 68px; height: 68px; flex-shrink: 0; background: var(--surface); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: var(--text-dim); border: 1px solid var(--border); }
.answer-details { flex: 1; min-width: 0; }
.answer-name  { font-size: .95rem; font-weight: 700; color: var(--text); }
.answer-price { font-size: 1.2rem; font-weight: 800; color: var(--green); }
.answer-row   { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .35rem; }
.answer-chip  { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 4px; padding: .1rem .4rem; font-size: .72rem; color: var(--text-muted); }

.game-over-buttons { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.btn { padding: .55rem 1.1rem; border-radius: 6px; border: 1px solid; font-size: .82rem; font-weight: 600; cursor: pointer; transition: all .15s; letter-spacing: .04em; text-transform: uppercase; }
.btn-share { background: var(--green-muted); border-color: var(--green-dim); color: var(--green); }
.btn-share:hover { background: #1f5c35; border-color: var(--green); }
.btn-new { background: transparent; border-color: var(--border-2); color: var(--text-muted); }
.btn-new:hover { border-color: var(--green); color: var(--green); }

.copy-toast {
  margin-top: .6rem;
  background: var(--green-muted);
  color: var(--green);
  border: 1px solid var(--green-dim);
  padding: .3rem .8rem; border-radius: 5px;
  font-size: .78rem; font-weight: 600;
  display: inline-block;
  animation: fadeOut 2.5s forwards;
}
@keyframes fadeOut { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

.resume-banner {
  background: rgba(46,204,113,.07);
  border: 1px solid var(--green-dim);
  color: var(--green);
  border-radius: var(--radius);
  padding: .5rem .85rem;
  font-size: .78rem; font-weight: 600;
  margin-bottom: .75rem;
  letter-spacing: .02em;
  animation: rowIn .3s ease, fadeOut 4s forwards;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}
.sidebar-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-title { font-weight: 700; font-size: .72rem; flex: 1; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.sidebar-count { font-size: .72rem; color: var(--green); font-weight: 600; }
.sidebar-close { background: none; border: none; cursor: pointer; font-size: .9rem; color: var(--text-muted); display: none; }

.sidebar-filters {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: .4rem;
  flex-shrink: 0;
}
.filter-select {
  width: 100%; padding: .38rem .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text);
  font-size: .8rem; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--green-dim); }
.filter-select:disabled { opacity: .5; cursor: not-allowed; }
.filter-select option { background: var(--surface-2); }

.price-range-row { display: flex; align-items: center; justify-content: space-between; }
.price-range-row label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.price-range-label { font-size: .75rem; font-weight: 600; color: var(--green); }
.price-inputs { display: flex; align-items: center; gap: .4rem; }
.price-inputs span { color: var(--text-dim); }
.price-input {
  flex: 1; padding: .36rem .45rem;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  color: var(--text);
  font-size: .8rem; outline: none; min-width: 0;
}
.price-input:focus { border-color: var(--green-dim); }
.price-input:disabled { opacity: .5; cursor: not-allowed; }

.filter-btns { display: flex; gap: .4rem; }
.btn-browse { flex: 1; background: var(--green-muted); border-color: var(--green-dim); color: var(--green); padding: .38rem; font-size: .78rem; }
.btn-browse:hover { background: #1f5c35; border-color: var(--green); }
.btn-reset { background: transparent; border-color: var(--border-2); color: var(--text-muted); padding: .38rem; font-size: .75rem; }
.btn-reset:hover { border-color: var(--green-dim); color: var(--green); }

/* Product list */
.product-grid { flex: 1; overflow-y: auto; padding: .4rem; display: flex; flex-direction: column; gap: .3rem; }
.grid-placeholder { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: .78rem; line-height: 1.6; }
.grid-loading { padding: 1rem; text-align: center; color: var(--text-muted); font-size: .78rem; }
.product-card {
  border: 1px solid var(--border);
  border-radius: 6px; padding: .42rem .55rem;
  background: var(--surface-2);
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer; transition: all .12s;
  overflow: hidden; min-height: 52px;
}
.product-card:hover { border-color: var(--green-dim); background: rgba(46,204,113,.05); }
.product-card.already-guessed { opacity: .28; cursor: not-allowed; }
.pc-img { width: 40px; height: 40px; object-fit: contain; background: var(--surface); border-radius: 4px; flex-shrink: 0; border: 1px solid var(--border); }
.pc-img-ph { width: 40px; height: 40px; background: var(--surface); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: var(--text-dim); flex-shrink: 0; border: 1px solid var(--border); }
.pc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pc-name { font-size: .75rem; font-weight: 600; line-height: 1.35; color: var(--text); word-break: break-word; }
.pc-brand { font-size: .68rem; color: var(--text-muted); }
.pc-price { font-size: .8rem; font-weight: 800; color: var(--green); white-space: nowrap; flex-shrink: 0; }

/* Pagination */
.sidebar-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem .85rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0; gap: .5rem;
}
.page-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  padding: .28rem .6rem; border-radius: 5px;
  font-size: .75rem; cursor: pointer; transition: all .12s;
}
.page-btn:hover:not(:disabled) { border-color: var(--green-dim); color: var(--green); }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }
.page-info { font-size: .72rem; color: var(--text-muted); text-align: center; flex: 1; letter-spacing: .03em; }

/* Ads */
.ad-container { width: 100%; text-align: center; margin-top: .75rem; min-height: 90px; }
.ad-container ins { display: block; }
.ad-sidebar { border-top: 1px solid var(--border); padding: .5rem; background: var(--surface-2); flex-shrink: 0; }

/* Mobile overlay */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 80; }

/* ── Footer ────────────────────────────────────────── */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 2rem; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: .85rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; }
.footer-fi, .footer-en { font-size: .72rem; line-height: 1.6; margin: 0; color: var(--text-muted); }
.footer-en strong { color: var(--text); font-weight: 600; }
.footer-link { color: var(--green); text-decoration: none; }
.footer-link:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(var(--sidebar-w), 92vw);
    z-index: 90;
    transform: translateX(100%);
    transition: transform .22s ease;
    min-height: unset; height: 100vh;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .layout { flex-direction: column; }
  .game-col { padding: .6rem .75rem; }
}
@media (min-width: 769px) {
  .sidebar-toggle-btn { display: none; }
  .sidebar-overlay { display: none !important; }
}

/* Scrollbar styling for dark theme */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-dim); }

/* ── Side ad columns ───────────────────────────────── */
.ad-col {
  width: 160px;
  flex-shrink: 0;
  padding: 1rem .5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}
.ad-col-unit {
  width: 160px;
  min-height: 600px;
}
/* Hide side ad columns on smaller screens */
@media (max-width: 1100px) {
  .ad-col { display: none !important; }
}
