/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: #f0ebe5;
  color: #4a4a5a;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  width: 100%;
  max-width: 420px;
  padding: 16px 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* ===== HEADER ===== */
header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #7b6b8a;
  letter-spacing: 0.02em;
}

.score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e3d9cd;
  padding: 6px 14px;
  border-radius: 20px;
}

.score-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #8a7a7a;
  letter-spacing: 0.06em;
}

#score {
  font-size: 1.1rem;
  font-weight: 700;
  color: #5b4b6b;
  min-width: 2.5rem;
  text-align: right;
}

/* ===== GRID ===== */
.grid {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  background: #e8ddd2;
  border-radius: 16px;
  padding: 8px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.06);
}

.cell {
  background: #f5efe8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.cell:active {
  cursor: grabbing;
}

.cell svg {
  width: 80%;
  height: 80%;
  display: block;
  pointer-events: none;
}

/* ===== DRAG GHOST ===== */
.cell.dragging {
  opacity: 0.35;
  transform: scale(0.92);
}

.cell.drop-target {
  background: #dccfbe;
  box-shadow: 0 0 0 2px #b8a9c0;
  transform: scale(1.04);
}

/* ===== INFO BAR ===== */
.info-bar {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 4px 0;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #7b6b7a;
}

.info-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9a8a8a;
}

/* ===== BUTTONS ===== */
.actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.btn {
  border: none;
  border-radius: 28px;
  padding: 10px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: #c8b8db;
  color: #4a3a5a;
  box-shadow: 0 2px 6px rgba(160,130,180,0.25);
}

.btn-primary:hover {
  background: #bcaad0;
}

.btn-secondary {
  background: #e3d9cd;
  color: #5a5a6a;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-secondary:hover {
  background: #dacebc;
}

.btn-accent {
  background: #f5d8c8;
  color: #6a4a3a;
  box-shadow: 0 2px 6px rgba(200,140,100,0.2);
}

.btn-accent:hover {
  background: #eccbbc;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #5b4b6b;
  color: #f5efe8;
  padding: 10px 24px;
  border-radius: 24px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

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

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-12px);
}

/* ===== OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 50, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  background: #f5efe8;
  border-radius: 24px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  max-width: 280px;
}

.overlay-card h2 {
  font-size: 1.5rem;
  color: #5b4b6b;
  margin-bottom: 12px;
}

.overlay-card p {
  font-size: 1rem;
  color: #7b6b7a;
  margin-bottom: 6px;
}

.overlay-card .btn {
  margin-top: 18px;
  width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  #app { padding: 10px 8px 16px; }
  header h1 { font-size: 1.05rem; }
  .grid { gap: 4px; padding: 6px; }
  .btn { padding: 8px 12px; font-size: 0.75rem; }
  .actions { gap: 5px; }
}

@media (min-width: 500px) {
  #app { max-width: 460px; }
  .grid { gap: 8px; padding: 10px; }
}
