:root {
  --bg-main: #eee7d4;
  --bg-card: #f9f6ef;
  --bg-correct: #d8eed5;
  --text-correct: #276738;
  --text-dark: #111111;
  --text-red: #c93b2b;
  --border-color: #222222;
  --border-thick: 3px solid var(--border-color);
  --border-thin: 2px solid var(--border-color);
  --p1-color: #2b6cb0;
  --p2-color: #c53030;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px;
}

.app-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--text-dark);
}

.brand-subtitle {
  font-size: 15px;
  font-weight: 900;
  color: #d95328;
}

.status-bar {
  display: flex;
  gap: 10px;
}

.stat-pill {
  background: var(--bg-card);
  border: var(--border-thin);
  border-radius: 6px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pill-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-red);
  letter-spacing: 0.5px;
}

.pill-value {
  font-size: 13px;
  font-weight: 800;
}

/* Controls */
.controls-bar {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.custom-select {
  flex: 1;
  background: var(--bg-card);
  border: var(--border-thin);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  outline: none;
  cursor: pointer;
}

.mode-toggle {
  display: flex;
  border: var(--border-thin);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-card);
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: var(--border-color);
  color: #fff;
}

.pvp-indicator {
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  padding: 6px;
  background: var(--bg-card);
  border: var(--border-thin);
  border-radius: 6px;
}
.player-p1 { color: var(--p1-color); }
.player-p2 { color: var(--p2-color); }

/* 3x3 Board */
.grid-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: var(--border-thick);
  background: var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.football-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
}

.grid-cell {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  text-align: center;
  padding: 4px;
  user-select: none;
}

/* Corner Logo */
.corner-cell {
  background: #111;
  color: #fff;
}
.corner-logo span {
  font-size: 13px;
  font-weight: 900;
  display: block;
}
.corner-logo small {
  font-size: 11px;
  font-weight: 900;
  color: #e65c00;
}

/* Header Cells */
.header-cell {
  background: #f4eee2;
}

.header-category {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-red);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.header-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  margin-bottom: 3px;
}

.header-name {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-dark);
}

/* Play Cells */
.play-cell {
  cursor: pointer;
  background: var(--bg-card);
  transition: transform 0.1s, background-color 0.2s;
}

.play-cell:active {
  transform: scale(0.97);
}

.add-circle {
  width: 38px;
  height: 38px;
  border: 2px solid #b8aa94;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  color: #9c8c74;
  font-weight: 300;
}

/* Correct Filled Cell */
.play-cell.solved {
  background-color: var(--bg-correct);
  cursor: default;
}

.play-cell.solved-p1 {
  background-color: #e2eaf5;
  border: 2px solid var(--p1-color);
}

.play-cell.solved-p2 {
  background-color: #fce8e8;
  border: 2px solid var(--p2-color);
}

.player-card-name {
  font-size: 13px;
  font-weight: 900;
  line-height: 1.15;
  color: #111;
  margin-bottom: 3px;
  text-transform: uppercase;
  max-width: 90%;
  word-break: break-word;
}

.player-card-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-correct);
  letter-spacing: 0.3px;
}

/* Action Buttons */
.actions-bar {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  padding: 10px;
  border: var(--border-thin);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-dark);
  transition: all 0.2s;
}

.action-btn:hover {
  background: #ede6d6;
}

.surrender-btn {
  color: var(--text-red);
}

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

.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 520px;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border: var(--border-thick);
  border-bottom: none;
  padding: 16px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

#modal-criteria-title {
  font-size: 16px;
  font-weight: 800;
}

.modal-subtitle {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #555;
}

.search-input-wrap {
  position: relative;
  margin-bottom: 8px;
}

#player-search-input {
  width: 100%;
  padding: 12px 14px;
  border: var(--border-thin);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  background: #fff;
  outline: none;
}

#player-search-input:focus {
  border-color: #000;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.search-error {
  background: #fde8e8;
  color: #c53030;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.search-results {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
}

.search-hint {
  text-align: center;
  color: #888;
  font-size: 13px;
  padding: 20px 0;
}

.candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.candidate-item:hover, .candidate-item:active {
  background: #f0f7ee;
  border-color: #276738;
}

.candidate-info {
  display: flex;
  flex-direction: column;
}

.candidate-name {
  font-size: 14px;
  font-weight: 800;
}

.candidate-meta {
  font-size: 11px;
  color: #777;
}

.candidate-select-arrow {
  font-size: 16px;
  color: #888;
}

/* Solutions Modal */
.solutions-content {
  max-height: 85vh;
}

.solutions-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.solution-cell-card {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 10px;
}

.solution-cell-header {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-red);
  margin-bottom: 4px;
}

.solution-cell-players {
  font-size: 13px;
  color: #222;
}

.hidden {
  display: none !important;
}
