* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-gradient-start: #0f0c29;
  --bg-gradient-mid: #302b63;
  --bg-gradient-end: #24243e;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-selected: #6366f1;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --input-bg: rgba(255, 255, 255, 0.1);
  --input-border: rgba(255, 255, 255, 0.2);
  --error-color: #ef4444;
  --success-color: #22c55e;
  --warning-color: #f59e0b;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  min-height: 100vh;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start) 0%,
    var(--bg-gradient-mid) 50%,
    var(--bg-gradient-end) 100%
  );
  color: var(--text-primary);
  padding: 2rem 1rem;
  overflow-x: hidden;
}

/* Page Layout */
.page-wrapper {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Ad Sidebar */
.ad-sidebar {
  flex-shrink: 0;
  width: 160px;
  position: sticky;
  top: 2rem;
  height: fit-content;
  align-self: flex-start;
}

.ad-placeholder {
  width: 160px;
  height: 600px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ad-label {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  text-align: center;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ad-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-align: center;
}

.ad-icon {
  font-size: 2.5rem;
  opacity: 0.5;
}

.ad-size {
  font-size: 0.75rem;
  opacity: 0.5;
  font-family: monospace;
}

/* Main Content */
.main-content {
  flex: 1;
  min-width: 0;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

/* Hide ad sidebar on smaller screens */
@media (max-width: 1024px) {
  .ad-sidebar {
    display: none;
  }

  .page-wrapper {
    justify-content: center;
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 3rem;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(90deg, #f472b6, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Room Info Bar */
.room-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-wrap: wrap;
}

.room-link-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.room-link-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.room-link-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: monospace;
  min-width: 150px;
}

.room-link-input:focus {
  outline: none;
  border-color: var(--card-selected);
}

.copy-link-btn {
  padding: 0.5rem 0.75rem;
  background: var(--card-selected);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.copy-link-btn:hover {
  transform: scale(1.05);
  background: #5855eb;
}

.room-timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  font-family: monospace;
  font-size: 1.125rem;
  font-weight: 600;
}

.timer-icon {
  font-size: 1rem;
}

/* Task Form Section */
.task-section {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border-radius: 1.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.room-info-text {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1rem;
}

.room-info-text strong {
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 1rem 1.25rem;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--card-selected);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

textarea.form-input {
  min-height: 100px;
  resize: vertical;
}

/* Members Section */
.members-section {
  margin-bottom: 2rem;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.member-card.voted {
  border-color: var(--success-color);
  background: rgba(34, 197, 94, 0.1);
}

.member-card.disconnected {
  opacity: 0.5;
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.member-card.disconnected .member-avatar {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.member-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
}

.member-name {
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.member-status {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.vote-hidden {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--success-color);
  border-radius: 50%;
  color: white;
  font-size: 0.75rem;
}

.vote-pending {
  color: var(--text-secondary);
  font-size: 1.25rem;
  animation: pulse 1.5s infinite;
}

.vote-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--card-selected);
}

.vote-offline {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.7;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* Cards Section */
.cards-section {
  margin-bottom: 2rem;
  transition: opacity 0.3s ease;
}

.section-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.section-title span {
  color: var(--error-color);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .cards-grid {
    display: grid;
    grid-gap: 8px;
    grid-template-rows: 150px;
    grid-auto-flow: column;
    overflow-x: scroll;
    padding: 18px 0;
  }
}

/* Poker Card */
.poker-card {
  position: relative;
  aspect-ratio: 3/4;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--card-bg);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid transparent;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 10px 20px rgba(0, 0, 0, 0.15);
}

.poker-card:hover .card-inner {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.2),
    0 20px 40px rgba(0, 0, 0, 0.25);
}

.poker-card.selected .card-inner {
  border-color: var(--card-selected);
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  transform: translateY(-8px) scale(1.05);
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.3),
    0 12px 24px rgba(99, 102, 241, 0.3),
    0 20px 40px rgba(99, 102, 241, 0.2);
}

.card-number {
  font-size: 2rem;
  font-weight: 700;
  color: #1e1b4b;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.card-emoji {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.poker-card.selected .card-number {
  color: var(--card-selected);
}

/* Selected indicator */
.selected-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  background: var(--card-selected);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.poker-card.selected .selected-indicator {
  opacity: 1;
  transform: scale(1);
}

.selected-indicator svg {
  width: 16px;
  height: 16px;
  color: white;
}

/* Corner decorations */
.card-corner {
  position: absolute;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6366f1;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.card-corner.top-left {
  top: 8px;
  left: 10px;
}

.card-corner.bottom-right {
  bottom: 8px;
  right: 10px;
  transform: rotate(180deg);
}

.card-corner-emoji {
  font-size: 0.875rem;
}

/* Selection Display */
.selection-display {
  text-align: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.selection-display.has-selection {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
}

.selection-placeholder {
  color: var(--text-secondary);
  font-size: 1rem;
}

.selection-value {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selection-emoji {
  font-size: 3rem;
  animation: bounce 0.5s ease;
}

.selection-text {
  text-align: left;
}

.selection-points {
  font-size: 2rem;
  font-weight: 700;
  color: var(--card-selected);
}

.selection-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

@keyframes bounce {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}

/* Results Section */
.results-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 2px solid var(--card-selected);
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.average-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.average-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.average-value {
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(90deg, #f472b6, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.votes-breakdown {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.vote-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
}

.vote-item-emoji {
  font-size: 1.25rem;
}

.vote-item-value {
  font-weight: 700;
  color: var(--text-primary);
}

.vote-item-count {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Submit Section & Buttons */
.submit-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 3rem;
  font-size: 1.125rem;
  font-weight: 600;
  font-family: inherit;
  color: white;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.submit-btn svg {
  width: 20px;
  height: 20px;
}

/* Admin Controls */
.admin-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.reveal-btn,
.reset-btn,
.end-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.reveal-btn {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.reveal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(34, 197, 94, 0.5);
}

.reset-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5);
}

.end-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.end-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

/* Validation Error */
.validation-error {
  color: var(--error-color);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.validation-error.show {
  display: flex;
}

.validation-error svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Success Toast */
.toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  transform: translateX(120%);
  background: var(--success-color);
  color: white;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast svg {
  width: 24px;
  height: 24px;
}

/* Error Toast */
.error-toast {
  background: var(--error-color);
  top: 6rem;
}

.error-toast.show {
  transform: translateX(0);
  opacity: 1;
}

/* Decorative elements */
.bg-decoration {
  position: fixed;
  pointer-events: none;
  opacity: 0.03;
  font-size: 20rem;
  z-index: -1;
}

.bg-decoration.top-right {
  top: -5rem;
  right: -5rem;
}

.bg-decoration.bottom-left {
  bottom: -5rem;
  left: -5rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .room-info-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .room-link-section {
    flex-wrap: wrap;
  }

  .room-link-label {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .members-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }

  .member-card {
    padding: 0.75rem;
  }

  .member-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .admin-controls {
    flex-direction: column;
    width: 100%;
  }

  .reveal-btn,
  .reset-btn,
  .end-btn {
    width: 100%;
    justify-content: center;
  }

  .results-section {
    padding: 1.5rem;
  }

  .average-value {
    font-size: 3rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 1rem 0.5rem;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .task-section,
  .selection-display {
    padding: 1rem;
  }

  .submit-btn {
    width: 100%;
    justify-content: center;
    padding: 1rem 1.5rem;
  }
}
