/* ===== COLOR VARIABLES - Warna Tegas ===== */
:root{
  --red: #FF0000;
  --yellow: #FFD700;
  --green: #00FF00;
  --blue: #0066FF;
  --card-w: 70px;
  --card-h: 70px;
  --radius: 8px;
  --shadow: 0 4px 16px rgba(0,0,0,0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, var(--red) 0%, var(--yellow) 25%, var(--green) 50%, var(--blue) 100%);
  background-size: 400% 400%;
  animation: gradientShift 10s ease infinite;
  min-height: 100vh;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-x: hidden;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hidden {
  display: none !important;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-content {
  text-align: center;
  color: #fff;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-content p {
  font-size: 16px;
  font-weight: 600;
}

/* ===== WELCOME SCREEN ===== */
#welcomeScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--blue), var(--green), var(--yellow), var(--red));
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#welcomeScreen.hidden {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.welcome-content {
  text-align: center;
  animation: welcomeBounce 1s ease;
}

@keyframes welcomeBounce {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.welcome-content h1 {
  font-size: 56px;
  margin: 0 0 15px;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
  animation: titleGlow 2s ease-in-out infinite;
  font-weight: 800;
}

@keyframes titleGlow {
  0%, 100% { 
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    transform: scale(1);
  }
  50% { 
    text-shadow: 0 0 25px rgba(255,255,255,0.9), 3px 3px 6px rgba(0,0,0,0.5);
    transform: scale(1.05);
  }
}

.welcome-content p {
  font-size: 26px;
  margin-bottom: 30px;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

.welcome-btn {
  background: linear-gradient(135deg, var(--yellow), var(--red));
  border: 3px solid #fff;
  padding: 16px 50px;
  border-radius: 40px;
  color: #000;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  animation: buttonPulse 2s ease-in-out infinite;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

@keyframes buttonPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.welcome-btn:hover {
  transform: scale(1.15) translateY(-5px) !important;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}

/* ===== SETUP SCREEN (COMPACT) ===== */
#setupScreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--green), var(--blue), var(--red), var(--yellow));
  background-size: 400% 400%;
  animation: gradientShift 8s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
  overflow-y: auto;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#setupScreen.hidden {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.setup-content {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(15px);
  border-radius: 24px;
  padding: 32px;
  max-width: 650px;
  width: 100%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: setupFadeIn 0.6s ease;
}

@keyframes setupFadeIn {
  from { opacity: 0; transform: translateY(-40px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.setup-header {
  text-align: center;
  margin-bottom: 28px;
}

.setup-header h2 {
  font-size: 34px;
  margin: 0 0 8px 0;
  text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
  font-weight: 800;
  background: linear-gradient(135deg, var(--yellow), var(--red));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.setup-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  font-weight: 500;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-group label {
  font-size: 16px;
  font-weight: 700;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon {
  font-size: 20px;
}

#setupPlayerName {
  padding: 12px 16px;
  border-radius: 12px;
  border: 3px solid var(--yellow);
  outline: none;
  font-size: 16px;
  color: #000;
  font-weight: 600;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

#setupPlayerName:focus {
  border-color: var(--green);
  box-shadow: 0 4px 16px rgba(0,255,0,0.5);
  transform: translateY(-2px);
}

.level-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.level-option {
  cursor: pointer;
}

.level-option input[type="radio"] {
  display: none;
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 130px;
}

.level-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.level-card strong {
  font-size: 17px;
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.level-card small {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1.5;
  font-weight: 500;
}

.level-option input[type="radio"]:checked + .level-card {
  background: linear-gradient(135deg, var(--green), var(--blue));
  border-color: var(--yellow);
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.level-option:hover .level-card {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.2);
}

.volume-icon {
  font-size: 20px;
}

.volume-control input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.volume-control input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.volume-value {
  font-weight: 700;
  min-width: 45px;
  text-align: right;
  font-size: 15px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.start-game-btn {
  background: linear-gradient(135deg, var(--yellow), var(--red));
  border: 3px solid #fff;
  padding: 14px 36px;
  border-radius: 40px;
  color: #000;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: all 0.3s ease;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.start-game-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 10px 28px rgba(0,0,0,0.5);
}

.btn-icon {
  font-size: 24px;
}

/* ===== MAIN APP ===== */
.app {
  width: 100%;
  max-width: 1400px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  border: 3px solid rgba(255, 255, 255, 0.3);
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  border: 3px solid rgba(255,255,255,0.3);
}

.title h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.5px;
  text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
  font-weight: 700;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

.meta {
  display: flex;
  gap: 10px;
  align-items: center;
}

.player-info {
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 12px;
  border-radius: 10px;
  border: 2px solid var(--yellow);
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.player-info label {
  font-size: 12px;
  font-weight: 600;
}

.player-info strong {
  color: var(--yellow);
  font-size: 14px;
}

.stats {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat {
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 10px;
  border-radius: 10px;
  min-width: 70px;
  border: 2px solid;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.stat-red { border-color: var(--red); }
.stat-yellow { border-color: var(--yellow); }
.stat-green { border-color: var(--green); }

.stat span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat strong {
  font-size: 20px;
  display: block;
  font-weight: 700;
  margin-top: 2px;
}

.controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn {
  border: 2px solid #fff;
  padding: 8px 14px;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: all .2s ease;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  font-size: 13px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.btn-green { background: var(--green); color: #000; }
.btn-yellow { background: var(--yellow); color: #000; }
.btn-red { background: var(--red); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 16px rgba(0,0,0,0.4);
}

.btn:active {
  transform: translateY(-1px);
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
}

/* Particle Canvas */
.particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.board {
  display: grid;
  gap: 6px;
  justify-content: center;
  align-content: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  backdrop-filter: blur(5px);
  border: 3px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  perspective: 1000px;
  opacity: 0;
  animation: cardFall 0.6s ease forwards;
}

@keyframes cardFall {
  0% {
    opacity: 0;
    transform: translateY(-500px) rotateZ(-15deg);
  }
  60% {
    transform: translateY(20px) rotateZ(5deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotateZ(0);
  }
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }
.card:nth-child(7) { animation-delay: 0.35s; }
.card:nth-child(8) { animation-delay: 0.4s; }
.card:nth-child(9) { animation-delay: 0.45s; }
.card:nth-child(10) { animation-delay: 0.5s; }
.card:nth-child(11) { animation-delay: 0.55s; }
.card:nth-child(12) { animation-delay: 0.6s; }
.card:nth-child(13) { animation-delay: 0.65s; }
.card:nth-child(14) { animation-delay: 0.7s; }
.card:nth-child(15) { animation-delay: 0.75s; }
.card:nth-child(16) { animation-delay: 0.8s; }
.card:nth-child(17) { animation-delay: 0.85s; }
.card:nth-child(18) { animation-delay: 0.9s; }
.card:nth-child(19) { animation-delay: 0.95s; }
.card:nth-child(20) { animation-delay: 1s; }
.card:nth-child(21) { animation-delay: 1.05s; }
.card:nth-child(22) { animation-delay: 1.1s; }
.card:nth-child(23) { animation-delay: 1.15s; }
.card:nth-child(24) { animation-delay: 1.2s; }
.card:nth-child(25) { animation-delay: 1.25s; }
.card:nth-child(26) { animation-delay: 1.3s; }
.card:nth-child(27) { animation-delay: 1.35s; }
.card:nth-child(28) { animation-delay: 1.4s; }
.card:nth-child(29) { animation-delay: 1.45s; }
.card:nth-child(30) { animation-delay: 1.5s; }
.card:nth-child(31) { animation-delay: 1.55s; }
.card:nth-child(32) { animation-delay: 1.6s; }
.card:nth-child(33) { animation-delay: 1.65s; }
.card:nth-child(34) { animation-delay: 1.7s; }
.card:nth-child(35) { animation-delay: 1.75s; }
.card:nth-child(36) { animation-delay: 1.8s; }

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform .4s;
  transform-style: preserve-3d;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  border: 4px solid var(--yellow);
  background: #ffffff;
}

.card.flip .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: inherit;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back {
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #fff;
  font-weight: 800;
  font-size: 36px;
  transform: rotateY(0deg);
  text-shadow: 2px 2px 5px rgba(0,0,0,0.5);
}

.card-front {
  transform: rotateY(180deg);
  background: #fff;
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.panel {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-card {
  background: rgba(0, 0, 0, 0.4);
  padding: 14px;
  border-radius: 12px;
  border: 3px solid;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.panel-leaderboard { border-color: var(--yellow); }
.panel-info { border-color: var(--blue); }

.panel-card h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}

.panel-card ol {
  margin: 0 0 10px 0;
  padding-left: 18px;
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
  font-weight: 500;
}

.panel-card ul {
  padding-left: 18px;
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  font-weight: 500;
}

.panel-card li {
  margin-bottom: 6px;
}

.footer {
  margin-top: 10px;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
  font-size: 12px;
  font-weight: 500;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9));
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 40px;
  max-width: 450px;
  width: 90%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  text-align: center;
  animation: modalSlideIn 0.4s ease;
}

.modal-content.small {
  max-width: 380px;
  padding: 32px;
}

@keyframes modalSlideIn {
  from { transform: translateY(-40px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: iconBounce 0.6s ease;
}

@keyframes iconBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.modal-content h2 {
  font-size: 30px;
  margin: 0 0 12px 0;
  font-weight: 800;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.modal-content h3 {
  font-size: 24px;
  margin: 0 0 16px 0;
  font-weight: 700;
}

.modal-content p {
  font-size: 16px;
  margin-bottom: 24px;
  line-height: 1.5;
  opacity: 0.95;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 28px;
  border-radius: 40px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  border: 3px solid #fff;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff;
}

.modal-btn.secondary {
  background: linear-gradient(135deg, var(--red), var(--yellow));
  color: #000;
}

.modal-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Volume Controls in Modal */
.volume-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.volume-item {
  text-align: left;
}

.volume-item label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
}

.volume-item input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
}

.volume-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
}

.volume-item input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
}

.volume-item span {
  font-weight: 700;
  color: var(--yellow);
  font-size: 14px;
  margin-left: 8px;
}

/* Responsive */
@media (max-width: 980px) {
  .app { padding: 12px; }
  main { flex-direction: column; }
  .panel { width: 100%; }
  .meta { flex-direction: column; gap: 6px; }
  .header { flex-direction: column; }
  .setup-content { padding: 24px 16px; }
  .level-options { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  :root { --card-w: 60px; --card-h: 60px; }
  .board { gap: 5px; padding: 8px; }
  .card-back { font-size: 28px; }
  .welcome-content h1 { font-size: 42px; }
  .welcome-content p { font-size: 20px; }
  .welcome-btn { font-size: 20px; padding: 14px 36px; }
  .title h1 { font-size: 22px; }
  .setup-content h2 { font-size: 28px; }
  .level-options { grid-template-columns: 1fr; }
}