:root {
  --bg-dark: #0d0f12;
  --bg-card: rgba(22, 27, 34, 0.85);
  --oak-wood-dark: #3b2816;
  --oak-wood: #5a3d28;
  --oak-wood-light: #8b5a2b;
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.4);
  --curtain-red: #7f1d1d;
  --curtain-dark: #450a0a;
  --curtain-gold: #fbbf24;
  --parchment: #fdf6e2;
  --parchment-border: #d4c5a9;
  --ink: #1e293b;
  --mc-green: #22c55e;
  --mc-red: #ef4444;
  --mc-yellow: #eab308;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mc: 'Minecraftia', 'VT323', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: #f1f5f9;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  position: relative;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(circle at 50% 30%, rgba(245, 158, 11, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 80% 20%, rgba(185, 28, 28, 0.1) 0%, transparent 50%),
    linear-gradient(180deg, #090b0e 0%, #151921 50%, #0d0e12 100%);
  z-index: -2;
}

.pixel-grid {
  position: fixed;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: -1;
}

header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 1.25rem 2.5rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mc-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #78350f, #451a03);
  border: 3px solid #b45309;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 2px 0 rgba(255,255,255,0.2);
}

.mc-icon svg {
  width: 26px;
  height: 26px;
  fill: #fbbf24;
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 40%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

main {
  position: relative;
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.voting-hall {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.voting-hall.hidden {
  display: none;
}

.hall-header {
  text-align: center;
  margin-bottom: 2rem;
}

.hall-header h2 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0,0,0,0.7);
}

.stage-container {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 3rem;
  width: 100%;
  align-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 3rem;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.torch-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.25) 0%, transparent 70%);
  filter: blur(25px);
  pointer-events: none;
  animation: torchFlicker 3s infinite alternate ease-in-out;
}

.torch-left { top: 10%; left: 8%; }
.torch-right { bottom: 15%; right: 12%; }

@keyframes torchFlicker {
  0% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 0.95; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.chest-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.mc-chest-wrapper {
  position: relative;
  width: 260px;
  height: 220px;
  cursor: pointer;
  perspective: 900px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mc-chest-wrapper:hover {
  transform: translateY(-8px) scale(1.03);
}

.mc-chest-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 20px 25px rgba(0,0,0,0.7));
}

.chest-pedestal {
  width: 280px;
  height: 36px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  border: 3px solid #334155;
  border-radius: 8px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.6);
  margin-top: -10px;
}

.interaction-area {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.envelope-station {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  position: relative;
  transition: all 0.3s ease;
}

.envelope-station.pulse-attention {
  animation: stationGlow 1.5s infinite alternate ease-in-out;
  border-color: var(--gold);
}

@keyframes stationGlow {
  0% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.2); }
  100% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.6); }
}

.station-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.station-title h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.envelope-count-tag {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.envelope-stack {
  position: relative;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0.75rem 0;
}

.envelope-card {
  position: absolute;
  width: 170px;
  height: 95px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 60%, #f59e0b 100%);
  border: 2px solid #b45309;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: #78350f;
  font-weight: 700;
  font-size: 0.75rem;
}

.envelope-card:nth-child(1) {
  transform: rotate(-5deg) translateY(6px);
  opacity: 0.85;
}

.envelope-card:nth-child(2) {
  transform: rotate(4deg) translateY(3px);
  opacity: 0.95;
}

.envelope-card:nth-child(3) {
  transform: rotate(0deg) translateY(0px);
  z-index: 2;
}

.envelope-stack:hover .envelope-card:nth-child(3) {
  transform: translateY(-12px) scale(1.04);
  box-shadow: 0 16px 30px rgba(0,0,0,0.5), 0 0 20px var(--gold-glow);
}

.envelope-seal-preview {
  width: 22px;
  height: 22px;
  background: #dc2626;
  border-radius: 50%;
  margin: 0 auto;
  border: 1px solid #7f1d1d;
  box-shadow: inset 0 2px 2px rgba(255,255,255,0.4);
}

.envelope-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.taken-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 8px;
  color: #86efac;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.75rem;
  animation: fadeIn 0.3s ease;
}

