:root {
  --cell-size: 100px;
  --mark-size: calc(var(--cell-size) * 0.8);
}

body {
  font-family: 'Arial', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: white;
}

.container {
  text-align: center;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 10px;
  margin: 20px auto;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 10px;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 48px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.1);
}

.cell.selected {
  background: rgba(0, 255, 255, 0.2);
}

.cell::after {
  content: attr(data-index);
  position: absolute;
  top: 5px;
  right: 10px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

.cell.x-state::before {
  content: "X";
  color: #ff4081;
  opacity: var(--state-opacity, 0.5);
  font-size: 64px;
}

.cell.o-state::before {
  content: "O";
  color: #ffeb3b;
  opacity: var(--state-opacity, 0.5);
  font-size: 64px;
}

.cell.x-final {
  background: rgba(255, 64, 129, 0.3); /* Soft pink background */
  border-color: #ff4081;
}

.cell.o-final {
  background: rgba(255, 235, 59, 0.3); /* Soft yellow background */
  border-color: #ffeb3b;
}

.cell.x-final::before {
  content: "X";
  color: #ff4081;
  opacity: 1;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 64, 129, 0.5);
  font-size: 64px;
}

.cell.o-final::before {
  content: "O";
  color: #ffeb3b;
  opacity: 1;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
  font-size: 64px;
}

.cell.swapped {
  background: rgba(76, 175, 80, 0.3) !important; /* Greenish background */
  border-color: #4CAF50 !important;
}

.quantum-state {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 5px;
  margin: 20px 0;
  font-family: 'Courier New', monospace;
  transition: background-color 0.3s ease;
}

.quantum-state.x-turn {
  background: rgba(255, 64, 129, 0.15); /* Soft pink background for X */
  border: 1px solid rgba(255, 64, 129, 0.3);
}

.quantum-state.o-turn {
  background: rgba(255, 235, 59, 0.15); /* Soft yellow background for O */
  border: 1px solid rgba(255, 235, 59, 0.3);
}

.probability-container {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 5px;
  margin: 20px 0;
  display: none;
}

.probability-slider {
  width: 80%;
  margin: 10px 0;
}

