/* style.css - Premium Tetris Game styling */

/* Global reset and dark theme */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: hsl(220, 15%, 10%);
  color: hsl(0, 0%, 90%);
  overflow: hidden;
}

/* Glassmorphism container */
.game-container {
  width: 100%;
  max-width: 500px;
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 24px;
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.title {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, hsl(210, 100%, 75%), hsl(260, 100%, 75%));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Line-clear flash effect (canvas-based but triggered via class on container if needed, or just drawn) 
   We'll use a CSS class on the canvas container for a brief flash. */
.flash-white {
  animation: flash 0.3s ease-out;
}

@keyframes flash {
  0% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(2);
  }

  100% {
    filter: brightness(1);
  }
}

.game-layout {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
}

/* Canvas styling */
#tetris-canvas {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 140px;
}

.ui-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ui-card h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: hsl(210, 20%, 60%);
  margin-bottom: 0.25rem;
}

#next-canvas {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-item .label {
  font-size: 0.75rem;
  color: hsl(210, 20%, 50%);
  text-transform: uppercase;
  font-weight: 700;
}

.stat-item .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

.controls-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-btn {
  padding: 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-btn.primary {
  background: linear-gradient(135deg, hsl(210, 80%, 50%), hsl(210, 100%, 40%));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 120, 255, 0.3);
}

.control-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.control-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.control-btn.danger {
  background: linear-gradient(135deg, hsl(0, 70%, 50%), hsl(0, 80%, 40%));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.2);
}

/* Score List Styling */
.score-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: hsl(210, 100%, 95%);
}

.score-item {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.score-item:last-child {
  border-bottom: none;
}

.text-link {
  background: none;
  border: none;
  color: hsl(210, 100%, 75%);
  cursor: pointer;
  font-size: 0.75rem;
  text-decoration: underline;
  margin-top: 0.5rem;
  transition: color 0.2s;
}

.text-link:hover {
  color: #fff;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: rgba(25, 30, 45, 0.95);
  padding: 2rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content.wide {
  max-width: 600px;
}

.modal-content h2 {
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff, hsl(210, 100%, 75%));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-content input {
  width: 100%;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #fff;
  margin-bottom: 1.5rem;
  outline: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.scores-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
}

#all-scores-table {
  width: 100%;
  border-collapse: collapse;
}

#all-scores-table th,
#all-scores-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#all-scores-table th {
  color: hsl(210, 20%, 50%);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Mobile Controls Styling */
.mobile-controls {
  display: none;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
  width: 100%;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.mobile-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.1s ease;
}

.mobile-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

#hard-drop {
  border-radius: 30px;
  width: 100px;
}

/* Responsive */
@media (max-width: 550px) {

  html,
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  .title {
    display: none;
  }

  .game-container {
    margin: 0;
    border-radius: 0;
    height: 100dvh;
    max-width: none;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.8rem;
  }

  .game-layout {
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    flex: 1;
  }

  .main-canvas-container {
    flex: 2;
    display: flex;
    justify-content: flex-end;
  }

  #tetris-canvas {
    max-width: 100%;
    max-height: 55vh;
    height: auto;
    width: auto;
  }

  .side-panel {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0;
    background: none;
    border: none;
    align-items: stretch;
    justify-content: flex-start;
  }

  .ui-card {
    flex: none;
    padding: 0.5rem;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
  }

  .ui-card h3 {
    font-size: 0.65rem;
    margin-bottom: 0;
    color: hsl(210, 20%, 50%);
  }

  .stat-item .value {
    font-size: 1.2rem;
    background: linear-gradient(to bottom, #fff, hsl(210, 20%, 80%));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .controls-container {
    position: static;
    flex: none;
    flex-direction: column;
    gap: 0.5rem;
    background: none;
    backdrop-filter: none;
    border: none;
    height: auto;
    padding: 0;
  }

  .control-btn {
    width: 100%;
    max-width: none;
    padding: 0.6rem;
    font-size: 0.8rem;
  }

  .mobile-controls {
    display: flex;
    margin-top: auto;
    gap: 0.8rem;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .mobile-btn {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.15);
  }

  #hard-drop {
    width: 90px;
    border-radius: 30px;
  }

  .control-row {
    gap: 0.8rem;
  }
}