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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #475569;
  --accent: #6366f1;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.container { width: 100%; max-width: 900px; }

.site-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 0; }
.site-nav .brand { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.1em; color: var(--accent); text-decoration: none; }
.site-nav .nav-links { display: flex; gap: 18px; }
.site-nav .nav-links a { color: var(--text-dim); text-decoration: none; font-size: 0.9rem; }
.site-nav .nav-links a:hover { color: var(--text); }

header { text-align: center; padding: 30px 0 20px; }

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.subtitle { color: var(--text-dim); margin-top: 6px; font-size: 0.95rem; }

/* Input */
.input-row { position: relative; margin-bottom: 16px; }

#guess-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 1.1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

#guess-input:focus { border-color: var(--accent); }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}

.suggestions.active { display: block; }

.suggestion-item {
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.active { background: var(--accent); }

/* Table */
.guess-table-wrap { overflow-x: auto; margin-bottom: 16px; }

#guess-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#guess-table th {
  padding: 10px 6px;
  text-align: center;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

#guess-table th.col-guess { width: 30px; }

#guess-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#guess-table td.col-name { text-align: left; font-weight: 600; }

.cell-green  { background: var(--green); color: #000; font-weight: 700; border-radius: 4px; }
.cell-orange { background: var(--orange); color: #000; font-weight: 700; border-radius: 4px; }
.cell-red    { background: var(--red); color: var(--text-dim); border-radius: 4px; }

#message {
  text-align: center;
  padding: 10px;
  min-height: 40px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

#message.error { color: #f87171; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.modal-content h2 { font-size: 1.6rem; margin-bottom: 8px; }

#result-answer { color: var(--text-dim); margin-bottom: 18px; }

#share-grid {
  font-family: monospace;
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 20px;
  letter-spacing: 0.15em;
}

.result-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-primary:hover, .btn-secondary:hover { opacity: 0.85; }

#countdown-text { margin-top: 14px; font-size: 0.8rem; color: var(--text-dim); }

.legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  padding: 20px 0;
  flex-wrap: wrap;
}

.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-dim); }

.dot { width: 14px; height: 14px; border-radius: 4px; }
.dot.green  { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.red    { background: var(--red); }

@media (max-width: 600px) {
  h1 { font-size: 1.8rem; }
  #guess-table { font-size: 0.7rem; }
  #guess-table th, #guess-table td { padding: 6px 3px; }
}