.taken-badge.active {
  display: flex;
}

.curtain-pass-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1.25rem 1.75rem;
  background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 60%, #450a0a 100%);
  border: 2px solid #ef4444;
  border-radius: 14px;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(185, 28, 28, 0.5), inset 0 2px 0 rgba(255,255,255,0.25);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.curtain-pass-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: 0.5s;
}

.curtain-pass-btn:hover::before {
  left: 100%;
}

.curtain-pass-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 35px -5px rgba(220, 38, 38, 0.7), 0 0 20px rgba(239, 68, 68, 0.4);
}

.arrow-icon-wrapper {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.curtain-pass-btn:hover .arrow-icon-wrapper {
  transform: translateX(4px);
  background: #ffffff;
  color: #7f1d1d;
}

.arrow-icon-wrapper svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.curtain-transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  display: flex;
  overflow: hidden;
}

.curtain-panel {
  flex: 1;
  height: 100%;
  background: 
    linear-gradient(90deg, 
      rgba(40, 5, 5, 0.95) 0%, 
      #7f1d1d 20%, 
      #991b1b 50%, 
      #7f1d1d 80%, 
      rgba(40, 5, 5, 0.95) 100%
    );
  box-shadow: inset 0 0 60px rgba(0,0,0,0.8);
  position: relative;
  transition: transform 0.85s cubic-bezier(0.77, 0, 0.175, 1);
}

.curtain-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.25) 0px,
    rgba(255, 255, 255, 0.08) 18px,
    rgba(0, 0, 0, 0.3) 36px
  );
  opacity: 0.8;
}

.curtain-left {
  transform: translateX(-100%);
  border-right: 4px solid #f59e0b;
}

.curtain-right {
  transform: translateX(100%);
  border-left: 4px solid #f59e0b;
}

.curtain-transition-overlay.closed .curtain-left {
  transform: translateX(0%);
}
.curtain-transition-overlay.closed .curtain-right {
  transform: translateX(0%);
}

.voting-booth {
  width: 100%;
  max-width: 900px;
  position: relative;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.6s ease, transform 0.6s ease;
  display: none;
}

