body {
  font-family: sans-serif;
  margin: 0;
  padding: 1rem;
  min-height: 100vh;
  background-color: #f9fbff;

  background-image: 
    linear-gradient(45deg, rgba(255,0,0,0.1) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(255,0,0,0.1) 1px, transparent 1px);
  background-size: 80px 80px; /* spacing between connections */
  
  display: flex;
  justify-content: center;
}

main {
  max-width: 600px;
  width: 100%;
}

/* Title */
h1 {
  text-align: center;
  margin-bottom: 1rem;
}
h2 {
  text-align: center;
  margin-top: 0;
  margin-bottom: 1rem;
}

/* Feedback and guess tracker */
.feedback, .guesses-left {
  text-align: center;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

/* Solved Groups */
.group-wrapper {
  margin-bottom: 1rem;
}

.group-label {
  text-align: center;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.solved-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* Remaining Tiles Grid */
.unsolved-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 1rem;
}

/* Tiles */
/* ----------------- Tiles ----------------- */
/* ----------------- Tiles ----------------- */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1.25rem;          
  padding: 0.75rem 1.25rem;        
  text-align: center;
  font-weight: 500;
  font-size: clamp(0.8rem, 1.5vw, 1.2rem); 
  line-height: 1.2;
  background: linear-gradient(145deg, #e6f1fb, #ffffff);
  box-shadow:
    inset 2px 2px 4px rgba(255, 255, 255, 0.8),
    inset -2px -2px 4px rgba(0, 0, 0, 0.05),
    0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 1px 1px 3px rgba(255, 255, 255, 0.7),
    inset -1px -1px 3px rgba(0, 0, 0, 0.05),
    0 10px 20px rgba(0, 0, 0, 0.35);
}

.tile.selected {
  background: linear-gradient(145deg, #bbdefb, #e3f2fd);
  box-shadow:
    inset 1px 1px 4px rgba(255, 255, 255, 0.6),
    inset -2px -2px 5px rgba(0, 0, 0, 0.1),
    0 10px 20px rgba(0, 0, 0, 0.35);
}


/* Subtle green pulse for solved/revealed tiles */
/* Solved / Revealed Tiles */
.tile.solved,
.tile.revealed {
  animation: subtleGreenPulse 1s ease-in-out 2; /* pulse twice and stop */
  background-color: #d1fae5; /* light green base */
  border-color: #10b981;     /* emerald accent */
  opacity: 0.7;              /* slightly faded to show inactive */
  color: #065f46;            /* darker green text for contrast */
  pointer-events: none;       /* disable interaction */
}


/* Keep hover effects off for solved tiles */
.tile.solved:hover,
.tile.revealed:hover {
  transform: none;
  box-shadow: 
    inset 2px 2px 4px rgba(0,0,0,0.05);
}


@keyframes subtleGreenPulse {
  0%   { transform: scale(1); background-color: #d1fae5; }
  50%  { transform: scale(1.03); background-color: #a7f3d0; } /* slightly brighter green */
  100% { transform: scale(1); background-color: #d1fae5; }
}

/* Sparkle effect for solved tiles */
.tile.solved {
  position: relative;   /* allow pseudo-elements to be placed */
  overflow: visible;    /* so sparkles can extend outside */
}

.tile.solved::before,
.tile.solved::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 15%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  pointer-events: none;
  animation: sparkle 0.8s ease-out forwards;
}

.tile.solved::after {
  animation-delay: 0.2s; /* stagger the second burst */
}

@keyframes sparkle {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.2) rotate(45deg); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(0) rotate(90deg); opacity: 0; }
}

/* Keep disabled look but visible */
.tile.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: default;
}

/* Slight shake for wrong guesses */
.cell.wrong {
  animation: shake 0.4s;
  border-color: #e53935;
}

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


/* Buttons */
button {
  display: inline-block;  /* or 'inline-flex' */
  width: auto;            /* Remove full width */
  margin-top: 0.5rem;
  padding: 0.75rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background-color: #4a90e2;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.button-row {
  display: flex;
  justify-content: center; /* Or space-between, space-around, etc. */
  gap: 10px; /* Space between buttons */
  flex-wrap: wrap; /* Allow wrapping on small screens */
  margin: 1rem 0;
}
.centered-button-column {
  display: flex;
  flex-direction: column;      /* stack vertically */
  align-items: center;         /* center horizontally */
  gap: 0.75rem;                /* space between buttons */
  margin-top: 1rem;
}
.small-button {
  padding: 0.4rem 0.8rem;
  font-size: 1rem;
  border-radius: 6px;
  background-color: #007bff;
  color: white;
  border: none;
  cursor: pointer;
  width: auto;              /* Ensure it's not full width */
  min-width: 100px;         /* Optional: make buttons more consistent */
  flex: 0 0 auto;           /* Prevent growing to full width in flexbox */
}


.small-button:hover {
  background-color: #0056b3;
}

button:hover {
  background-color: #357ab7;
}

button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
.share-buttons {
  margin-top: 1.5rem;
  text-align: center;
  font-family: inherit;
}

.share-buttons p {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: #333; /* same text style as body */
}

.share-buttons a {
  display: inline-block;
  margin: 0.25rem;
  padding: 0.6rem 1.2rem;
  border-radius: 9999px; /* pill shape */
  text-decoration: none;
  font-size: 0.5rem;
  font-weight: 500;
  color: white;
  background-color: #006d77; /* matches your tile accent/primary color */
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Hover effect */
.share-buttons a:hover {
  background-color: #00555d; /* slightly darker teal on hover */
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}


.visit-counter-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}


#visit-box {
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  color: limegreen;
  background-color: black;
  padding: 8px 12px;
  border: 2px inset gray;
  display: inline-block;
  margin: 20px auto;
  text-align: center;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

#visit-box .label {
  margin-right: 8px;
  color: white;
}

