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

:root {
  --bg-primary: #121213;
  --bg-secondary: #1a1a1b;
  --bg-tertiary: #2d2d2d;
  --text-primary: #ffffff;
  --text-secondary: #818384;
  --correct: #538d4e;
  --correct-dark: #3a6635;
  --close: #b59f3b;
  --close-dark: #8a7a2d;
  --wrong: #3a3a3c;
  --wrong-dark: #2a2a2c;
  --border: #3a3a3c;
  --accent: #6aaa64;
}

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

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.header {
  text-align: center;
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
}

.title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 16px 0;
}

.tab {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 28px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab:first-child {
  border-radius: 6px 0 0 6px;
}

.tab:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.tab.active {
  background: var(--accent);
  color: var(--text-primary);
  border-color: var(--accent);
}

.tab:hover:not(.active) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Game Info */
.game-info {
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
}

/* Search */
.search-container {
  position: relative;
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Autocomplete */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-dropdown.visible {
  display: block;
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.95rem;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--bg-tertiary);
}

/* Grid */
.grid-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.guess-grid {
  min-width: 600px;
}

.guess-row {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}

/* Soccer: player + 6 attrs */
.guess-row {
  grid-template-columns: 1.5fr repeat(var(--cols), 1fr);
}

.guess-header {
  margin-bottom: 8px;
}

.guess-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  word-break: break-word;
  animation: flipIn 0.4s ease both;
}

.header-cell {
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-height: 30px;
  animation: none;
}

.name-cell {
  background: var(--bg-tertiary);
  font-weight: 700;
  font-size: 0.8rem;
  justify-content: flex-start;
  padding-left: 10px;
}

.name-cell.correct {
  background: var(--correct);
}

.guess-cell.correct {
  background: var(--correct);
  color: white;
}

.guess-cell.close {
  background: var(--close);
  color: white;
}

.guess-cell.wrong {
  background: var(--wrong);
  color: var(--text-secondary);
}

@keyframes flipIn {
  0% {
    transform: scaleY(0);
    opacity: 0;
  }
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.visible {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
}

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

.result-text {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 1rem;
}

.target-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.target-details span {
  background: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.share-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 16px;
}

.share-btn:hover {
  opacity: 0.9;
}

.countdown-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.countdown {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Toast */
#toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 24px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transition: all 0.3s;
  z-index: 300;
  pointer-events: none;
}

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

/* Responsive */
@media (max-width: 600px) {
  .app {
    padding: 8px;
  }

  .title {
    font-size: 1.5rem;
  }

  .tab {
    padding: 8px 20px;
    font-size: 0.8rem;
  }

  .guess-cell {
    padding: 8px 4px;
    font-size: 0.7rem;
    min-height: 38px;
  }

  .name-cell {
    font-size: 0.7rem;
  }

  .guess-grid {
    min-width: 520px;
  }
}
