:root {
  --neon-green: #00ff00;
  --neon-glow: rgba(0, 255, 0, 0.7);
  --background-color: #f5f5f0;
  --dark-gray: #2e2e2e;
  --medium-gray: #6e6e6e;
  --light-gray: #e0e0e0;
}

.wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--background-color);
  color: var(--neon-green); 
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

header {
  display: flex;
  justify-content: center;
  font-size: 55px;
  font-weight: bold;
  height: 110px;
  width: 100%;
  margin-top: 2rem;
  color: var(--neon-green);
  text-shadow: 1px 1px 1px var(--dark-gray);
  letter-spacing: 2px;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
}

.scoreboard {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 500px;
  height: 180px;
  gap: 3rem;
  letter-spacing: 1px;
  justify-content: center;
  text-align: center;
  align-items: center;
  text-shadow: 1px 1px 1px var(--dark-gray);
}

.leaderboard {
  display: flex;
  justify-content: center;
  align-items: center;
  align-content: center;
  text-align: center;
  color: var(--neon-green);
  font-size: 18px;
  letter-spacing: 1px;
  height: 3.5rem;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
  background-color: rgba(0, 0, 0, 0.04);
  padding: 8px;
  border: solid 1px var(--medium-gray);
  border-radius: 5px;
  overflow: hidden;
}

.players {
  margin-bottom: 15%;
  height: 140px;
  width: 130px;
  min-width: 130px;
  max-width: 130px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-name {
  min-height: 30px;
  width: 100%;
  max-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-overflow: ellipsis;
  cursor: pointer;
}

.players p {
  font-size: 38px;
  margin-top: 35px;
}

.edit-name-input {
  width: 90%;
  max-width: 110px;
  box-sizing: border-box;
  font-size: 16px;
  padding: 4px;
  border: 1px solid var(--neon-green);
  border-radius: 3px;
  color: var(--dark-gray);
  cursor: pointer;
}

.edit-name-input:focus {
  outline: 1px solid var(--neon-green);
  box-shadow: 0 0 5px var(--neon-glow);
}

.board {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  padding: 4px;
  gap: 4px;
  border: solid 2px var(--neon-green);
  border-radius: 7px;
  background-color: var(--dark-gray);
  height: 28rem;
  width: 28rem;
}

.cell {
  width: 100%;
  height: 100%;
  border: solid 1px var(--neon-green);
  border-radius: 6px;
  background-color: var(--light-gray);
  color: var(--neon-green);
  text-shadow: 1px 1px 1px var(--dark-gray);
  font-size: 50px;
  align-content: center;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s;
}

.cell:hover {
  background-color: var(--medium-gray);
  box-shadow: 0 0 5px #00ff00, 0 0 10px #00ff00;
}

.cell:active {
  background-color: #d0d0d0;
  transform: scale(0.95);
}

.replay-div {
  height: 100px;
  display: flex;  
}

.replay-btn {
  display: none;
  height: 40px;
  width: 140px;
  background-color: var(--neon-green);
  color: #1a1a1a;
  margin-top: 70px;
  border-radius: 7px;
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.1s, box-shadow 0.3s;
}

.replay-btn:hover {
  background-color: #a6ff4d;
  box-shadow: 0 0 10px var(--neon-green), 0 0 20px var(--neon-green);
}

.replay-btn:active {
  background-color: #4dff1a;
  transform: scale(0.95);
  box-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green);
}

footer {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 10px 0;
  margin-top: auto;
  text-shadow: 1.2px 1.2px 1.2px var(--dark-gray);
}

@keyframes pulsate {
  0% {
    text-shadow: 0 0 2px var(--neon-green), 0 0 3px var(--neon-green);
    filter: brightness(0.95);
  }
  50% {
    text-shadow: 0 0 4px var(--neon-green), 0 0 8px var(--neon-green);
    filter: brightness(1.1);
  }
  100% {
    text-shadow: 0 0 2px var(--neon-green), 0 0 3px var(--neon-green);
    filter: brightness(0.95);
  }
}

footer a {
  color: var(--neon-green);
  text-decoration: none;
  font-size: 18px;
  transition: color 0.3s, text-shadow 0.3s;
  animation: pulsate 3s infinite;
}

