@import url('https://fonts.googleapis.com/css2?family=Creepster&family=Montserrat:wght@400;600;800;900&display=swap');

:root {
  --bg-color: #0b0114;
  --panel-bg: rgba(22, 6, 38, 0.88);
  --panel-border: #ff7518;
  --color-orange: #ff7518;
  --color-purple: #9d4edd;
  --color-green: #39ff14;
  --color-blood: #ff2a2a;
  --color-gold: #ffb703;
  --text-main: #f8f9fa;
  --text-dim: #b8b8b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Montserrat', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(157, 78, 221, 0.22) 0%, transparent 60%),
    radial-gradient(circle at 10% 90%, rgba(255, 117, 24, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(57, 255, 20, 0.08) 0%, transparent 40%);
}

/* Floating Spooky Fog & Bats */
.fog-layer {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  background: radial-gradient(ellipse at bottom, rgba(74, 20, 140, 0.15) 0%, transparent 70%);
  z-index: 1;
}

.bat {
  position: absolute;
  font-size: 24px;
  user-select: none;
  pointer-events: none;
  animation: flyBat 18s linear infinite;
  z-index: 2;
  opacity: 0.6;
}

@keyframes flyBat {
  0% { transform: translate(-100px, 80vh) rotate(10deg) scale(0.6); }
  25% { transform: translate(30vw, 30vh) rotate(-15deg) scale(0.9); }
  50% { transform: translate(60vw, 60vh) rotate(15deg) scale(0.7); }
  75% { transform: translate(85vw, 15vh) rotate(-10deg) scale(1); }
  100% { transform: translate(110vw, -50px) rotate(20deg) scale(0.6); }
}

/* Header & Controls */
header {
  position: relative;
  z-index: 10;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 117, 24, 0.3);
  background: rgba(11, 1, 20, 0.85);
  backdrop-filter: blur(8px);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.spooky-logo {
  font-family: 'Creepster', cursive;
  font-size: 2rem;
  color: var(--color-orange);
  text-shadow: 0 0 10px rgba(255, 117, 24, 0.8), 0 0 20px rgba(255, 42, 42, 0.5);
  letter-spacing: 2px;
}

.header-controls {
  display: flex;
  gap: 0.75rem;
}

.btn-icon {
  background: rgba(157, 78, 221, 0.2);
  border: 1px solid var(--color-purple);
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon:hover {
  background: var(--color-orange);
  border-color: var(--color-orange);
  box-shadow: 0 0 12px var(--color-orange);
  transform: translateY(-2px);
}

/* Main Container */
main {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Glass Panels */
.spooky-card {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(255, 117, 24, 0.25), inset 0 0 15px rgba(157, 78, 221, 0.2);
  padding: 2.5rem;
  max-width: 720px;
  width: 100%;
  text-align: center;
  position: relative;
  backdrop-filter: blur(12px);
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.spooky-title {
  font-family: 'Creepster', cursive;
  font-size: 2.8rem;
  color: var(--color-orange);
  letter-spacing: 3px;
  margin-bottom: 0.6rem;
  text-shadow: 0 0 15px rgba(255, 117, 24, 0.7);
}

.spooky-subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* Guardian Dog Rohamis Frame */
.guardian-box {
  margin: 1rem auto 2rem auto;
  position: relative;
  width: 200px;
  height: 200px;
}

.guardian-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--color-orange);
  box-shadow: 0 0 25px rgba(255, 117, 24, 0.8), 0 0 50px rgba(157, 78, 221, 0.5);
  animation: pulseGlow 3s ease-in-out infinite alternate;
}

.guardian-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a0845;
  border: 2px solid var(--color-green);
  color: var(--color-green);
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

@keyframes pulseGlow {
  0% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 117, 24, 0.6); }
  100% { transform: scale(1.03); box-shadow: 0 0 35px rgba(255, 117, 24, 0.9), 0 0 20px var(--color-purple); }
}

/* Code Input Form */
.code-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  max-width: 440px;
  margin: 0 auto;
}

.code-input {
  background: rgba(10, 2, 20, 0.9);
  border: 2px solid var(--color-purple);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  font-size: 1.3rem;
  color: var(--color-green);
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.code-input:focus {
  border-color: var(--color-orange);
  box-shadow: 0 0 20px rgba(255, 117, 24, 0.7), inset 0 0 10px rgba(0, 0, 0, 0.9);
}

.btn-spooky {
  background: linear-gradient(135deg, #ff7518, #d00000);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 117, 24, 0.6);
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.btn-spooky:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 0 30px rgba(255, 117, 24, 0.9);
}

/* Error banner */
.msg-error {
  color: var(--color-blood);
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.5rem;
  display: none;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* User Profile Header (When Logged in) */
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 840px;
  background: rgba(30, 8, 50, 0.9);
  border: 2px solid var(--color-purple);
  border-radius: 16px;
  padding: 0.8rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 0 15px rgba(157, 78, 221, 0.4);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.player-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-orange);
  box-shadow: 0 0 10px var(--color-orange);
}

.player-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-orange);
}

