:root{
  --bg:#080c14;
  --card:rgba(12,18,30,0.85);
  --text:#f1f5f9;
  --muted:#8899b0;
  --green:#10b981;
  --yellow:#f59e0b;
  --gray:#2a3444;
  --border:rgba(255,255,255,0.07);
  --tile:rgba(14,20,34,0.8);
  --accent:#e8453c;
  --accent2:#ff8c42;
}

html, body { height: 100%; margin: 0; }

/* ---- City night background ---- */
body{
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

/* Background image */
body::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  background:
    /* Dark overlay for readability */
    linear-gradient(to bottom, rgba(8,12,20,0.75) 0%, rgba(8,12,20,0.5) 40%, rgba(8,12,20,0.3) 100%),
    url('Miami_dark_vroomdle.png') center/cover no-repeat;
}

/* Scanlines */
body::after{
  content:"";
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(255,255,255,0.008) 3px,
      rgba(255,255,255,0.008) 4px
    );
}

/* Cityscape div no longer needed with image bg */
.cityscape{ display:none; }

.wrap{
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ---- Header ---- */
.header{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-bottom:16px;
  text-align:center;
  align-items:center;
}

.header h1{
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header .sub{
  color: var(--muted);
  font-size: 14px;
  margin: 2px 0 6px;
}

.attempts{
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(8px);
  padding: 5px 14px;
  border-radius: 999px;
}

/* ---- Result overlay modal ---- */
.resultOverlay{
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  animation: overlayFadeIn 0.3s ease;
  padding: 20px;
}
.resultOverlay.hidden{ display:none; }

.resultCard{
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 24px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: popIn 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.resultCard.win{
  border-color: rgba(16,185,129,0.3);
  box-shadow: 0 0 80px rgba(16,185,129,0.12), 0 0 30px rgba(16,185,129,0.06);
}
.resultCard.loss{
  border-color: rgba(232,69,60,0.25);
  box-shadow: 0 0 80px rgba(232,69,60,0.1), 0 0 30px rgba(232,69,60,0.05);
}

.resultIcon{
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1;
}

.resultTitle{
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}
.resultCard.win .resultTitle{
  background: linear-gradient(135deg, var(--green) 0%, #34d399 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.resultCard.loss .resultTitle{
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.resultSub{
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.tryAgainBtn{
  margin-top: 16px;
  padding: 10px 28px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(232,69,60,0.15);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s;
}
.tryAgainBtn:hover{ background: rgba(232,69,60,0.25); }

/* ---- Car image in result ---- */
.resultImageWrap{
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.resultImageWrap.hidden{ display:none; }

.resultImage{
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.resultAttribution{
  padding: 6px 10px;
  background: rgba(0,0,0,0.5);
  font-size: 11px;
  color: var(--muted);
}
.resultAttribution a{
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.resultAttribution a:hover{
  color: var(--accent2);
}

.solution{
  text-align: left;
}

@keyframes overlayFadeIn{
  0%{ opacity: 0; }
  100%{ opacity: 1; }
}
@keyframes popIn{
  0%{ transform: scale(0.85); opacity: 0; }
  100%{ transform: scale(1); opacity: 1; }
}

/* ---- Input row ---- */
.inputRow{
  display:flex;
  gap:8px;
  margin: 12px 0 10px;
  align-items: stretch;
}

input{
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 14px;
  outline:none;
  transition: border-color .2s;
  height: 44px;
  box-sizing: border-box;
}
input:focus{ border-color: rgba(232,69,60,0.4); }

button{
  padding: 0 20px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(232,69,60,0.15);
  color: var(--text);
  cursor:pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s;
  box-sizing: border-box;
  flex-shrink: 0;
}
button:hover{ background: rgba(232,69,60,0.25); }
button.secondary{ background: var(--card); }
button.secondary:hover{ background: rgba(255,255,255,0.06); }

/* ---- Legend ---- */
.legend{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom: 12px;
  color:var(--muted);
}
.badge{
  padding:4px 10px;
  border-radius:999px;
  font-size:11px;
  border:1px solid var(--border);
}
.badge.green{ background: rgba(16,185,129,0.15); color: var(--green); }
.badge.yellow{ background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge.gray{ background: rgba(42,52,68,0.3); }
.badge.outline{ background: transparent; }

/* ---- Board ---- */
.board{
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* ---- Guess row: name on top, tiles below ---- */
.guessRow{
  display:flex;
  flex-direction:column;
  gap:0;
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.guessMeta{
  padding: 10px 14px;
  display:flex;
  align-items:center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.guessMeta .name{
  font-size: 15px;
  line-height: 1.2;
}
.guessMeta .brand{
  color: var(--muted);
  font-size: 12px;
}

.tiles{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:0;
}

.tile{
  padding: 10px 14px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:4px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
/* remove right border on last column */
.tile:nth-child(3n){ border-right: none; }
/* remove bottom border on last row */
.tile:nth-child(n+4){ border-bottom: none; }

.label{
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}
.value{
  font-size: 15px;
  font-weight: 600;
  display:flex;
  align-items:center;
  gap:6px;
}

/* ---- Tile states ---- */
.state-green{
  background: rgba(16,185,129,0.12);
}
.state-green .value{ color: var(--green); }

.state-yellow{
  background: rgba(245,158,11,0.10);
}
.state-yellow .value{ color: var(--yellow); }

.state-gray{
  background: transparent;
}

.arrow{ font-size: 14px; opacity: .8; }

/* ---- Flag ---- */
.flag{
  width: 20px;
  height: 14px;
  border-radius: 2px;
  display: inline-block;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
  vertical-align: middle;
}

/* ---- Autocomplete ---- */
.autocomplete{
  position: relative;
  flex: 1;
}

.suggestions{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(12,18,30,0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.suggestions.hidden{ display:none; }

.suggestion{
  padding: 8px 12px;
  cursor: pointer;
  display:flex;
  justify-content: space-between;
  gap: 12px;
  transition: background .15s;
}
.suggestion:hover,
.suggestion.active{
  background: rgba(232,69,60,0.08);
}

.suggestion .smodel{ color: var(--text); font-size: 13px; }
.suggestion .sbrand{ color: var(--muted); font-size: 12px; white-space: nowrap; }

/* ---- Footer ---- */
.footer{
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 640px){
  .wrap{ padding: 16px 10px; }
  .guessRow .tiles{ grid-template-columns: repeat(2, 1fr); }
  .tile:nth-child(3n){ border-right: 1px solid var(--border); }
  .tile:nth-child(2n){ border-right: none; }
  .tile{ border-bottom: 1px solid var(--border); }
  .tile:last-child{ border-bottom: none; }
}
