:root {
  --bg: #000000;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.5);
  --border: rgba(255, 255, 255, 0.08);
  --accent: #ffffff;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.brand-text b {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

/* Status pill */
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: background 0.2s ease;
}

.dot.on {
  background: #34c759;
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.5);
}

/* Main content */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Card */
.card {
  width: 100%;
  max-width: 480px;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

/* Auto-height card for index page */
.card.card-auto {
  min-height: auto;
}

.index-content {
  padding: 40px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pad {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pad:active {
  background: rgba(255, 255, 255, 0.03);
}

/* Tap animation for seeker */
[data-role="seeker"] .card {
  transition: transform 0.1s ease;
}

[data-role="seeker"] .card.tapped {
  transform: scale(0.98);
}

[data-role="seeker"] .card.holding {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.08);
}

[data-role="seeker"] .card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.15), transparent 70%);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

[data-role="seeker"] .card.tapped::after {
  opacity: 1;
}

/* Text content */
.center {
  text-align: center;
  padding: 32px 24px;
  max-width: 340px;
}

.h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin: 0 0 12px 0;
}

.p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.5;
}

.hint {
  margin-top: 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
}

/* Buttons */
.primaryBtn {
  border: none;
  background: var(--accent);
  color: var(--bg);
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  width: 100%;
  max-width: 300px;
}

.primaryBtn:hover {
  opacity: 0.9;
}

.primaryBtn:active {
  transform: scale(0.98);
}

.secondaryBtn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.secondaryBtn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Hidden utility */
.hidden { display: none !important; }

/* Flash effects for Beacon */
.flashStage {
  position: absolute;
  inset: 0;
  background: #000;
}

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  transition: opacity 50ms linear;
}

.flash.on { opacity: 1; }

.pageFlash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 50ms linear;
}

.pageFlash.on { opacity: 1; }

/* Share overlay - clear and prominent */
.share-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: rgba(0, 0, 0, 0.85);
  padding: 24px;
  pointer-events: auto; /* Always clickable */
}

.share-overlay.hidden {
  display: none;
  pointer-events: none;
}

.share-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.share-overlay-text {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
}

/* Waiting state (shared by seeker and beacon) */
.waiting-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 24px;
  text-align: center;
}

.waiting-state.hidden {
  display: none;
}

/* Role intro */
.role-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 280px;
}

.role-badge {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border-radius: 100px;
}

.role-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* How it works (index page) */
.how-it-works {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.how-step {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 10px;
  border-radius: 6px;
}

.how-arrow {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
}

/* Notice text */
.notice {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.5;
}

/* Role selection (index page) */
.roleCard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
  margin-top: 28px;
}

.roleBtn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 20px 18px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.roleBtn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}

.roleBtn:active {
  transform: scale(0.98);
}

.roleTitle {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 4px;
  color: var(--text);
}

.roleDesc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.roleIcon {
  font-size: 20px;
  margin-bottom: 10px;
}

/* Beacon-specific styles */
.beacon-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Corner actions removed for cleaner look */
.corner { display: none; }

/* Waiting indicator */
.waiting-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  opacity: 0.6;
}

.waiting-indicator.hidden {
  display: none;
}

.waiting-dots {
  display: flex;
  gap: 4px;
}

.waiting-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: waitingPulse 1.4s ease-in-out infinite;
}

.waiting-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.waiting-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes waitingPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.waiting-text {
  font-size: 12px;
  color: var(--muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}

.modal-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-card .primaryBtn {
  max-width: 100%;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(40, 40, 40, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 40px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.hidden {
  display: none;
}

.toast.toast-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.toast-hide {
  transform: translateX(-50%) translateY(-20px);
  opacity: 0;
}

.toast-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.toast-text {
  font-size: 13px;
  color: var(--muted);
}

/* Responsive */
@media (max-height: 600px) {
  .card { min-height: 300px; }
  .h1 { font-size: 24px; }
  .center { padding: 24px 20px; }
  .waiting-indicator { margin-top: 16px; }
}
