body {
  background:#ffeef7;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding:16px;
  color:#444;
}

.container {
  background:#fff;
  border-radius:18px;
  padding:20px 18px 24px;
  max-width:720px;
  width:100%;
  box-shadow:0 12px 40px rgba(0,0,0,.12);
}

h1{
  font-size:26px;
  color:#ff6fae;
  margin-bottom:4px;
  font-weight:800;
  text-align:center;
}

.subtitle{
  font-size:14px;
  text-align:center;
  color:#777;
  max-width:520px;
  margin:0 auto 10px;
}

.nav-tabs{
  display:flex;
  justify-content:center;
  gap:8px;
  margin-bottom:12px;
  flex-wrap:wrap;
}

.nav-btn{
  padding:7px 14px;
  border-radius:999px;
  border:none;
  background:#f7f7f7;
  color:#555;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  box-shadow:0 2px 6px rgba(0,0,0,.08);
}

.nav-btn.active{
  background:#ff8acb;
  color:#fff;
  box-shadow:0 3px 8px rgba(0,0,0,.15);
}

.daily-theme{
  text-align:center;
  color:#b24aa5;
  margin-bottom:6px;
  font-size:13px;
  font-weight:700;
  min-height:18px;
}

.date-label{
  text-align:center;
  font-size:12px;
  color:#999;
  margin-bottom:14px;
  min-height:16px;
}

/* Timer display */
.timer{
  text-align:center;
  font-size:14px;
  color:#ff6fae;
  margin-bottom:14px;
  font-weight:600;
  padding:6px 12px;
  background:#fff5fb;
  border-radius:999px;
  display:inline-block;
  margin-left:auto;
  margin-right:auto;
  width:auto;
  box-shadow:0 2px 4px rgba(0,0,0,.08);
}

/* Streak display */
.streak-display{
  text-align:center;
  font-size:14px;
  color:#ff8f00;
  margin-bottom:14px;
  font-weight:600;
  padding:6px 16px;
  background:#fff9e6;
  border-radius:999px;
  display:inline-block;
  margin-left:auto;
  margin-right:auto;
  width:auto;
  box-shadow:0 2px 4px rgba(255,143,0,.15);
  border:1px solid #ffe4b3;
}

/* Completion rate display */
.completion-rate{
  text-align:center;
  font-size:13px;
  color:#666;
  margin-bottom:14px;
  font-weight:500;
  padding:5px 14px;
  background:#f9f9f9;
  border-radius:999px;
  display:inline-block;
  margin-left:auto;
  margin-right:auto;
  width:auto;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
  border:1px solid #e0e0e0;
  animation:slideIn 0.3s ease-out;
}

@keyframes slideIn{
  from{opacity:0; transform:translateY(-10px);}
  to{opacity:1; transform:translateY(0);}
}

.streak-flame{
  animation:flicker 1.5s ease-in-out infinite;
  display:inline-block;
}

.streak-max{
  color:#b36800;
  font-size:12px;
}

.perfect-indicator{
  color:#ffa500;
  font-size:13px;
  margin-left:8px;
  padding-left:8px;
  border-left:1px solid #ffcc80;
  animation:sparkle 2s ease-in-out infinite;
}

@keyframes flicker{
  0%,100%{transform:scale(1) rotate(-5deg);}
  50%{transform:scale(1.1) rotate(5deg);}
}

@keyframes sparkle{
  0%,100%{opacity:1;}
  50%{opacity:0.7; transform:scale(1.05);}
}

/* GRID WITH FULL BOLD 3×3 SEPARATORS */
#board{
  display:grid;
  grid-template-columns:repeat(9, minmax(48px,1fr)); /* ensures cells can't shrink smaller than emoji */
  max-width:520px;
  margin:0 auto;
  background:#fff;
  border:4px solid #ff8acb;
  border-radius:12px;
  overflow:hidden;
  touch-action:manipulation;
  gap:0;
}

.cell{
  position:relative;
  background:#fff;
  cursor:pointer;
  transition:background .12s,box-shadow .12s;
  border-right:1px solid #ffd1e8;
  border-bottom:1px solid #ffd1e8;
  min-width:48px;
  min-height:48px;
  aspect-ratio:1/1; /* keeps cells perfectly square */
  user-select:none; /* Prevent text selection on double-click */
}

