body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #e91e63 0%, #880e4f 100%);
  color: #333;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1.25em;
  box-sizing: border-box;
}

main {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  width: 100%;
  max-width: 31em;
  background: rgba(255, 255, 255, 0.95);
  padding: 2em;
  border-radius: 1.25em;
  box-shadow: 0 1.25em 2.5em rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(0.6em);
  box-sizing: border-box;
}

footer {
  margin-top: auto;
  padding-top: 1.25em;
  border-top: 1px solid #bbbbbb;
  font-size: 0.9em;
  color: #777;
  text-align: center;
}

h1 {
  color: #2c3e50;
  margin-bottom: 1.5em;
  font-size: clamp(1.8em, 4vw, 2.5em);
  font-weight: 700;
  text-shadow: 0.125em 0.125em 0.25em rgba(0, 0, 0, 0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5em;
  margin: 1.5em auto;
  padding: 1em;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 0.9em;
  box-shadow: inset 0 0.1em 0.6em rgba(0, 0, 0, 0.1);
  width: min(280px, 80vw);
  aspect-ratio: 1;
}

.grid div {
  aspect-ratio: 1;
  background: linear-gradient(145deg, #ffffff, #e6e6e6);
  border: none;
  border-radius: 0.75em;
  font-size: clamp(1.5em, 5vw, 2.25em);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0.25em 0.5em rgba(0, 0, 0, 0.1);
}

.grid div:hover {
  transform: translateY(-0.07em);
  box-shadow: 0 0.3em 0.6em rgba(0, 0, 0, 0.15);
  background: linear-gradient(145deg, #f8f9fa, #e9ecef);
}

.grid div.x { 
  color: #8e44ad;
  text-shadow: 0.125em 0.125em 0.25em rgba(142, 68, 173, 0.3);
}

.grid div.o { 
  color: #f1c40f;
  text-shadow: 0.125em 0.125em 0.25em rgba(241, 196, 15, 0.3);
}

#buttons {
  margin-bottom: 1.5em;
  display: flex;
  gap: 0.9em;
  justify-content: center;
  flex-wrap: nowrap;
}

button {
  padding: 0.75em 1.5em;
  font-size: 1em;
  font-weight: 600;
  border: none;
  border-radius: 3em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0.25em 0.9em rgba(0, 0, 0, 0.2);
  min-width: 7.5em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#joinX {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: white;
}

#joinX:hover:not(:disabled) {
  background: linear-gradient(135deg, #8e44ad, #7d3c98);
  transform: translateY(-0.1em);
  box-shadow: 0 0.4em 1.25em rgba(155, 89, 182, 0.4);
}

#joinX.joined {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d) !important;
  color: #ecf0f1 !important;
  transform: none !important;
  box-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.1) !important;
}

#joinO {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
}

#joinO:hover:not(:disabled) {
  background: linear-gradient(135deg, #e67e22, #d35400);
  transform: translateY(-0.1em);
  box-shadow: 0 0.4em 1.25em rgba(243, 156, 18, 0.4);
}

#joinO.joined {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d) !important;
  color: #ecf0f1 !important;
  transform: none !important;
  box-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.1) !important;
}

#reset {
  background: linear-gradient(135deg, #a8e6cf, #88d8a3);
  color: #2c3e50;
  margin-top: 0.5em;
}

#reset:hover {
  background: linear-gradient(135deg, #81c784, #66bb6a);
  transform: translateY(-0.1em);
  box-shadow: 0 0.4em 1.25em rgba(168, 230, 207, 0.4);
}

#homepage {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  margin-top: 0.5em;
  margin-left: 0.6em;
}

#homepage:hover {
  background: linear-gradient(135deg, #2980b9, #1f5f99);
  transform: translateY(-0.125em);
  box-shadow: 0 0.4em 1.25em rgba(52, 152, 219, 0.4);
}

button:disabled {
  background: linear-gradient(135deg, #bdc3c7, #95a5a6) !important;
  color: #7f8c8d !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.1) !important;
}

#status {
  font-size: clamp(1em, 3vw, 1.25em);
  font-weight: bold;
  color: #2c3e50;
  margin: 1.5em 0;
  min-height: 1.5em;
  text-shadow: 0.06em 0.06em 0.1em rgba(0, 0, 0, 0.1);
  text-align: center;
}

.bottom-buttons {
  display: flex;
  gap: 0.6em;
  justify-content: center;
  flex-wrap: wrap;
}
  
@media (max-width: 480px) {
  body {
    padding: 1.5em 0;
  }
  
  main {
    width: auto;
    max-width: 100%;
    padding: 1.5em 1em;
    border-radius: 0.75em;
  }
  
  .grid {
    width: min(260px, 90vw);
    margin: 1em auto;
    gap: 0.4em;
    padding: 0.8em;
  }
  
  .grid div {
    font-size: clamp(1.25em, 6vw, 1.75em);
  }
  
  h1 {
    font-size: clamp(1.5em, 6vw, 2em);
    margin-bottom: 1em;
  }
  
  #buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.8em;
    margin-bottom: 1em;
  }
  
  button {
    width: 80%;
    max-width: 12.5em;
    padding: 0.6em 1.2em;
    font-size: 0.9em;
  }

  .bottom-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.6em;
  }
  
  #status {
    font-size: clamp(0.9em, 4vw, 1em);
    margin: 1em 0;
  }
}