* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: system-ui, sans-serif;
}

#game {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#hud {
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  font-size: 18px;
  border-bottom: 1px solid #222;
}

#game-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;

}

.home {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 26px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 26px;
  align-items: center;
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.h-title {
  font-size: 64px;
  letter-spacing: 4px;
  margin: 0;
}

.h-subtitle {
  margin: 6px 0 0;
  opacity: 0.8;
  font-size: 18px;
  line-height: 1.5;
}

.h-steps {
  margin-top: 16px;
  opacity: 0.9;
  line-height: 1.7;
}

.h-steps b {
  opacity: 1;
}

.h-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

@media (max-width: 820px) {
  .h-actions {
    justify-content: center;
  }
}

.animated-square {
  width: 240px;
  height: 240px;
  margin-left: auto;
  position: relative;
}

@media (max-width: 820px) {
  .animated-square {
    margin: 0 auto;
  }
}

.animated-square::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255,255,255,0.25);
}

.animated-square::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(255,255,255,0.95);
  animation: trace 1.8s linear infinite;
}

@keyframes trace {
  0%   { clip-path: inset(0 95% 95% 0); }
  25%  { clip-path: inset(0 0 95% 0); }
  50%  { clip-path: inset(0 0 0 0); }
  75%  { clip-path: inset(95% 0 0 0); }
  100% { clip-path: inset(0 95% 95% 0); }
}
.btn {
  padding: 12px 18px;
  border: 1px solid #333;
  background: transparent;
  color: white;
  cursor: pointer;
  letter-spacing: 1px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.boards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 900px) {
  .boards {
    grid-template-columns: 1fr;
  }
}

.board {
  border: 1px solid #222;
  padding: 14px;
}

.board h3 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: 1px;
  opacity: 0.85;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table.beaten th, .table.beaten td {
  border-bottom: 1px solid limegreen;
  padding: 8px 6px;
  text-align: left;
  opacity: 0.95;
}

.table th, .table td {
  border-bottom: 1px solid #1a1a1a;
  padding: 8px 6px;
  text-align: left;
  opacity: 0.95;
}

.table th {
  opacity: 0.7;
  font-weight: 600;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}
.modal {
  width: 92%;
  max-width: 420px;
  border: 1px solid #222;
  background: black;
  padding: 16px;
}
.modal h4 {
  margin: 0 0 8px;
  letter-spacing: 1px;
}
.modal p {
  margin: 0 0 10px;
  opacity: 0.8;
  line-height: 1.4;
}
.modal input {
  width: 100%;
  padding: 10px 12px;
  background: black;
  border: 1px solid #333;
  color: white;
  font-size: 16px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}
.site-footer {
  margin-top: 60px;
  padding: 18px 12px 22px;
  border-top: 1px solid #222;
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}
.site-footer a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
}
.site-footer a:hover {
  text-decoration: underline;
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  line-height: 1.5;
}
.footer-small {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.75;
}
.win-square-wrap {
  width: 180px;
  height: 180px;
  position: relative;
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.win-square {
  width: 180px;
  height: 180px;
  box-sizing: border-box;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 2px;
}
/* Fade out from TOP to BOTTOM using a moving mask */
.win-square.fade-down {
  /* Start fully visible */
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,1) 60%,
    rgba(0,0,0,1) 100%
  );
  -webkit-mask-size: 100% 300%;
  -webkit-mask-position: 0% 0%;

  mask-image: linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,1) 60%,
    rgba(0,0,0,1) 100%
  );
  mask-size: 100% 300%;
  mask-position: 0% 0%;

  animation: fadeDownMask 1.8s ease forwards;
  animation-delay: 0.25s;
  animation-iteration-count: 1; /* just to be explicit */
  animation-fill-mode: forwards;
}

@keyframes fadeDownMask {
  from {
    -webkit-mask-position: 0% 0%;
    mask-position: 0% 0%;
    opacity: 1;
  }
  to {
    /* Move the mask so the transparent part covers everything */
    -webkit-mask-position: 0% 150%;
    mask-position: 0% 150%;
    opacity: 0; /* final safety: ensure it stays gone */
  }
}