footer a:hover,
footer a:focus {
  color: #a6ff4d;
  text-shadow: 0 0 10px var(--neon-green), 0 0 20px var(--neon-green), 0 0 30px var(--neon-green);
}

/* Tablet and medium screens */
@media (max-width: 768px) {
  header {
    font-size: 42px;
    height: 90px;
    margin-top: 1.5rem;
  }
  
  .scoreboard {
    max-width: 95%;
    height: auto;
    gap: 1.5rem;
    padding: 0 1rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    font-size: 17px;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
    height: 3.2rem;
    flex-shrink: 0;
  }
  
  .players {
    height: auto;
    margin-bottom: 8%;
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 32px;
    margin-top: 25px;
  }
  
  .player-name {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .edit-name-input {
    font-size: 15px;
    width: 95%;
    max-width: 115px;
  }
  
  .board {
    width: 70vw;
    height: 70vw;
    max-width: 500px;
    max-height: 500px;
  }
  
  .cell {
    font-size: 40px;
  }
  
  .replay-btn {
    margin-top: 50px;
  }
}

/* Small tablets and large phones */
@media (max-width: 600px) {
  header {
    font-size: 36px;
    height: 80px;
    margin-top: 1.2rem;
  }
  
  .scoreboard {
    max-width: 98%;
    gap: 1rem;
    padding: 0 0.5rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    font-size: 16px;
    width: 145px;
    min-width: 145px;
    max-width: 145px;
    height: 3rem;
    flex-shrink: 0;
  }
  
  .players {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    margin-bottom: 6%;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 30px;
    margin-top: 20px;
  }
  
  .player-name {
    font-size: 14px;
    min-height: 28px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .edit-name-input {
    font-size: 14px;
    width: 95%;
    max-width: 105px;
  }
  
  .board {
    width: 80vw;
    height: 80vw;
    max-width: 450px;
    max-height: 450px;
  }
  
  .cell {
    font-size: 36px;
  }
  
  .replay-btn {
    margin-top: 40px;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  header {
    font-size: 30px;
    height: 70px;
    margin-top: 1rem;
    letter-spacing: 1px;
  }
  
  .scoreboard {
    max-width: 100%;
    height: auto;
    gap: 0.8rem;
    padding: 0 0.3rem;
    justify-content: space-around;
    align-items: center;
  }
  
  .leaderboard {
    font-size: 15px;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    height: 2.8rem;
    padding: 6px;
    flex-shrink: 0;
  }
  
  .players {
    height: auto;
    margin-bottom: 5%;
    width: 95px;
    min-width: 95px;
    max-width: 95px;
    font-size: 13px;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 24px;
    margin-top: 15px;
  }
  
  .player-name {
    font-size: 13px;
    min-height: 25px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
  
  .edit-name-input {
    font-size: 13px;
    width: 95%;
    max-width: 85px;
    padding: 3px;
  }
  
  .board {
    width: 85vw;
    height: 85vw;
    max-width: 400px;
    max-height: 400px;
    gap: 3px;
    padding: 3px;
  }
  
  .cell {
    font-size: 26px;
  }
  
  .replay-btn {
    margin-top: 30px;
    height: 35px;
    width: 120px;
    font-size: 14px;
  }
  
  footer {
    font-size: 14px;
    padding: 8px 0;
  }
  
  footer a {
    font-size: 16px;
  }
}

/* Small phones */
@media (max-width: 400px) {
  header {
    font-size: 28px;
    height: 65px;
    margin-top: 0.8rem;
  }
  
  .scoreboard {
    gap: 0.6rem;
    padding: 0 0.2rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    font-size: 14px;
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    height: 2.6rem;
    padding: 5px;
    flex-shrink: 0;
  }
  
  .players {
    width: 85px;
    min-width: 85px;
    max-width: 85px;
    font-size: 12px;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 22px;
    margin-top: 12px;
  }
  
  .player-name {
    font-size: 12px;
    min-height: 22px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .edit-name-input {
    font-size: 12px;
    width: 95%;
    max-width: 75px;
    padding: 2px;
  }
  
  .board {
    width: 88vw;
    height: 88vw;
    max-width: 350px;
    max-height: 350px;
  }
  
  .cell {
    font-size: 24px;
  }
  
  .replay-btn {
    height: 32px;
    width: 110px;
    font-size: 13px;
    margin-top: 25px;
  }
  
  footer {
    font-size: 12px;
    padding: 6px 0;
  }
  
  footer a {
    font-size: 14px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  header {
    font-size: 26px;
    height: 60px;
    margin-top: 0.5rem;
  }
  
  .scoreboard {
    gap: 0.4rem;
    padding: 0 0.1rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    font-size: 13px;
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    height: 2.4rem;
    padding: 4px;
    flex-shrink: 0;
  }
  
  .players {
    width: 75px;
    min-width: 75px;
    max-width: 75px;
    font-size: 11px;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 20px;
    margin-top: 10px;
  }
  
  .player-name {
    font-size: 11px;
    min-height: 20px;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .edit-name-input {
    font-size: 11px;
    width: 95%;
    max-width: 65px;
    padding: 2px;
  }
  
  .board {
    width: 90vw;
    height: 90vw;
    max-width: 320px;
    max-height: 320px;
    gap: 2px;
    padding: 2px;
  }
  
  .cell {
    font-size: 20px;
  }
  
  .replay-btn {
    height: 30px;
    width: 100px;
    font-size: 12px;
    margin-top: 20px;
  }
}

/* Extra small devices */
@media (max-width: 320px) {
  header {
    font-size: 24px;
    height: 55px;
    margin-top: 0.3rem;
  }
  
  .scoreboard {
    gap: 0.3rem;
    padding: 0;
    justify-content: space-around;
  }
  
  .leaderboard {
    font-size: 12px;
    width: 100px;
    min-width: 100px;
    max-width: 100px;
    height: 2.2rem;
    padding: 3px;
    flex-shrink: 0;
  }
  
  .players {
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    font-size: 10px;
    flex-shrink: 0;
  }
  
  .players p {
    font-size: 18px;
    margin-top: 8px;
  }
  
  .player-name {
    font-size: 10px;
    min-height: 18px;
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .edit-name-input {
    font-size: 10px;
    width: 95%;
    max-width: 60px;
    padding: 1px;
  }
  
  .board {
    width: 92vw;
    height: 92vw;
    max-width: 290px;
    max-height: 290px;
    gap: 1px;
    padding: 1px;
  }
  
  .cell {
    font-size: 18px;
  }
  
  .replay-btn {
    height: 28px;
    width: 90px;
    font-size: 11px;
    margin-top: 15px;
  }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  header {
    font-size: 28px;
    height: 50px;
    margin-top: 0.5rem;
  }
  
  .scoreboard {
    height: auto;
    margin-bottom: 1rem;
    gap: 1rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    height: 2.5rem;
    flex-shrink: 0;
  }
  
  .players {
    margin-bottom: 3%;
    flex-shrink: 0;
  }
  
  .players p {
    margin-top: 10px;
  }
  
  .board {
    width: 45vh;
    height: 45vh;
    max-width: 350px;
    max-height: 350px;
  }
  
  .cell {
    font-size: 24px;
  }
  
  .replay-btn {
    margin-top: 15px;
    height: 35px;
  }
  
  footer {
    margin-top: 0.5rem;
    padding: 5px 0;
  }
}

/* Very short screens in landscape */
@media (max-height: 450px) and (orientation: landscape) {
  header {
    font-size: 24px;
    height: 40px;
    margin-top: 0.3rem;
  }
  
  .scoreboard {
    margin-bottom: 0.5rem;
    gap: 0.8rem;
    justify-content: space-around;
  }
  
  .leaderboard {
    height: 2rem;
    font-size: 13px;
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    flex-shrink: 0;
  }
  
  .players {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    flex-shrink: 0;
  }
  
  .players p {
    margin-top: 8px;
    font-size: 20px;
  }
  
  .player-name {
    font-size: 11px;
    max-width: 85px;
  }
  
  .board {
    width: 35vh;
    height: 35vh;
    max-width: 280px;
    max-height: 280px;
  }
  
  .cell {
    font-size: 18px;
  }
  
  .replay-btn {
    margin-top: 8px;
    height: 28px;
  }
}