/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; font-size: 16px; }

body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  color: #1A1A1A;
  background: #E8E4D8;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

/* ── Shared ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 40px;
  background: #1A1A1A;
  color: #FFF;
  border-radius: 100px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
}
.btn-primary:hover  { opacity: 0.85; }
.btn-primary:active { transform: scale(0.97); opacity: 0.78; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 40px;
  background: transparent;
  color: #1A1A1A;
  border: 2px solid #1A1A1A;
  border-radius: 100px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.1px;
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
}
.btn-secondary:hover  { opacity: 0.7; }
.btn-secondary:active { transform: scale(0.97); opacity: 0.6; }

.landing-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.hidden { display: none !important; }

/* ── Landing page ───────────────────────────────────────────────────────────── */
.page-landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #F0EDE8;
}

.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 32px;
}

.landing-logo {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: #1A1A1A;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.landing-logo svg { width: 40px; height: 40px; }

.landing-title {
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 700;
  letter-spacing: -2.5px;
  line-height: 1;
  color: #1A1A1A;
  margin-bottom: 12px;
}

.landing-subtitle {
  font-size: 16px;
  color: #86868B;
  margin-bottom: 52px;
}

/* ── Game page layout ───────────────────────────────────────────────────────── */
.page-game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: #E8E4D8;
  overflow: hidden;
  padding: 16px;
  padding-top:    max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* ── HUD ────────────────────────────────────────────────────────────────────── */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  flex-shrink: 0;
}

.player-tag {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-tag.right { justify-content: flex-end; }

.tag-dot {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
}

.tag-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1A1A1A;
}

.tag-walls {
  font-size: 15px;
  font-weight: 700;
  color: #1A1A1A;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
}

.hud-sep {
  font-size: 18px;
  color: rgba(26,26,26,0.3);
  font-weight: 400;
  user-select: none;
}

/* ── Board area ─────────────────────────────────────────────────────────────── */
.board-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  background: #E8E4D8;
}

#board-canvas {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.game-footer {
  flex-shrink: 0;
  height: 64px;
  border: 1px solid #222;
  overflow: hidden;
}

.footer-panel {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
}

.footer-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-title {
  font-size: 16px;
  font-weight: 700;
  color: #1A1A1A;
  letter-spacing: -0.2px;
}

.footer-sub {
  font-size: 13px;
  color: rgba(26,26,26,0.55);
  font-variant-numeric: tabular-nums;
}

.wall-buttons {
  display: flex;
  align-self: stretch;
  margin-right: -16px;
}

.btn-wall {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 100%;
  background: transparent;
  border: none;
  border-left: 1px solid #222;
  font-size: 20px;
  color: #1A1A1A;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s, color 0.1s;
}

.btn-wall:disabled { opacity: 0.32; cursor: not-allowed; }

.btn-wall.active {
  background: rgba(0,0,0,0.15);
  color: #1A1A1A;
}

.btn-wall.is-dragging {
  background: rgba(0,0,0,0.2);
}

.btn-wall:active:not(:disabled):not(.is-dragging) { background: rgba(0,0,0,0.1); }

/* ── Overlay ────────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(232,228,216,0.75);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  z-index: 200;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 44px 52px;
  background: #FDFCFA;
  border: 1px solid rgba(26,26,26,0.08);
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.06);
  max-width: 380px;
  width: 100%;
  animation: cardAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardAppear {
  from { transform: scale(0.86) translateY(16px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);    opacity: 1; }
}

.overlay-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 20px;
  display: block;
}

.overlay-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.7px;
  color: #1A1A1A;
  margin-bottom: 8px;
}

.overlay-message {
  font-size: 15px;
  color: #86868B;
  line-height: 1.55;
}

.invite-box {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 20px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 10px;
}

.invite-url {
  flex: 1;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #86868B;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.btn-copy {
  flex-shrink: 0;
  padding: 5px 13px;
  background: #1A1A1A;
  color: #FFF;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: opacity 0.12s;
}
.btn-copy:hover { opacity: 0.82; }

.waiting-dots {
  display: none;
  gap: 6px;
  margin-top: 24px;
}

.waiting-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #AEAEB2;
  animation: dotBounce 1.3s ease-in-out infinite;
}
.waiting-dots .dot:nth-child(2) { animation-delay: 0.18s; }
.waiting-dots .dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-9px); opacity: 1;   }
}

.overlay-action {
  display: none;
  margin-top: 28px;
  width: 100%;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .overlay-card { padding: 32px 28px; }
  .overlay-title { font-size: 22px; }
}

@media (min-width: 641px) {
  .page-game {
    justify-content: center;
    align-items: center;
    gap: 32px;
    padding: 32px;
  }

  .hud {
    width: 380px;
    padding: 0;
  }

  .board-area {
    width: 380px;
    height: 380px;
    flex: none;
  }

  .game-footer {
    width: 380px;
  }
}