#visit-box .digits {
  letter-spacing: 2px;
  font-weight: bold;
  background-color: #222;
  padding: 4px 8px;
  border: 1px solid #0f0;
  display: inline-block;
  color: #0f0;
}

#completion-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) scaleY(0); /* start squished vertically */
  transform-origin: top center;
  background: linear-gradient(135deg, #4a90e2, #007bff); /* match your buttons */
  color: #fff;
  font-size: 1.6rem;
  font-weight: bold;
  padding: 1rem 3rem;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  z-index: 9999;
  text-align: center;
  display: inline-block;
  transition: transform 0.6s ease-out;
  position: fixed;
}

/* Ribbon tails */
#completion-banner::before,
#completion-banner::after {
  content: "";
  position: absolute;
  bottom: -20px;
  width: 25px;
  height: 20px;
  background: inherit; /* same gradient */
  z-index: -1;
}

#completion-banner::before {
  left: 0;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

#completion-banner::after {
  right: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/* Active state: unroll into view */
#completion-banner.show {
  transform: translateX(-50%) scaleY(1);
}

.hidden {
  display: none;
}


/* ===== Comments Section ===== */
#comments-section {
  max-width: 600px;
  margin: 2rem auto;
  text-align: center;
}

#comments-section h2 {
  margin-bottom: 0.75rem;
}

/* Wrapper for input + button */
.comment-input-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: center;
  margin-bottom: 1rem;
}

#comment-input {
  flex: 1;
  min-height: 3rem;
  padding: 0.5rem;
  font-size: 1rem;
  border: 2px solid #ccc;
  border-radius: 6px;
  resize: vertical;
}

#submit-comment {
  height: fit-content;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background-color: #4a90e2;
  color: white;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#submit-comment:hover {
  background-color: #357ab7;
}

/* Comments list (hidden to players, but structured) */
#comments-list {
  margin-top: 1rem;
  text-align: left;
}
.end-prompt {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.end-prompt-content {
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.hidden {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .comment-input-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  #submit-comment {
    width: 100%;
  }
}



/* Modal Styles */
.modal {
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 2rem;
  border-radius: 1rem;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.close {
  float: right;
  font-size: 1.5rem;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
}

.close:hover {
  color: #000;
}

@media (max-width: 430px) {
  main {
    padding: 0.5rem;
    max-width: 100%;
  }

  .tile {
    font-size: 0.7rem;
    padding: 0.5rem;
    min-height: 50px; 
  }

  .solved-row,
  .unsolved-grid {
    gap: 6px;
  }

  button {
    font-size: 0.9rem;
    padding: 0.6rem;
  }

  .group-label {
    font-size: 0.85rem;
  }
}