.cell.given{
  background: #e3f2fd !important;
  border: 1px solid #64b5f6;
  cursor: default;
  position: relative;
}

.cell.given::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background: #2196f3;
  border-radius: 50%;
  opacity: 0.6;
}

.cell.given .emoji {
  filter: brightness(0.95) contrast(1.1);
}

.cell.selected{
  background:#fff0d8!important;
  box-shadow:inset 0 0 0 3px #ffc107;
}

.cell.given.selected{
  background:#bbdefb!important;
  box-shadow:inset 0 0 0 3px #2196f3;
}

.cell.drag-over{
  background:#fff4fa!important;
  box-shadow:inset 0 0 0 4px #ff8acb;
}

.cell.given.drag-over{
  background:#e3f2fd!important;
  cursor:not-allowed;
}

.cell.error{
  background:#ffe8ec!important;
}

/* Bold vertical lines between 3×3 blocks */
.cell:nth-child(9n+3),
.cell:nth-child(9n+6),
.cell:nth-child(9n+9){
  border-right:2px solid #ff8acb;
}

/* Bold horizontal lines between 3×3 blocks */
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54),
.cell:nth-child(n+73):nth-child(-n+81){
  border-bottom:2px solid #ff8acb;
}

/* Fixed emoji positioning */
.cell .emoji{
  display:flex;
  align-items:center;
  justify-content:center;
  width:100%;
  height:100%;
  font-size:34px;
  pointer-events:none;
}

/* Hint text and legend */
.hint-text {
  text-align: center;
  font-size: 12px;
  color: #999;
  margin: 20px 0;
  line-height: 1.6;
}

.hint-legend {
  display: inline-flex;
  gap: 16px;
  margin-bottom: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #666;
}

.legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #ddd;
}

.legend-color.given {
  background: #e3f2fd;
  border-color: #64b5f6;
}

.legend-color.conflict {
  background: #ffb3b3;
  border-color: #ff6666;
}

.legend-color.placed {
  background: white;
  border-color: #ccc;
}

.animals-title{
  text-align:center;
  margin-top:18px;
  margin-bottom:8px;
  font-size:15px;
  color:#b24aa5;
  font-weight:700;
}

/* Notes mode controls */
.notes-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 12px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 12px;
}

.notes-toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-slider {
  position: relative;
  width: 50px;
  height: 26px;
  background: #ccc;
  border-radius: 34px;
  transition: 0.3s;
  display: inline-block;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

#notesToggle {
  display: none;
}

#notesToggle:checked + .toggle-slider {
  background: #ff8acb;
}

#notesToggle:checked + .toggle-slider::after {
  transform: translateX(24px);
}

.toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

/* Notes commit button */
.control-btn.notes-commit {
  background: #9c27b0;
  color: white;
  font-size: 12px;
  padding: 6px 12px;
}

.control-btn.notes-commit:hover {
  background: #7b1fa2;
}

/* Grayscale effect for notes mode */
#animals.notes-mode .animal-choice {
  filter: grayscale(100%);
  opacity: 0.8;
  border-color: #999;
}

#animals.notes-mode .animal-choice.selected {
  filter: grayscale(50%);
  opacity: 1;
  border-color: #666;
  box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

/* Notes display in cells */
.notes-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 2px;
}

.note-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.1s;
}

.note-cell.active {
  opacity: 0.7;
}

/* Undo/Redo buttons */
.control-btn.undo-redo {
  background: #607d8b;
  color: white;
  min-width: 80px;
}

.control-btn.undo-redo:hover:not(:disabled) {
  background: #455a64;
}

.control-btn.undo-redo:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Cell highlighting for notes */
.cell.has-notes {
  background: #fffef0;
}

/* Given cells styling */
.cell.given {
  background: #e6f3ff !important;
  border: 2px solid #4a90e2;
  position: relative;
}

.cell.given::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(74, 144, 226, 0.1) 0%, 
    rgba(74, 144, 226, 0.05) 100%);
  pointer-events: none;
  border-radius: inherit;
}

