* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent zoom on double-click */
html,
body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

body {
  font-family: "Roboto Condensed", sans-serif;
  font-optical-sizing: auto;
  background: #1e293b;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e2e8f0;
  letter-spacing: 0.07em;
}

.container {
  background: #1e293b;
  border-radius: 20px;
  /* box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); */
  padding: 40px;
  max-width: 600px;
  width: 95%;
  text-align: center;
  /* border: 1px solid #334155; */
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #f1f5f9;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-family: "Playwrite AU QLD", cursive;
  font-optical-sizing: auto;
}

h2 {
  font-size: 2rem;
  margin-bottom: 15px;
  color: #f1f5f9;
}

.game-description {
  font-size: 1.1rem;
  color: #cbd5e1;
  margin-bottom: 30px;
  line-height: 1.6;
  ul {
    list-style-type: none;
    li {
      margin-bottom: 10px;
      .highlight {
        color: #f87171;
        font-weight: bold;
        font-size: 1.5rem;
      }
    }
  }
}

.difficulty-selector {
  margin-bottom: 30px;
  text-align: center;
}

.difficulty-selector label {
  display: block;
  font-size: 1.1rem;
  color: #cbd5e1;
  margin-bottom: 15px;
  font-weight: 500;
}

.difficulty-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.difficulty-btn {
  background: #334155;
  color: #cbd5e1;
  border: 2px solid #475569;
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Roboto Condensed", sans-serif;
  font-optical-sizing: auto;
}

.difficulty-btn:hover {
  background: #475569;
  border-color: #64748b;
}

.difficulty-btn.active {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-color: #3b82f6;
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  font-size: 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  font-family: "Roboto Condensed", sans-serif;
  font-optical-sizing: auto;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
}

.btn:active {
  transform: translateY(0);
}

.game-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: #334155;
  border-radius: 15px;
  border: 1px solid #475569;
}

.timer,
.round {
  font-size: 1.1rem;
  font-weight: bold;
  color: #f1f5f9;
}

.timer {
  color: #f87171;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-bar {
  width: 200px;
  height: 4px;
  background: #334155;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin: 0 auto 20px;
}

.timer-progress {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 2px;
  transition: width 0.1s linear;
  position: absolute;
  top: 0;
  left: 0;
}

.game-board {
  position: relative;
  width: 400px;
  height: 400px;
  margin: 0 auto 30px;
  overflow: visible;
  max-width: 400px;
  min-width: 400px;
}

.grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 2px;
  background: #475569;
  padding: 0px;
  /* border-radius: 15px; */
  border: 2px solid #475569;
  transition: all 0.5s ease;
  transform: translateX(100%);
  opacity: 0;
}

.grid.active {
  transform: translateX(0);
  opacity: 1;
  /* border-color: #3b82f6;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3); */
}

.grid.sliding-out {
  transform: translateX(-100%);
  opacity: 0;
}

.grid-number {
  position: absolute;
  bottom: -75px;
  left: 50%;
  transform: translateX(-50%);
  /* background: #3b82f6; */
  color: #b2b2ef;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 2rem;
  font-weight: bold;
  z-index: 10;
}

.cell {
  background: #1e293b;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  color: #f1f5f9;
  margin: 0;
  width: 100%;
  height: 100%;
}

.cell:hover {
  background: #475569;
  border-color: #3b82f6;
}

.cell.x {
  color: #f87171;
  background: #7f1d1d;
  border-color: #f87171;
}

.cell.o {
  color: #60a5fa;
  background: #1e3a8a;
  border-color: #60a5fa;
}

.cell.winning {
  background: #065f46;
  border-color: #10b981;
  color: #10b981;
  animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

#end-message {
  font-size: 1rem;
  margin-bottom: 30px;
  padding: 5px;
  /* border-radius: 15px; */
  font-weight: normal;
}

#end-message.win {
  color: #10b981;
  /* background: #064e3b; */
  /* border: 1px solid #10b981; */
}

#end-message.lose {
  color: #f87171;
  /* background: #7f1d1d; */
  /* border: 1px solid #f87171; */
}

.game-summary-info {
  margin-bottom: 20px;
  text-align: center;
}

.difficulty-display {
  display: inline-block;
  background: #334155;
  color: #cbd5e1;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid #475569;
}

.difficulty-display span:first-child {
  color: #94a3b8;
  margin-right: 5px;
}

.difficulty-display span:last-child {
  color: #f1f5f9;
  font-weight: bold;
}

.grid-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  justify-content: center;
  margin: 20px 0;
  padding: 5px;
  /* background: #334155; */
  /* border-radius: 15px; */
  /* border: 1px solid #475569; */
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  width: 120px;
  height: 120px;
  background: #475569;
  padding: 0px;
  border-radius: 0px;
  border: 1px solid #475569;
  position: relative;
}

.summary-grid::before {
  content: attr(data-grid-number);
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  /* background: #3b82f6; */
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  z-index: 10;
}

.summary-cell {
  background: #1e293b;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  user-select: none;
  position: relative;
  color: #f1f5f9;
  margin: 0;
  width: 100%;
  height: 100%;
}

.summary-cell.x {
  color: #f87171;
  background: #7f1d1d;
  border-color: #f87171;
}

.summary-cell.o {
  color: #60a5fa;
  background: #1e3a8a;
  border-color: #60a5fa;
}

.summary-cell.o.winning {
  background: #065f46;
  border-color: #10b981;
  color: #10b981;
}

.summary-cell.o.winning::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #f87171;
  transform: translateY(-50%);
  z-index: 5;
}

.summary-cell.o.winning::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #f87171;
  transform: translateX(-50%);
  z-index: 5;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 20px;
    width: 95%;
    max-width: 400px;
  }

  h1 {
    font-size: 2rem;
  }

  .game-header {
    flex-direction: column;
    gap: 10px;
  }

  .game-board {
    width: 400px;
    height: 340px;
    max-width: 400px;
    min-width: 400px;
  }

  .cell {
    font-size: 2.8rem;
  }
}

@media (max-width: 480px) {
  .container {
    max-width: 400px;
  }

  .game-board {
    width: 400px;
    height: 280px;
    max-width: 400px;
    min-width: 400px;
  }

  .cell {
    font-size: 2.2rem;
  }
}

@media (max-width: 450px) {
  .container {
    padding: 15px;
    max-width: 100%;
    width: 100%;
  }

  .game-board {
    width: 200px;
    height: 240px;
    max-width: 200px;
    min-width: 200px;
  }

  .cell {
    font-size: 1.8rem;
  }

  .game-header {
    flex-direction: column;
    gap: 5px;
  }

  .timer,
  .round {
    font-size: 0.9rem;
  }
}
