/* ============ Theme tokens ============ */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="light"] {
  --bg: #f7f5f2;
  --bg-card: #ffffff;
  --bg-inset: #efece7;
  --bg-input: #ffffff;
  --text: #1f2125;
  --text-dim: #6c6f76;
  --border: #e2ded8;
  --shadow: 0 1px 3px rgba(20, 20, 30, .07), 0 8px 24px rgba(20, 20, 30, .06);
  --accent: #e0565b;
  --accent-text: #ffffff;
  --c-win: #149e6c;
  --c-hot: #d9a514;
  --c-warm: #e07a2e;
  --c-cold: #4f86d8;
  --overlay: rgba(30, 28, 26, .45);
}

html[data-theme="dark"] {
  --bg: #131417;
  --bg-card: #1c1e23;
  --bg-inset: #24262c;
  --bg-input: #16181c;
  --text: #ecedef;
  --text-dim: #9a9da6;
  --border: #2e3138;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --accent: #ff5a5f;
  --accent-text: #ffffff;
  --c-win: #2bd394;
  --c-hot: #f2c245;
  --c-warm: #f0884a;
  --c-cold: #6ba3f5;
  --overlay: rgba(0, 0, 0, .6);
}

/* ============ Base ============ */
* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

button { font-family: inherit; }

/* ============ Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.logo {
  margin: 0;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  font-weight: 800;
  letter-spacing: .04em;
}

.logo-bnb { color: var(--accent); }

.header-actions { display: flex; gap: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease;
}

.icon-btn:hover { background: var(--bg-inset); }
.icon-btn:active { transform: scale(.93); }
.icon-btn svg { width: 20px; height: 20px; }

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

/* ============ Layout + ad slots ============ */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  gap: 24px;
  justify-content: center;
}

.game {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ad-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}

.ad-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: .7;
}

.ad-top {
  max-width: 1200px;
  margin: 12px auto 0;
  min-height: 90px;          /* leaderboard space reserved — no layout shift */
  width: calc(100% - 32px);
}

.ad-side {
  display: none;             /* desktop only */
  width: 300px;
  min-height: 600px;         /* 300x600 half-page unit */
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: 76px;
}

.ad-bottom {
  max-width: var(--maxw);
  margin: 8px auto 16px;
  min-height: 100px;
  width: calc(100% - 32px);
}

@media (min-width: 1100px) {
  .ad-side { display: flex; }
}

/* ============ Property card ============ */
.property-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.photo-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: repeat(2, minmax(110px, min(22vw, 205px)));
  gap: 4px;
}

.photo {
  border: 0;
  padding: 0;
  background: var(--bg-inset);
  cursor: zoom-in;
  overflow: hidden;
  position: relative;
}

.photo:first-child { grid-row: span 2; }

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

.photo:hover img { transform: scale(1.04); }

.photo.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 8%, transparent) 50%, transparent 70%);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

.property-meta { padding: 16px 18px 18px; }

.property-title {
  margin: 0 0 10px;
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: 700;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: .85rem;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  animation: chip-in .3s ease;
}

.chip.locked { opacity: .55; font-style: italic; }
.chip strong { font-weight: 700; }