.player-status {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Stage Progress Bar */
.progress-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.progress-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  transition: all 0.3s;
}

.progress-step.completed {
  background: var(--color-green);
  border-color: var(--color-green);
  color: #000;
  box-shadow: 0 0 10px var(--color-green);
}

.progress-step.active {
  border-color: var(--color-orange);
  background: var(--color-orange);
  color: #fff;
  box-shadow: 0 0 12px var(--color-orange);
}

/* Trials / Riddles Container */
.riddle-box {
  background: rgba(14, 2, 28, 0.85);
  border: 2px solid var(--color-purple);
  border-radius: 16px;
  padding: 1.8rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.riddle-title {
  color: var(--color-gold);
  font-family: 'Creepster', cursive;
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
}

.riddle-text {
  font-size: 1.15rem;
  line-height: 1.6;
  margin-bottom: 1.4rem;
}

.riddle-options {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.option-btn {
  background: rgba(45, 10, 78, 0.8);
  border: 2px solid rgba(157, 78, 221, 0.6);
  border-radius: 10px;
  padding: 0.9rem 1.2rem;
  font-size: 1.05rem;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.option-btn:hover {
  background: rgba(255, 117, 24, 0.25);
  border-color: var(--color-orange);
  transform: translateX(6px);
}

.option-btn.correct {
  background: rgba(57, 255, 20, 0.3) !important;
  border-color: var(--color-green) !important;
  color: var(--color-green) !important;
}

.option-btn.wrong {
  background: rgba(255, 42, 42, 0.3) !important;
  border-color: var(--color-blood) !important;
  color: var(--color-blood) !important;
}

/* Games Section */
.game-viewport-card {
  max-width: 760px;
  width: 100%;
}

.game-canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 1rem auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 25px rgba(255, 117, 24, 0.5);
  border: 3px solid var(--color-orange);
  background: #000;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.game-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-secondary {
  background: rgba(157, 78, 221, 0.3);
  border: 1px solid var(--color-purple);
  color: #fff;
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--color-purple);
  box-shadow: 0 0 15px var(--color-purple);
}

/* Mobile Warning Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-content {
  background: #18052b;
  border: 3px solid var(--color-orange);
  border-radius: 20px;
  padding: 2.2rem;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px rgba(255, 117, 24, 0.8);
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 1.8s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* VIP Halloween Invitation Ticket (Victory Screen) */
.ticket-container {
  background: linear-gradient(145deg, #1b072c, #0a0114);
  border: 4px solid var(--color-gold);
  border-radius: 24px;
  padding: 2.5rem;
  max-width: 760px;
  width: 100%;
  position: relative;
  box-shadow: 0 0 40px rgba(255, 183, 3, 0.5), inset 0 0 30px rgba(157, 78, 221, 0.3);
  text-align: center;
}

.ticket-header {
  border-bottom: 2px dashed rgba(255, 183, 3, 0.5);
  padding-bottom: 1.5rem;
  margin-bottom: 1.8rem;
}

.ticket-badge {
  display: inline-block;
  background: var(--color-gold);
  color: #000;
  font-weight: 900;
  font-size: 0.9rem;
  padding: 0.3rem 1.2rem;
  border-radius: 20px;
  letter-spacing: 2px;
  margin-bottom: 0.8rem;
}

.ticket-guest-spotlight {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.ticket-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 4px solid var(--color-orange);
  object-fit: cover;
  box-shadow: 0 0 25px var(--color-orange);
}

.ticket-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
  text-align: left;
}

.ticket-item {
  background: rgba(45, 12, 75, 0.6);
  border: 1px solid rgba(255, 117, 24, 0.4);
  border-radius: 12px;
  padding: 1rem;
}

.ticket-item-label {
  font-size: 0.85rem;
  color: var(--color-gold);
  font-weight: 700;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ticket-item-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

/* Crucial Rules Box */
.rules-card {
  background: rgba(255, 42, 42, 0.15);
  border: 2px solid var(--color-blood);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: left;
}

.rules-card h4 {
  color: var(--color-blood);
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rules-list li {
  font-size: 1.05rem;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

/* Admin Table */
.admin-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  margin: 1.5rem 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.admin-table th, .admin-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-table th {
  background: rgba(157, 78, 221, 0.3);
  color: var(--color-gold);
}

.copy-btn {
  background: var(--color-orange);
  color: #000;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
  font-size: 0.75rem;
}

/* Footer */
footer {
  position: relative;
  z-index: 10;
  padding: 1.2rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 117, 24, 0.2);
}

/* Responsive tweaks */
@media (max-width: 600px) {
  .spooky-card {
    padding: 1.5rem;
  }
  .spooky-title {
    font-size: 2.2rem;
  }
  .guardian-box {
    width: 150px;
    height: 150px;
  }
  .ticket-guest-spotlight {
    flex-direction: column;
  }
}