.confirm-probability {
  background: #4CAF50;
  color: white;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.confirm-probability:hover {
  background: #45a049;
}

.measure-btn, .reset-btn {
  padding: 10px 20px;
  font-size: 18px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px;
  transition: all 0.3s ease;
}

.measure-btn {
  background: #ffeb3b;
  color: #1e3c72;
  transition: all 0.3s ease;
}

.measure-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.measure-btn.entangle-measure {
  background: #9c27b0;
  color: white;
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from {
    box-shadow: 0 0 5px #9c27b0, 0 0 10px #9c27b0, 0 0 15px #9c27b0;
  }
  to {
    box-shadow: 0 0 10px #9c27b0, 0 0 20px #9c27b0, 0 0 30px #9c27b0;
  }
}

.measure-btn:hover:not(:disabled),
.reset-btn:hover {
  transform: scale(1.05);
}

.reset-btn {
  background: #ff4081;
  color: white;
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.back-btn {
  padding: 10px 20px;
  font-size: 18px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px;
  transition: all 0.3s ease;
  background: #673AB7;
  color: white;
}

.back-btn:hover {
  transform: scale(1.05);
}

.message {
  margin: 20px;
  font-size: 24px;
  height: 30px;
}

.mode-selector {
  display: none;
}

.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.start-content {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  border-radius: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-height: 95vh;
  overflow-y: auto;
}

.mode-selection {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.mode-option {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid #00e5ff;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 80px;
}

.mode-details {
  text-align: left;
  flex: 1;
}

.mode-details h3 {
  margin: 0;
  color: #00e5ff;
}

.mode-details p {
  display: none;
}

.play-mode-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.play-mode-content {
  background: rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.play-mode-selection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
}

.play-mode-option {
  padding: 1.2rem 2.5rem;
  font-size: 1.2rem;
  background: transparent;
  border: 2px solid #00e5ff;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.play-mode-option:hover {
  background: rgba(0, 229, 255, 0.2);
  transform: scale(1.05);
}

.leaderboard {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 5px;
  margin: 20px auto;
  max-width: 300px;
}

.scores {
  display: flex;
  justify-content: space-around;
  font-size: 1.2em;
}

.post-game-dialog {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 60, 114, 0.95);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1000;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.post-game-dialog.visible {
  display: block;
}

.post-game-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.post-game-btn {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  background: transparent;
  border: 2px solid #00e5ff;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.post-game-btn:hover {
  background: rgba(0, 229, 255, 0.2);
  transform: scale(1.05);
}

.entangle-btn {
  padding: 10px 20px;
  font-size: 18px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 10px;
  transition: all 0.3s ease;
  background: #9c27b0;
  color: white;
}

.entangle-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

.entangle-btn:hover:not(:disabled) {
  transform: scale(1.05);
}

.cell.entangled {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(156, 39, 176, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(156, 39, 176, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(156, 39, 176, 0);
  }
}

.cell.entangle-selection {
  border: 2px solid #9c27b0;
  animation: borderPulse 1s infinite;
}

@keyframes borderPulse {
  0% {
    border-color: rgba(156, 39, 176, 0.4);
  }
  50% {
    border-color: rgba(156, 39, 176, 1);
  }
  100% {
    border-color: rgba(156, 39, 176, 0.4);
  }
}

.entangle-dialog {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 60, 114, 0.95);
  padding: 2rem;
  border-radius: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1000;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  color: white;
  max-width: 400px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.entangle-dialog.visible {
  display: block;
}

.entangle-state {
  font-family: 'Courier New', monospace;
  margin: 1rem 0;
  font-size: 1.2em;
  line-height: 1.5;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

.entangle-dialog-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.entangle-dialog-btn {
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.measure-entangle-btn {
  background: #9c27b0;
  color: white;
  animation: glow 1.5s ease-in-out infinite alternate;
}

.back-to-game-btn {
  background: #673AB7;
  color: white;
}

.entangle-dialog-btn:hover {
  transform: scale(1.05);
}

.help-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  display: none;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  z-index: 1000;
  padding: 2rem 0;
}

.help-screen.visible {
  display: flex;
}

.help-content {
  background: rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border-radius: 15px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 800px;
  margin: 0 auto;
  color: white;
}

.help-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.help-section h2 {
  color: #00e5ff;
  margin-bottom: 1rem;
}

.quantum-concept {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
  background: rgba(0, 229, 255, 0.1);
  border-radius: 8px;
}

.mode-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-card h3 {
  color: #00e5ff;
}

.mode-illustration {
  margin: 1rem 0;
  text-align: center;
}

.moves-guide, .entangle-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.move-step, .entangle-step {
  background: rgba(255, 255, 255, 0.05);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.move-step h4, .entangle-step h4 {
  color: #00e5ff;
  margin-bottom: 0.5rem;
}

.win-illustration {
  text-align: center;
  margin: 1rem 0;
}

.help-button {
  padding: 1.5rem 3rem;
  font-size: 1.2rem;
  background: transparent;
  border: 2px solid #00e5ff;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
}

.help-button:hover {
  background: rgba(0, 229, 255, 0.2);
  transform: scale(1.05);
}

.back-to-menu-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  background: #00e5ff;
  border: none;
  color: #1e3c72;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  margin: 2rem auto 0;
  font-weight: bold;
}

.back-to-menu-btn:hover {
  transform: scale(1.05);
  background: #33eaff;
}

.game-container {
  display: none;
}

.game-container.visible {
  display: block;
}

.start-screen .language-selector {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 5px;
}

.start-screen .lang-btn {
  background: transparent;
  border: 1px solid #00e5ff;
  color: white;
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.start-screen .lang-btn.active {
  background: #00e5ff;
  color: #1e3c72;
}

.start-screen .lang-btn:hover {
  background: rgba(0, 229, 255, 0.2);
}

.language-selector {
  display: none;
}

.mini-board {
  display: grid;
  grid-template-columns: repeat(3, 30px);
  gap: 4px;
  margin: 15px auto;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 4px;
  width: fit-content;
}

.mini-cell {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
}

.mini-cell.x-final {
  color: #ff4081;
  text-shadow: 0 0 5px rgba(255, 64, 129, 0.5);
}

.mini-cell.o-final {
  color: #ffeb3b;
  text-shadow: 0 0 5px rgba(255, 235, 59, 0.5);
}