@keyframes chip-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ============ Guesses ============ */
.guess-area {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guess-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.guess-row .row-num { color: var(--text-dim); font-size: .85rem; }
.guess-row .row-guess { font-weight: 700; font-size: 1.05rem; }
.guess-row .row-hint { font-size: .85rem; color: var(--text-dim); }
.guess-row .row-arrow { font-size: 1.2rem; font-weight: 800; width: 1.4em; text-align: center; }

.guess-row.filled { animation: pop-in .25s ease; }

.guess-row.r-win  { background: color-mix(in srgb, var(--c-win) 18%, var(--bg-inset));  border-color: var(--c-win); }
.guess-row.r-hot  { background: color-mix(in srgb, var(--c-hot) 16%, var(--bg-inset));  border-color: var(--c-hot); }
.guess-row.r-warm { background: color-mix(in srgb, var(--c-warm) 16%, var(--bg-inset)); border-color: var(--c-warm); }
.guess-row.r-cold { background: color-mix(in srgb, var(--c-cold) 14%, var(--bg-inset)); border-color: var(--c-cold); }

.guess-row.r-win .row-arrow  { color: var(--c-win); }
.guess-row.r-hot .row-arrow  { color: var(--c-hot); }
.guess-row.r-warm .row-arrow { color: var(--c-warm); }
.guess-row.r-cold .row-arrow { color: var(--c-cold); }

@keyframes pop-in {
  0% { transform: scale(.97); opacity: .4; }
  60% { transform: scale(1.01); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============ Input ============ */
.guess-form { display: flex; gap: 10px; }

.guess-input-wrap {
  flex: 1;
  min-width: 0;          /* allow the input to shrink so the Guess button stays in the card */
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color .15s ease;
}

.guess-input-wrap:focus-within { border-color: var(--accent); }

.currency-prefix { color: var(--text-dim); font-weight: 700; margin-right: 6px; }

#guess-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 13px 0;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.btn-primary, .btn-secondary {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}

.btn-primary { background: var(--accent); color: var(--accent-text); }
.guess-form .btn-primary { flex-shrink: 0; }
.btn-secondary { background: var(--bg-inset); color: var(--text); border: 1px solid var(--border); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active, .btn-secondary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.feedback-line {
  margin: 0;
  min-height: 1.4em;
  text-align: center;
  font-weight: 600;
  color: var(--text-dim);
}

/* ============ Result ============ */
.result-panel {
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: chip-in .4s ease;
}

.result-panel.hidden { display: none; }

.result-headline { margin: 0; font-size: 1.15rem; font-weight: 800; }
.result-price { margin: 0; font-size: 2rem; font-weight: 800; color: var(--c-win); font-variant-numeric: tabular-nums; }
.result-actions { display: flex; gap: 10px; justify-content: center; }
.countdown { margin: 0; color: var(--text-dim); font-size: .9rem; }
.countdown strong { font-variant-numeric: tabular-nums; }

/* ============ Modals ============ */
.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
}

.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 12px 20px 20px; }
.modal-body h3 { font-size: .95rem; margin: 18px 0 8px; }

.help-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.help-list li { display: flex; align-items: center; gap: 10px; }

.swatch {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
}
.s-win  { background: color-mix(in srgb, var(--c-win) 30%, transparent); }
.s-hot  { background: var(--c-hot); }
.s-warm { background: var(--c-warm); }
.s-cold { background: var(--c-cold); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-cell { background: var(--bg-inset); border-radius: var(--radius-sm); padding: 10px 4px; }
.stat-cell .num { font-size: 1.5rem; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.stat-cell .lbl { font-size: .7rem; color: var(--text-dim); }

.distribution { display: flex; flex-direction: column; gap: 5px; }

.dist-row { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.dist-row .bar {
  background: var(--bg-inset);
  border-radius: 4px;
  min-width: 24px;
  padding: 2px 8px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dist-row.best .bar { background: var(--c-win); color: #fff; }

/* ============ Lightbox ============ */
.lightbox {
  width: min(960px, calc(100vw - 24px));
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.lightbox-inner {
  position: relative;
}

.lightbox img {
  width: 100%;
  border-radius: var(--radius);
  display: block;
  pointer-events: none;
  user-select: none;
}

.lightbox-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.lightbox-controls > * {
  pointer-events: auto;
}

.lightbox-close {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 3;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  margin-top: -20px;
  z-index: 3;
  font-size: 1.6rem;
  line-height: 1;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  backdrop-filter: blur(4px);
}

.lightbox-nav:hover { background: var(--bg-card); }
.lightbox-nav:active { transform: scale(.93); }

.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }

.lightbox-counter {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  backdrop-filter: blur(4px);
  color: var(--text);
}

.lightbox.single .lightbox-nav,
.lightbox.single .lightbox-counter { display: none; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ About / FAQ accordion (SEO content) ============ */
.about {
  max-width: var(--maxw);
  margin: 8px auto 0;
  padding: 0 16px 8px;
}

.about-heading {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin: 22px 4px 8px;
}

.acc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.acc > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.acc > summary::-webkit-details-marker { display: none; }

.acc > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg);
  transition: transform .2s ease;
  flex-shrink: 0;
  margin-right: 4px;
}

.acc[open] > summary::after { transform: rotate(225deg); }
.acc > summary:hover { background: var(--bg-inset); }

.acc-body {
  padding: 0 16px 14px;
  color: var(--text-dim);
  font-size: .92rem;
  line-height: 1.65;
}
.acc-body p { margin: 0 0 10px; }
.acc-body p:last-child { margin-bottom: 0; }
.acc-body strong { color: var(--text); }

/* ============ Footer ============ */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 16px 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: .78rem;
}

/* ============ Small screens ============ */
@media (max-width: 480px) {
  .page { padding: 12px; }
  .guess-area, .property-meta { padding: 14px; }
  .photo-grid { grid-template-rows: repeat(2, minmax(90px, 26vw)); }
  .guess-row { padding: 0 10px; gap: 7px; min-height: 48px; }
  .row-hint { display: none; }   /* keep rows compact; color + arrow carry the info */
  .btn-primary { padding: 13px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