.voting-booth.active {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.booth-curtain-frame {
  position: relative;
  background: 
    radial-gradient(circle at 50% 10%, rgba(254, 240, 138, 0.2) 0%, transparent 55%),
    linear-gradient(180deg, #3d0707 0%, #1c0505 100%);
  border: 4px solid #7f1d1d;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  box-shadow: 
    0 30px 70px rgba(0,0,0,0.9),
    inset 0 0 100px rgba(0,0,0,0.8),
    inset 0 4px 0 rgba(245, 158, 11, 0.3);
  overflow: hidden;
}

.curtain-valance {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  background: linear-gradient(180deg, #991b1b 0%, #580c0c 100%);
  border-bottom: 3px solid #f59e0b;
  display: flex;
  justify-content: space-around;
  z-index: 5;
}

.valance-fold {
  width: 32px;
  height: 28px;
  background: #7f1d1d;
  border-radius: 0 0 16px 16px;
  border: 1px solid #b91c1c;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.booth-desk {
  background: linear-gradient(180deg, #5c3b1e 0%, #3e2612 100%);
  border: 4px solid #2b180a;
  border-radius: 18px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.7), inset 0 2px 4px rgba(255,255,255,0.2);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.desk-lamp-spot {
  position: absolute;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
  height: 250px;
  background: radial-gradient(ellipse at center, rgba(254, 240, 138, 0.28) 0%, transparent 70%);
  filter: blur(25px);
  pointer-events: none;
}

.desk-quill-pen {
  position: absolute;
  top: 30px;
  right: 28px;
  width: 50px;
  height: 180px;
  pointer-events: none;
  filter: drop-shadow(4px 10px 10px rgba(0,0,0,0.6));
  z-index: 10;
  transform: rotate(18deg);
  transition: transform 0.4s ease;
}

.parchment-sheet {
  width: 100%;
  max-width: 660px;
  background-color: var(--parchment);
  background-image: 
    radial-gradient(#f0e2bd 1px, transparent 1px),
    linear-gradient(to bottom, rgba(212, 197, 169, 0.3) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 2px solid var(--parchment-border);
  border-radius: 12px;
  padding: 2.5rem 2.2rem;
  box-shadow: 
    0 15px 35px rgba(0,0,0,0.5),
    inset 0 0 40px rgba(212, 197, 169, 0.4);
  color: var(--ink);
  position: relative;
  transition: transform 0.5s ease;
}

.paper-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid rgba(180, 83, 9, 0.25);
}

.paper-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e1b4b;
  line-height: 1.3;
}

.voting-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
}

.status-radio-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 0.6rem;
  background: rgba(255, 255, 255, 0.75);
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.status-radio-label:hover {
  background: #ffffff;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.status-radio-input {
  display: none;
}

.status-radio-input:checked + .status-radio-label {
  background: #ffffff;
  border-color: #b45309;
  color: #78350f;
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.2);
  transform: translateY(-2px);
}

.status-radio-input[value="active"]:checked + .status-radio-label {
  border-color: #16a34a;
  color: #15803d;
  background: #f0fdf4;
}

.status-radio-input[value="quit"]:checked + .status-radio-label {
  border-color: #eab308;
  color: #a16207;
  background: #fefce8;
}

.status-radio-input[value="inactive"]:checked + .status-radio-label {
  border-color: #dc2626;
  color: #b91c1c;
  background: #fef2f2;
}

.paper-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.92rem;
  color: #0f172a;
  transition: all 0.2s ease;
}

.paper-input:focus {
  outline: none;
  background: #ffffff;
  border-color: #b45309;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}

.paper-textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.submit-ballot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1.15rem;
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  border: 2px solid #22c55e;
  border-radius: 12px;
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 20px -5px rgba(22, 101, 52, 0.6), inset 0 2px 0 rgba(255,255,255,0.3);
  transition: all 0.25s ease;
  margin-top: 0.5rem;
}

.submit-ballot-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 14px 28px -5px rgba(22, 101, 52, 0.8);
}

.back-to-hall-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: color 0.2s ease;
}

.back-to-hall-btn:hover {
  color: #f1f5f9;
}

.seal-animation-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 10, 0.88);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.seal-animation-overlay.active {
  display: flex;
}

.sealed-envelope-visual {
  width: 240px;
  height: 140px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 3px solid #b45309;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: envelopeFly 1.8s ease-in-out forwards;
}

.wax-seal {
  width: 58px;
  height: 58px;
  background: radial-gradient(circle at 35% 35%, #ef4444 0%, #991b1b 70%, #450a0a 100%);
  border-radius: 50%;
  border: 2px solid #7f1d1d;
  box-shadow: 0 6px 15px rgba(0,0,0,0.6), inset 0 2px 4px rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fde047;
  font-family: var(--font-mc);
  font-size: 1.4rem;
  font-weight: bold;
  animation: sealStamp 0.4s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes sealStamp {
  0% { transform: scale(3.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes envelopeFly {
  0% { transform: scale(0.7) translateY(40px); opacity: 0; }
  30% { transform: scale(1.05) translateY(0); opacity: 1; }
  75% { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.6) translateY(-80px); opacity: 0.9; }
}

.seal-status-text {
  margin-top: 2rem;
  text-align: center;
}

.seal-status-text h3 {
  font-size: 1.35rem;
  color: #fff;
  margin-bottom: 0.4rem;
}

.seal-status-text p {
  color: #94a3b8;
  font-size: 0.9rem;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  padding: 0.75rem 1.15rem;
  background: #1e293b;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  color: #f8fafc;
  font-size: 0.88rem;
  animation: slideIn 0.3s ease;
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.success {
  border-left-color: #22c55e;
}

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

@media (max-width: 860px) {
  header {
    padding: 1rem 1.25rem;
  }
  
  .stage-container {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 1.75rem;
  }
  
  .booth-curtain-frame {
    padding: 2rem 1.2rem;
  }
  
  .parchment-sheet {
    padding: 1.75rem 1.25rem;
  }
  
  .desk-quill-pen {
    display: none;
  }
}