.cell.given .emoji {
  color: #2c5282;
  font-weight: 600;
}

/* Given cells should not show conflict highlighting */
.cell.given.conflict,
.cell.given.conflict-source {
  background: #e6f3ff !important;
  border: 2px solid #4a90e2;
  animation: none;
}

/* Conflict highlighting */
.cell.conflict {
  background: #ffe0e0 !important;
  animation: conflictPulse 1s ease-in-out infinite;
}

.cell.conflict-source {
  background: #ffb3b3 !important;
  animation: conflictPulse 1s ease-in-out infinite;
}

@keyframes conflictPulse {
  0%, 100% { 
    box-shadow: inset 0 0 0 2px rgba(255, 0, 0, 0.3);
  }
  50% { 
    box-shadow: inset 0 0 0 4px rgba(255, 0, 0, 0.5);
  }
}

/* Conflict emoji styling */
.cell.conflict .emoji,
.cell.conflict-source .emoji {
  opacity: 0.8;
}

/* Given cells should not show conflict highlighting */
.cell.given.conflict,
.cell.given.conflict-source {
  background: #fff6fb !important;
  animation: none;
}

/* Conflict indicator in controls */
.conflict-indicator {
  display: inline-block;
  padding: 4px 12px;
  background: #ff4444;
  color: white;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 10px;
  animation: shake 0.5s ease-in-out;
}

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

/* Settings for conflict highlighting toggle */
.settings-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 8px;
}

.settings-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.settings-label {
  font-size: 14px;
  color: #666;
  cursor: pointer;
  user-select: none;
}

/* Transformation indicator for hard mode */
.transformation-indicator {
  display: inline-block;
  position: relative;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin: 10px auto;
  animation: pulse 2s ease-in-out infinite;
  cursor: help;
}

.transformation-indicator span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.transform-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  background: #333;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: normal;
  width: 250px;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.transformation-indicator:hover .transform-tooltip {
  display: block;
}

.transform-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #333;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

#animals{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px;
  margin-bottom:14px;
}

.animal-choice{
  width:56px;
  height:56px;
  background:#fff;
  border-radius:14px;
  border:3px solid #ff8acb;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 4px 10px rgba(0,0,0,.08);
  transition:.12s;
  touch-action:none;
  user-select:none;
  position:relative;
}

/* Fixed emoji positioning for palette buttons */
.animal-choice .emoji-button{
  font-size:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}

/* Pet image styling */
.pet-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  image-rendering: crisp-edges;
}

.animal-choice.user-pet {
  border-color: #ffd700;
  border-width: 3px;
  background: linear-gradient(135deg, #fff9e6, #fff);
  position: relative;
  overflow: hidden;
}

.animal-choice.user-pet::before {
  content: '⭐';
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 14px;
  background: #ffd700;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.animal-choice.user-pet:hover {
  transform: translateY(-2px) rotate(2deg);
  box-shadow: 0 6px 16px rgba(255,215,0,0.4);
}

/* Sunday parade banner */
.sunday-parade-banner {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #333;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(255,215,0,0.3);
  animation: shimmer 3s ease-in-out infinite;
}

.sunday-parade-banner a {
  display: inline-block;
  margin-top: 6px;
  color: #ff6fae;
  font-weight: 700;
  text-decoration: none;
  background: white;
  padding: 4px 12px;
  border-radius: 999px;
  transition: all 0.3s;
}

.sunday-parade-banner a:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Pet image in cells */
.cell .pet-image {
  padding: 4px;
}

/* Grayscale effect for notes mode with pet images */
#animals.notes-mode .animal-choice.user-pet {
  filter: grayscale(100%);
  opacity: 0.8;
}

/* Add upload button to main page */
.upload-pet-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #333;
  padding: 12px 20px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(255,215,0,0.4);
  z-index: 1000;
  transition: all 0.3s;
  animation: pulse 2s ease-in-out infinite;
}

.upload-pet-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(255,215,0,0.5);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.animal-choice.selected{
  border-color:#ff3f9e;
  box-shadow:0 0 12px rgba(255,64,150,.7);
  transform:translateY(-2px);
}

#controls{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  margin:6px auto 4px;
  max-width:520px;
}

