:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --error: #dc2626;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #d9e0ec;
  --text: #1f2937;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 60%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

header { text-align: center; margin-bottom: 24px; }
header h1 { margin: 0 0 4px; font-size: 2rem; }
.subtitle { color: #4b5563; margin: 0; }

.screen.hidden { display: none; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.category-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  font-size: 1.05rem;
  font-weight: 600;
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.15);
  border-color: var(--primary);
}
.category-card .cat-emoji { font-size: 2.2rem; display: block; margin-bottom: 8px; }

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.score-board {
  display: flex;
  gap: 18px;
  font-size: 1.05rem;
  background: var(--card-bg);
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.score-board strong { color: var(--primary); }

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e5e9f2; color: var(--text); }
.btn-secondary:hover { background: #d8deeb; }

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; }
}

.column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.15rem;
  min-height: 56px;
  transition: border-color 0.2s ease, background 0.2s ease, opacity 0.3s ease;
}

.image-card {
  font-size: 2.2rem;
  justify-content: center;
  cursor: default;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.image-card .emoji { font-size: 2.2rem; line-height: 1; }
.image-card .cz-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #4b5563;
}
.image-card .matched-word {
  font-size: 0.95rem;
  color: var(--success);
  font-weight: 700;
}
.image-card.drag-over {
  border-color: var(--primary);
  background: #eef2ff;
}
.image-card.matched {
  border-color: var(--success);
  background: #ecfdf3;
}
.image-card.wrong-flash {
  border-color: var(--error);
  background: #fef2f2;
  animation: shake 0.3s;
}

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

.word-card {
  cursor: grab;
  user-select: none;
  font-weight: 600;
  background: #fff;
}
.word-card:active { cursor: grabbing; }
.word-card.dragging { opacity: 0.4; }
.word-card.matched {
  opacity: 0;
  pointer-events: none;
  height: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  overflow: hidden;
}

.word-card.touch-selected {
  border-color: var(--primary);
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.25);
}

.win-message {
  text-align: center;
  margin-top: 30px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 30px;
  border: 2px solid var(--success);
}
.win-message.hidden { display: none; }
.win-message h2 { color: var(--success); }
.win-message button { margin: 6px; }
