:root{
  --bg1: #8a2424;
  --bg2: #105a10;
  --accent: #ff6b6b;
  --accent2: #7f5af0;
  --card-bg: #ffffff;
  --muted: #666;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;  
  /* Background image should fit the screen width and repeat vertically (tile along Y) */
  background-color: darkgreen;
  background-image: url('/images/background.jpg');
  background-repeat: repeat-y;
  background-position: top center;
  /* Fit the image to the viewport width and keep aspect ratio */
  background-size: 100% auto;
  margin: 0;
  padding: 0;
  color: #222;
}

.container {
  max-width: 900px;
  margin: 40px auto;
  padding: 18px;
  background: linear-gradient(180deg, rgb(255 191 169 / 73%), rgb(137 185 150 / 92%));
  border-radius: 14px;
  box-shadow: 3px 11px 11px 10px rgb(26 12 7 / 68%);
}

h1 {
  text-align: center;
  margin: 12px 0 6px 0;
  letter-spacing: 0.6px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input {
  padding: 10px;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid #e8e8ef;
}

button {
  padding: 10px 12px;
  background: linear-gradient(90deg,var(--accent),var(--accent2));
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 6px 14px rgba(127,90,240,0.12);
}

button:hover {
  background: #0056b3;
}

.card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

/* rules image styling and modal tweaks */
.rules-image {
  display: block;
  margin: 0 auto 12px auto;
  max-width: 400px;
  border-radius: 15px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}

.rules-modal .modal-content {
  max-width: 720px;
  text-align: center;
}
.rules-modal img { max-width: 100%; height: auto; }

.card.large {
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.square {
  aspect-ratio: 1;
  border: 2px solid rgba(120,120,140,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  border-radius: 12px;
  transition: transform .08s ease, box-shadow .08s ease;
}

.square:not(.done) {
  background: url('/images/defaultsquare.png') center/cover no-repeat, linear-gradient(135deg, #fff9f9 0%, #fff3fb 100%);
  color: #ffffff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  word-break: break-word;
  font-size: 20px;
  text-shadow: 0 1px 0 rgba(49, 255, 66, 0.6);
}

/* Mobile: make each square a row for better readability on smaller screens */
@media (max-width: 640px) {
  .card {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .square:not(.done) {
    font-size: 18px;
    padding: 18px;
  }

  .card.large { grid-template-columns: 1fr !important; }

  /* Ensure modals are full-width on mobile */
  .modal-content { margin: 8% 8%; width: auto; }
}

/* Fix rules image overflow on small screens */
.rules-image { max-width: 100%; box-sizing: border-box; }

.square .status-label {
  position: absolute;
  left: 6px;
  top: 6px;
  background: rgba(255,255,255,0.85);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.square.done {
  background: #d4edda;
}

.square.done.approved {
  border-color: #28a745;
  box-shadow: 0 0 0 4px rgba(40,167,69,0.08);
}
.square.done.rejected {
  border-color: #dc3545;
  box-shadow: 0 0 0 4px rgba(220,53,69,0.06);
}

.square.done img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
}

.modal-content {
  background-color: #68856ed9;
  margin: 15% auto;
  padding: 20px;
  border: 1px solid #888;
  border-radius: 20px;
}

#modal .modal-content {
  width: 88%;
  max-width: 460px;
  border-radius: 8px;
}

 #cardModal .modal-content {
  max-width: 880px;
  max-height: 80vh;
  overflow: auto;
  margin: 5% auto;
}

#imageModal .modal-content {
  width: auto;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  text-align: center;
  margin: 5% auto;
}

/* Make modals take more space so mouseup rarely falls outside during selection */
.modal .modal-content { max-width: 90vw;
}

#fullImage {
  max-width: 100%;
  height: auto;
}

.close {
  color: #999;
  float: right;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

.close:hover {
  color: black;
}

#players {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-item {
  border: 1px solid rgba(20,20,30,0.06);
  padding: 12px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.9));
  border-radius: 8px;

}

.player-item.completed {
  background: linear-gradient(90deg, #fffaf0, #fff4e6);
  border-color: rgba(255,167,1,0.18);
}

.player-item.completed::after {
  content: attr(data-timestamp);
  display: block;
  font-size: 12px;
  color: #856404;
}

.status.pending {
  color: #f6a623;
}

.status.approved {
  color: #28a745;
}

.status.rejected {
  color: #e55340;
}

@media (max-width: 600px) {
  .card {
    grid-template-columns: 1fr;
  }
  .card.large {
    grid-template-columns: 1fr;
  }
}

/* Approval indicator overlays */
.approval-overlay {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  z-index: 2000;
  font-size: 3.8rem;
  display: none;
  pointer-events: none;
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 14px 40px rgba(10,10,16,0.12);
}
.approval-overlay.visible { display: block; }
.approval-overlay.ok { color: #28a745; }
.approval-overlay.no { color: #dc3545; }

/* Snowfall effect container */
.snow-container {
  position: fixed;
  left: 0; top: 0; width: 100%; height: 100%;
  pointer-events: none; /* allow clicks through */
  overflow: hidden;
  z-index: 900; /* behind modals but above backgrounds */
}
.snowflake {
  position: absolute;
  top: -10vh;
  color: #fff;
  opacity: 0.9;
  user-select: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
.snow-fall {
  /* repeat indefinitely so snow keeps falling */
  animation: fall linear infinite;
}

@keyframes fall {
  to { transform: translateY(120vh) translateX(var(--x)); opacity: 0.85; }
}

/* Santa / sleigh animation */
.santa-flight {
  position: fixed;
  top: 10%;
  left: -25%;
  width: 30vw;
  max-width: 400px;
  pointer-events: none;
  z-index: 1400;
  transform: translateX(0) translateY(0);
  animation: santa-sweep 4s linear forwards;
}
@keyframes santa-sweep {
  0% { left: -35%; transform: translateY(0) rotate(-3deg); }
  25% { transform: translateY(8vh) rotate(1deg); }
  50% { left: 40%; transform: translateY(12vh) rotate(0deg); }
  75% { transform: translateY(6vh) rotate(-1deg); }
  100% { left: 115%; transform: translateY(0) rotate(2deg); }
}

/* small mobile scaling */
@media (max-width: 480px) {
  .santa-flight { width: 50vw; top: 6%; }
}

/* Snow toggle top-left */
.snow-toggle {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 1300;
  width: 36px;
  height: 36px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 18px;
  color: #0b6bff;
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.snow-toggle:hover { transform: translateY(-2px); }
.snow-toggle.off {
  filter: grayscale(80%) brightness(.6);
  background: rgba(255,255,255,0.92);
  color: #777;
}

@media (max-width: 480px) {
  .snow-toggle { width: 32px; height: 32px; font-size: 16px; left: 8px; top: 8px; }
}