.control-btn{
  border-radius:999px;
  border:none;
  padding:8px 14px;
  font-size:13px;
  font-weight:600;
  background:#f3f3f3;
  color:#555;
  cursor:pointer;
  box-shadow:0 2px 6px rgba(0,0,0,.12);
  transition:all .12s;
}

.control-btn.primary{
  background:#ff8acb;
  color:#fff;
}

/* Reddit share button styling */
.control-btn.reddit{
  background:#ff4500;
  color:#fff;
}

.control-btn.reddit:hover{
  background:#ff5722;
}

/* Social image share button */
.control-btn.social{
  background:linear-gradient(45deg, #833ab4, #fd1d1d, #fcb045);
  color:#fff;
}

.control-btn.social:hover{
  background:linear-gradient(45deg, #9444c4, #ff3d3d, #fdc055);
  transform:translateY(-1px) scale(1.02);
}

/* Grey secondary button for Show Solution */
.control-btn.secondary{
  background:#808080;
  color:#fff;
}

.control-btn.secondary:hover{
  background:#696969;
}

.control-btn:hover{
  box-shadow:0 3px 8px rgba(0,0,0,.16);
  transform:translateY(-1px);
}

/* Control groups for visual separation */
.control-group{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  margin:6px auto;
}

.control-group:not(:last-child){
  padding-bottom:8px;
  border-bottom:1px dashed #ffd1e8;
}

.instructions{
  text-align:center;
  font-size:12px;
  color:#777;
  margin-top:12px;
  max-width:560px;
  margin-inline:auto;
  line-height:1.4;
}

/* Double-click hint */
.hint-text{
  text-align:center;
  font-size:11px;
  color:#999;
  margin-top:8px;
  font-style:italic;
}

.archive-panel{
  margin-top:16px;
  padding:12px 10px;
  border-radius:12px;
  background:#fff5fb;
  border:1px dashed #ff8acb;
}

.archive-panel.hidden{
  display:none;
}

.archive-panel label{
  font-size:13px;
  display:block;
  margin-bottom:4px;
}

.archive-panel-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  margin-bottom:6px;
}

.archive-panel input[type="date"],
.archive-panel select{
  padding:6px 8px;
  border-radius:999px;
  border:1px solid #ff8acb;
  font-size:13px;
}

.archive-panel button{
  padding:7px 14px;
  border-radius:999px;
  border:none;
  background:#ff8acb;
  color:#fff;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
}

.archive-list {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:4px;
}

.archive-list-row {
  align-items:flex-start;
}

.archive-list-item {
  flex:1 1 calc(50% - 6px);
  min-width:140px;
  padding:6px 10px;
  border-radius:999px;
  background:#fff;
  border:1px solid #ffd8f0;
  font-size:12px;
  text-align:left;
  cursor:pointer;
  transition:background .12s, box-shadow .12s, transform .05s;
}

.archive-list-item:hover {
  background:#fff0fa;
  box-shadow:0 2px 6px rgba(0,0,0,.08);
  transform:translateY(-1px);
}

/* Center timer and streak in container */
#timer, #streakDisplay, #completionRate {
  display:block;
  text-align:center;
  margin:0 auto 14px;
}

@media (max-width:600px){
  .container{padding:16px 12px 20px;}
  h1{font-size:22px;}
  .cell .emoji{font-size:30px;}
  .cell.given::after{width:4px;height:4px;bottom:1px;right:1px;}
  .animal-choice{width:52px;height:52px;}
  .animal-choice .emoji-button{font-size:28px;}
  .nav-btn{font-size:12px;padding:6px 10px;}
  .control-btn{font-size:12px;padding:8px 12px;}
  .control-btn.undo-redo{font-size:11px;min-width:70px;padding:6px 10px;}
  .archive-list-item{flex:1 1 100%;}
  .timer{font-size:13px;}
  .streak-display{font-size:13px;}
  .notes-controls{flex-direction:column;gap:8px;}
  .notes-toggle-container{font-size:13px;}
  .note-cell{font-size:10px;}
  .control-btn.notes-commit{font-size:11px;}
  .hint-legend{gap:10px;font-size:10px;}
  .legend-color{width:12px;height:12px;}
}
