[hidden] { display: none !important; }
:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1f2630; --border: #2d3540;
  --text: #e6edf3; --muted: #8b949e; --accent: #f0b429;
  --match: #2ea043; --partial: #d9822b; --miss: #b62324;
  --row-w: 520px;    /* guess input row width; the board matches it exactly */
  --tile-h: 50px;    /* clue tile height on desktop */
  --gap: 6px;
  /* Column weights: Car, Make, Country (flag + name), Body, Year, HP */
  --cols: minmax(0, 1.35fr) minmax(0, 1.1fr) minmax(0, 1.6fr) minmax(0, 1.1fr) minmax(0, .8fr) minmax(0, .95fr);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: radial-gradient(ellipse 120% 600px at 50% -100px, #1c2533, var(--bg)) no-repeat, var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
header { text-align: center; padding: 28px 16px 8px; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: 1px; }
h1 span { color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 0; }
.banner { display: inline-block; margin-top: 12px; padding: 6px 12px; border-radius: 8px; font-size: .85rem;
  background: #3a2f0b; border: 1px solid #6b5313; color: #f5d27a; }
main { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; padding: 8px 12px 24px; }

.input-area { max-width: var(--row-w); margin: 16px auto 8px; }
.combo { position: relative; display: flex; gap: 8px; }
#guess-input { flex: 1; min-width: 0; padding: 14px 16px; font-size: 1rem; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
#guess-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,180,41,.2); }
#guess-input:disabled { opacity: .5; }
button { padding: 0 18px; font-size: 1rem; font-weight: 600; color: #111; background: var(--accent); border: 0;
  border-radius: 10px; cursor: pointer; transition: filter .15s, transform .05s; }
button:hover:not(:disabled) { filter: brightness(1.1); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
.suggestions { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 4px;
  list-style: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); max-height: 320px; overflow-y: auto; }
.suggestions li { padding: 10px 12px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggestions li small { color: var(--muted); }
.suggestions li.active, .suggestions li:hover { background: var(--panel2); }
.suggestions li mark { background: none; color: var(--accent); font-weight: 700; }
.suggestions li.empty { color: var(--muted); cursor: default; }

.win { max-width: 520px; margin: 16px auto; padding: 18px; text-align: center; background: linear-gradient(160deg, #13301c, var(--panel));
  border: 1px solid #2c6b3b; border-radius: 14px; animation: pop .4s ease; }
.win.lost { background: linear-gradient(160deg, #3a1416, var(--panel)); border-color: #7a2a2d; }
.win h2 { margin: 0 0 6px; }
.win-car { font-size: 1.3rem; font-weight: 700; color: var(--accent); margin: 8px 0; }
.win-car small { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); margin-top: 4px; }
.win-actions { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; }
.win-actions button { padding: 10px 16px; }
.share-status { color: var(--muted); font-size: .85rem; }
.countdown { color: var(--muted); margin: 12px 0 0; }
.countdown strong { color: var(--text); font-variant-numeric: tabular-nums; }
.clue { max-width: var(--row-w); margin: 12px auto 0; }
.clue-canvas { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.clue-stages { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.clue-stages button { width: 26px; height: 26px; padding: 0; border-radius: 50%; font-size: .72rem; font-weight: 700;
  color: var(--muted); background: var(--panel2); border: 1px solid var(--border); }
.clue-stages button:not(:disabled):hover { filter: brightness(1.25); }
.clue-stages button.active { color: #111; background: var(--accent); border-color: var(--accent); }
.clue-stages button:disabled { opacity: .35; }
.clue-credit { margin: 6px 0 0; text-align: center; font-size: .72rem; color: var(--muted); }
.clue-credit a { color: var(--muted); text-decoration: underline; text-decoration-color: rgba(139,148,158,.5); }
.clue-credit a:hover { color: var(--text); }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.board-wrap { overflow-x: auto; padding-bottom: 6px; margin-top: 12px; }
.board { width: 100%; max-width: var(--row-w); margin: 0 auto; }
.row { display: grid; grid-template-columns: var(--cols); gap: var(--gap); margin-bottom: var(--gap); }
.row.header div { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  text-align: center; padding-bottom: 4px; border-bottom: 2px solid var(--border); }
.cell { height: var(--tile-h); perspective: 600px; }
.cell .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.cell.flip .inner { animation: flip .5s ease both; animation-delay: var(--d, 0s); }
@keyframes flip { 0% { transform: rotateX(-90deg); } 100% { transform: rotateX(0deg); } }
.face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3px; border-radius: 7px; text-align: center; font-size: .7rem; font-weight: 600; line-height: 1.1;
  overflow: hidden; overflow-wrap: normal; word-break: normal; border: 1px solid rgba(255,255,255,.08); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
  backface-visibility: hidden; }
.face.match { background: var(--match); }
.face.partial { background: var(--partial); }
.face.miss { background: var(--miss); }
.face.name { background: var(--panel2); font-size: .7rem; }
.face.name.match { background: var(--match); }
.face .val { max-width: 100%; }
.face.country { flex-direction: row; gap: 5px; } /* name, then flag to its right */
.face.country .val { white-space: nowrap; text-align: left; }
.face .flag { display: block; flex: none; width: 20px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.25); object-fit: cover; }
.flag-inline { width: 16px; height: 12px; vertical-align: -1px; margin-left: 5px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.face .arrow { font-size: 1rem; line-height: 1; margin-top: 2px; opacity: .95; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 16px; }

@media (max-width: 720px) {
  /* 6 fluid columns that fit the viewport, no horizontal scroll */
  /* Same column weights as desktop, board = input row width; tiles 44px tall */
  :root { --gap: 4px; --tile-h: 44px; }
  .row.header div { font-size: .56rem; letter-spacing: .02em; }
  .face { font-size: .62rem; letter-spacing: -.01em; padding: 2px; border-radius: 6px; }
  .face.name { font-size: .62rem; }
  .face .arrow { font-size: .8rem; margin-top: 1px; }
  .face .flag { width: 16px; height: 12px; }
  .face.country { gap: 3px; }
  .face.country .val { white-space: normal; } /* long names may wrap (flag stays to the right) on narrow phones */
}
@media (prefers-reduced-motion: reduce) {
  .cell.flip .inner { animation: none; transform: none; }
  .win { animation: none; }
}
