* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

:root {
  --primary: #025425;
  --secondary: #297a3d;
  --success: #4cc9f0;
  --danger: #f49325;
  --warning: #f8961e;
  --light: #c6ae6c;
  --dark: #111111;
  --gray: #1f1f1f;
  --light-gray: #e9ecef;
}

body {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  min-height: 100vh;
  padding: 10px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.auth-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  perspective: 1000px;
}

#auth-screen {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  text-align: center;
  max-width: 500px;
  margin: 50px auto;
  position: relative;
  z-index: 2;
}

#auth-screen::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 84, 37, 0.08);
  z-index: -1;
}
.auth-content {
  position: relative;
  z-index: 10;
  color: var(--primary);
}

.lightning {
  position: absolute;
  font-size: 24px;
  opacity: 0.4;
  user-select: none;
  pointer-events: none;
  z-index: 0;
  transition: transform 0.3s ease-out;
  transform-style: preserve-3d;
}

#auth-screen h1 {
  color: var(--primary);
  margin-bottom: 30px;
  font-size: 2rem;
}

#auth-screen input {
  width: 100%;
  padding: 15px;
  border: 2px solid var(--light-gray);
  border-radius: 10px;
  font-size: 1.1rem;
  margin-bottom: 20px;
  transition: border-color 0.3s;
}

#auth-screen input:focus {
  outline: none;
  border-color: var(--primary);
}

#auth-screen button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.3s;
  width: 100%;
}

#auth-screen button:hover {
  background: var(--secondary);
}

/* Game Screen */
#game-screen {
  display: none;
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--light-gray);
}

.stats {
  display: flex;
  gap: 10px;
}

.stat-box {
  background: var(--light);
  padding: 5px 10px;
  border-radius: 10px;
  text-align: center;
}

.stat-box h3 {
  color: var(--gray);
  font-size: 0.9rem;
  margin-bottom: 5px;
}

.stat-box p {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
}

.game-controls {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--secondary);
}

.btn-secondary {
  background: var(--light-gray);
  color: var(--dark);
}

.btn-secondary:hover {
  background: red;
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  opacity: 0.8;
}

/* Game Area */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 550px;
}

.workspace-and-task {
  display: flex;
  gap: 20px;
  flex: 1;
}

.workspace {
  width: 780px;
  max-height: 430px;
  background: #a5a5a5;
  border-radius: 15px;
  position: relative;
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(15, 50px);
  grid-template-rows: repeat(8, 50px);
  width: 100%;
  height: 100%;
  gap: 1px;
  padding: 10px;
}

.grid-cell {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.task-display {
  flex: 1;
  max-width: 400px;
  max-height: 430px;
  background: var(--light);
  border-radius: 15px;
  padding: 15px;
  display: flex;
  flex-direction: column;
}

.task-display h3 {
  color: var(--primary);
  margin-bottom: 10px;
}

.calculation-input {
  margin-top: auto;
  display: flex;
  gap: 10px;
  flex-direction: column;
}

.calculation-input input,
.calculation-input button {
  width: 100%;
}

.elements-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 15px;
  background: var(--light);
  border-radius: 15px;
  min-height: 80px;
}

.element {
  width: 60px;
  height: 60px;
  background: white;
  border: 2px dashed var(--light-gray);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: all 0.2s;
}

.delete-zone {
  display: none;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 53, 69, 0.3);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: bold;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.element:hover {
  border-color: var(--primary);
  transform: scale(1.1);
}

.element img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  border-radius: 10px;
}

.placed-element img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.grid-cell.current {
  position: relative;
  animation: currentPulse 0.6s ease-out;
}

.grid-cell.current::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  height: 120%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 0, 0.9),
    rgba(255, 140, 0, 0.5),
    transparent 80%
  );
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;
  animation: currentGlow 0.6s ease-out;
}

@keyframes currentPulse {
  0% {
    transform: scale(1) translateY(0);
  }
  40% {
    transform: scale(1.15) translateY(-8px);
    z-index: 10;
  }
  70% {
    transform: scale(1) translateY(0);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

@keyframes currentGlow {
  0% {
    opacity: 0.8;
    width: 0%;
    height: 0%;
  }
  40% {
    opacity: 1;
    width: 140%;
    height: 140%;
  }
  100% {
    opacity: 0;
    width: 200%;
    height: 200%;
  }
}

.placed-element.highlight {
  position: relative;
  animation: pulseGlow 1s ease-in-out infinite;
  z-index: 10;
  border: 2px solid red;
}

.placed-element.highlight::before {
  content: "";
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  background: radial-gradient(
    circle,
    rgba(255, 217, 0, 0.414),
    rgba(255, 140, 0, 0.4)
  );
  z-index: 0;
  animation: glowPulse 1s ease-in-out infinite;
  filter: blur(8px);
  opacity: 0.5;
}

@keyframes pulseGlow {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(255, 165, 0, 1), 0 0 40px rgba(255, 215, 0, 0.8);
  }
}

@keyframes glowPulse {
  0%,
  100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

.element-count {
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placed-element {
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.placed-element:hover {
  transform: scale(1.1);
  z-index: 10;
}

.placed-element.led.on {
  background: linear-gradient(45deg, #4cc9f0, #4361ee);
  box-shadow: 0 0 20px rgba(76, 201, 240, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
  .workspace-and-task {
    flex-direction: column;
  }

  .task-display {
    max-width: none;
  }
}

/* Success Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.success-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(76, 201, 240, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: pulse 2s ease-in-out;
  display: none;
}

.success-animation h2 {
  color: white;
  font-size: 4rem;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 30px;
  border-radius: 10px;
  color: white;
  font-weight: bold;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s, fadeOut 0.5s 2.5s forwards;
}

.notification.success {
  background: var(--primary);
}
.notification.error {
  background: var(--danger);
}

@keyframes slideIn {
  from {
    top: -50px;
    opacity: 0;
  }
  to {
    top: 20px;
    opacity: 1;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

.modal {
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  display: flex;
  flex-direction: column;
  justify-self: space-between;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin: 0 auto;
  background: white;
  padding: 25px;
  border-radius: 15px;
  width: 300px;
  text-align: center;
}

.help-modal-content {
  width: fit-content;
  display: block;
  padding: 50px;
  text-align: left;
}

.modal-content ul {
  padding-left: 50px;
}

.modal-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-input {
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 5px 10px;
  width: 100%;
  font-size: 1.1rem;
}

.close {
  font-size: 28px;
  cursor: pointer;
}

.save-button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.3s;
  width: 100%;
}

#leaderboard-screen {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 50px auto;
  text-align: center;
}

.leaderboard-header {
  margin-bottom: 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.leaderboard-header h1 {
  color: var(--primary);
  margin-bottom: 20px;
  font-size: 2rem;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--light-gray);
}

.leaderboard-table th {
  color: var(--primary);
  font-weight: bold;
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

#leaderboard-body .empty {
  text-align: center;
  color: #888;
  padding: 20px;
  font-style: italic;
}
