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

body {
  background: #1a1a2e;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #16213e 0%, #1a1a2e 50%, #0f3460 100%);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(108, 92, 231, 0.3), 0 0 80px rgba(108, 92, 231, 0.1);
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  background: rgba(22, 33, 62, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
  padding: 20px;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Title Screen */
.title-art {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 0 30px rgba(108, 92, 231, 0.4);
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: #ffd93d;
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.5), 0 2px 4px rgba(0,0,0,0.5);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1rem;
  color: #a8b8d8;
  margin-bottom: 32px;
  text-align: center;
  line-height: 1.4;
}

/* Buttons */
.btn-primary {
  padding: 14px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a2e;
  background: linear-gradient(135deg, #ffd93d, #ffb830);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 184, 48, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 1px;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 184, 48, 0.5);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 12px 16px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.hud-item {
  background: rgba(15, 52, 96, 0.85);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(108, 92, 231, 0.2);
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6c5ce7;
  margin-bottom: 2px;
}

.hud-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd93d;
  text-shadow: 0 0 8px rgba(255, 217, 61, 0.3);
}

/* Timer urgency */
.hud-value.urgent {
  color: #ff6b6b;
  animation: pulse-urgent 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-urgent {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

/* Result Screens */
.result-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 16px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.win-title {
  color: #ffd93d;
}

.lose-title {
  color: #ff6b6b;
}

.result-score {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
}

.result-bonus {
  font-size: 1rem;
  color: #a8d8a8;
  margin-bottom: 8px;
}

.result-matches {
  font-size: 1rem;
  color: #a8b8d8;
  margin-bottom: 24px;
}

/* Canvas */
#game-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}
