@import url('https://fonts.googleapis.com/css2?family=Lalezar&display=swap');

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: 'Lalezar', sans-serif;
}

body {
  height: 100vh;
  background: linear-gradient(135deg, #0f172a, #3b82f6);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.15) 100%);
  z-index: -1;
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  width: 24em;
  background-color: #ffffff;
  position: relative;
  overflow: hidden;
  padding: 2em 0 0 0;
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 
              0 1px 5px rgba(0, 0, 0, 0.1);
  min-height: 350px;
  transform: translateY(0);
  animation: floatIn 0.6s ease-out;
}

@keyframes floatIn {
  0% {
    opacity: 0;
    transform: translateY(40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.grid-box {
  height: 3em;
  width: 3em;
  border: 1px solid #f1f5f9;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease-out;
}

.grid-box:hover {
  background-color: #f1f5f9;
  transform: scale(0.95);
}

.grid-box::after {
  content: "";
  position: absolute;
  top: 0.5em;
  left: 0.5em;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  background-color: transparent;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player1::after {
  background-color: #4f46e5;
  animation: dropToken 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.player2::after {
  background-color: #ef4444;
  animation: dropToken 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropToken {
  0% {
    transform: translateY(-100px);
    opacity: 0;
  }
  70% {
    transform: translateY(10px);
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.filled {
  cursor: not-allowed;
}

.filled:hover {
  transform: scale(1);
  background-color: transparent;
}

.endScreen {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.95);
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2;
  padding: 2em;
  overflow-y: auto;
  min-height: 450px;
  backdrop-filter: blur(5px);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.endScreen > * {
  margin-bottom: 1.5em;
}

button {
  font-size: 1.1em;
  padding: 0.7em 1.5em;
  background-color: #4f46e5;
  color: #ffffff;
  border: none;
  outline: none;
  border-radius: 0.5em;
  cursor: pointer;
  margin-top: 1em;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  font-weight: 500;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.15);
  background-color: #4338ca;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: all 0.5s ease;
}

button:active::after {
  opacity: 1;
  width: 300px;
  height: 300px;
}

.create-join-buttons {
  display: flex;
  flex-direction: column;
  gap: 1em;
  width: 100%;
  max-width: 240px;
}

#joinGameBtn {
  background-color: #ef4444;
}

#joinGameBtn:hover {
  background-color: #dc2626;
}

.hide {
  display: none !important;
}

#message, #playerTurn {
  text-align: center;
  margin-bottom: 1.5em;
  font-weight: 500;
}

#message {
  color: #ffffff;
  font-size: 1.8em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: pulseText 1.5s infinite alternate;
}

@keyframes pulseText {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

span {
  color: #0f172a;
  font-weight: 600;
}

#gameIdDisplay {
  margin-bottom: 1.5em;
  background-color: #f8fafc;
  padding: 0.8em 1.2em;
  border-radius: 0.5em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 300px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#gameIdValue {
  font-weight: 600;
  letter-spacing: 1px;
  color: #0f172a;
}

#copyBtn {
  background-color: #4f46e5;
  font-size: 0.9em;
  padding: 0.4em 0.8em;
  margin: 0;
  border-radius: 0.3em;
}

#gameIdInput {
  font-size: 1.1em;
  padding: 0.8em 1em;
  width: 100%;
  margin-bottom: 1.5em;
  border: 2px solid #e2e8f0;
  border-radius: 0.5em;
  text-align: center;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  outline: none;
}

#gameIdInput:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.waiting-info {
  color: #ffffff;
  text-align: center;
  margin-bottom: 1em;
  font-size: 1.1em;
  animation: fadeIn 0.8s ease-out;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8em 1.5em;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  animation: slideDown 0.5s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.7em;
  transition: all 0.3s ease;
}

.player-marker {
  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.player1-marker {
  background-color: #4f46e5;
}

.player2-marker {
  background-color: #ef4444;
}

.active-player {
  font-weight: bold;
  transform: scale(1.05);
  color: #ef4444;
}

.active-player .player-marker {
  transform: scale(1.2);
}

.notification {
  position: fixed;
  top: 1.5em;
  right: 1.5em;
  padding: 1em 1.5em;
  border-radius: 0.5em;
  background-color: #ef4444;
  color: white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  z-index: 100;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.notification.show {
  opacity: 1;
  transform: translateY(0);
}

#createGameBtn, #joinGameBtn {
  width: 100%;
}

#backToMenuBtn {
  background-color: #64748b;
}

#backToMenuBtn:hover {
  background-color: #475569;
}

#rematchBtn {
  background-color: #4f46e5;
}

#newGameBtn {
  background-color: #64748b;
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .container {
    width: 90%;
    min-height: 350px;
  }
  
  .grid-box {
    height: 2.5em;
    width: 2.5em;
  }
  
  .grid-box::after {
    top: 0.35em;
    left: 0.35em;
    width: 1.8em;
    height: 1.8em;
  }
  
  button {
    font-size: 1em;
    padding: 0.6em 1.2em;
  }
  
  #message {
    font-size: 1.5em;
  }
}

#errorMessage {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 25px;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
  z-index: 1000;
  max-width: 80%;
  text-align: center;
}

a.btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: #4CAF50;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  border: none;
  font-size: 16px;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

a.btn:hover {
  background-color: #45a049;
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

a.btn:active {
  background-color: #3e8e41;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
