Pages
Booking

Seat Picker

A movie ticket booking page for React: pick a city, movie and showtime, choose seats by tier, and see live pricing with a confirmation state.

seat-picker.preview

Book tickets

  • PVR · Viviana Mall

    Eastern Express Hwy

  • INOX · Korum Mall

    Pokhran Road

Choose seats

Up to 6 seats

Classic · ₹180
A
A
B
B
C
C
D
D
Prime · ₹320
E
E
F
F
G
G
H
H
Recliner · ₹520
I
I
J
J

Tap a seat to select it

Available104Selected0Sold36

Install

Copies the source into components/blocks/seat-picker.tsx and installs what it needs.

$ pnpm dlx shadcn@latest add https://makeui.xyz/r/seat-picker.json

Usage

app/page.tsx
import { SeatPicker } from "@/components/blocks/seat-picker"

export default function Page() {
  return <SeatPicker defaultCity="Mumbai" onBook={(booking) => console.log(booking)} />
}

Source

Prefer to copy by hand? It's one file. Requires motion and the shadcn cn helper.

components/blocks/seat-picker.tsx
"use client"

import { type CSSProperties, memo, useCallback, useEffect,useRef, useMemo, useState } from "react"

import {
  AnimatePresence,
  motion,
  useReducedMotion,
  useSpring,
  useTransform,
} from "motion/react"
import { Check, ChevronDown, MapPin, X } from "lucide-react"
import { cn } from "@/lib/utils"

/* ------------------------------------------------------------------ */
/* Types                                                               */
/* ------------------------------------------------------------------ */
export interface Movie {
  id: string
  title: string
  language: string
  /** Indian censor certificate: U, UA 7+, UA 13+, UA 16+, A */
  certificate: string
  runtime: string
  genre: string
  /** Flat poster colour (any CSS colour). */
  poster: string
  /** Theater id -> [time, format][] for this movie. Theaters not listed don't screen it. */
  shows: Record<string, [time: string, format: string][]>
}

export interface Theater {
  id: string
  name: string
  area: string
  city: string
  /** Price multiplier on the base tier prices (single screens < 1, premium > 1). */
  rate: number
}

export interface Booking {
  id: string
  movie: Movie
  theater: Theater
  time: string
  format: string
  seats: string[]
  total: number
}

export interface SeatPickerProps {
  movies?: Movie[]
  theaters?: Theater[]
  /** City shown first. Falls back to the first city in `theaters`. */
  defaultCity?: string
  onBook?: (booking: Booking) => void
  className?: string
}

/* ------------------------------------------------------------------ */
/* Sample data (swap for your API). Titles are made up.                */
/* ------------------------------------------------------------------ */
const THEATERS: Theater[] = [
  { id: "viviana", name: "PVR · Viviana Mall", area: "Eastern Express Hwy", city: "Thane", rate: 1 },
  { id: "korum", name: "INOX · Korum Mall", area: "Pokhran Road", city: "Thane", rate: 0.9 },
  { id: "icon", name: "PVR ICON · Phoenix Palladium", area: "Lower Parel", city: "Mumbai", rate: 1.6 },
  { id: "insignia", name: "INOX Insignia · Nariman Point", area: "Nariman Point", city: "Mumbai", rate: 1.8 },
  { id: "cine-andheri", name: "Cinépolis · Andheri West", area: "Andheri West", city: "Mumbai", rate: 1 },
  { id: "maratha", name: "Maratha Mandir", area: "Mumbai Central", city: "Mumbai", rate: 0.6 },
  { id: "pmc", name: "PVR · Phoenix Marketcity", area: "Viman Nagar", city: "Pune", rate: 1.1 },
  { id: "amanora", name: "INOX · Amanora Mall", area: "Hadapsar", city: "Pune", rate: 1 },
  { id: "ambience", name: "PVR Director's Cut · Ambience", area: "Vasant Kunj", city: "Delhi NCR", rate: 1.7 },
  { id: "delite", name: "Delite Cinema", area: "Asaf Ali Road", city: "Delhi NCR", rate: 0.55 },
  { id: "orion", name: "PVR · Orion Mall", area: "Rajajinagar", city: "Bengaluru", rate: 1.1 },
  { id: "garuda", name: "INOX · Garuda Mall", area: "Magrath Road", city: "Bengaluru", rate: 0.9 },
]

const MOVIES: Movie[] = [
  {
    id: "monsoon-mail",
    title: "Monsoon Mail",
    language: "Hindi",
    certificate: "UA 13+",
    runtime: "2h 21m",
    genre: "Thriller",
    poster: "#0f766e",
    shows: {
      viviana: [["10:15 AM", "2D"], ["1:40 PM", "2D"], ["7:05 PM", "2D"], ["10:30 PM", "2D"]],
      korum: [["11:00 AM", "2D"], ["4:10 PM", "2D"], ["9:20 PM", "2D"]],
      icon: [["12:00 PM", "IMAX 2D"], ["6:30 PM", "IMAX 2D"], ["10:00 PM", "Dolby Atmos"]],
      maratha: [["12:30 PM", "2D"], ["6:00 PM", "2D"]],
      "cine-andheri": [["2:15 PM", "2D"], ["8:45 PM", "4DX"]],
      pmc: [["1:00 PM", "2D"], ["7:30 PM", "Dolby Atmos"]],
      ambience: [["3:00 PM", "2D"], ["9:15 PM", "2D"]],
      orion: [["11:45 AM", "2D"], ["5:50 PM", "2D"]],
    },
  },
  {
    id: "mumbai-local",
    title: "Mumbai Local",
    language: "Marathi",
    certificate: "U",
    runtime: "2h 04m",
    genre: "Comedy · Drama",
    poster: "#b45309",
    shows: {
      viviana: [["11:30 AM", "2D"], ["5:00 PM", "2D"]],
      korum: [["1:15 PM", "2D"], ["6:45 PM", "2D"], ["9:45 PM", "2D"]],
      maratha: [["10:00 AM", "2D"], ["2:00 PM", "2D"], ["6:30 PM", "2D"], ["9:30 PM", "2D"]],
      insignia: [["7:00 PM", "2D"]],
      pmc: [["12:15 PM", "2D"], ["8:00 PM", "2D"]],
      amanora: [["3:30 PM", "2D"], ["9:00 PM", "2D"]],
    },
  },
  {
    id: "veera-nagar",
    title: "Veera Nagar",
    language: "Telugu",
    certificate: "UA 16+",
    runtime: "2h 52m",
    genre: "Action",
    poster: "#4338ca",
    shows: {
      viviana: [["9:30 PM", "2D"]],
      icon: [["3:30 PM", "IMAX 2D"], ["9:00 PM", "IMAX 2D"]],
      "cine-andheri": [["12:45 PM", "2D"], ["6:15 PM", "4DX"]],
      ambience: [["1:30 PM", "Dolby Atmos"], ["7:45 PM", "Dolby Atmos"]],
      delite: [["11:00 AM", "2D"], ["3:00 PM", "2D"], ["7:00 PM", "2D"]],
      orion: [["2:00 PM", "2D"], ["8:30 PM", "2D"], ["11:30 PM", "2D"]],
      garuda: [["10:30 AM", "2D"], ["4:45 PM", "2D"], ["10:15 PM", "2D"]],
    },
  },
]

/* ------------------------------------------------------------------ */
/* Seat layout: front row A -> back row J, aisles after seat 3 and 11  */
/* ------------------------------------------------------------------ */
const TIERS = [
  { id: "classic", name: "Classic", base: 180, rows: ["A", "B", "C", "D"], color: "#64748b" },
  { id: "prime", name: "Prime", base: 320, rows: ["E", "F", "G", "H"], color: "#4f46e5" },
  { id: "recliner", name: "Recliner", base: 520, rows: ["I", "J"], color: "#d97706" },
] as const
type Tier = (typeof TIERS)[number]

/* Soft line colour set INLINE so it can never fall back to black.
   Derived from the current text colour, so it adapts to light/dark. */
const LINE = "color-mix(in srgb, currentColor 14%, transparent)"
const lineStyle: CSSProperties = { borderColor: LINE }

/* frosted-glass surface for the active movie tab */
const GLASS =
  "bg-white/80 shadow-[inset_0_1px_0_rgb(255_255_255/0.8),0_2px_10px_-3px_rgb(0_0_0/0.15)] ring-1 ring-inset ring-black/[0.08] backdrop-blur-md dark:bg-white/10 dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.12),0_2px_10px_-3px_rgb(0_0_0/0.5)] dark:ring-white/10"

/* solid, high-contrast active showtime chip */
const SOLID_ACTIVE =
  "bg-foreground text-background shadow-[0_4px_12px_-4px_rgb(0_0_0/0.45)]"

const GROUPS = [3, 8, 3]
const COLS = GROUPS.reduce((a, b) => a + b, 0)
const MAX_SEATS = 6
const FEE = 30 // convenience fee per ticket, incl. GST

const inr = new Intl.NumberFormat("en-IN", {
  style: "currency",
  currency: "INR",
  maximumFractionDigits: 0,
})

const tierOf = (row: string): Tier => TIERS.find((t) => (t.rows as readonly string[]).includes(row))!
const priceOf = (t: Tier, rate: number) => Math.round((t.base * rate) / 10) * 10
const rowOf = (id: string) => id[0]
const numOf = (id: string) => Number(id.slice(1))

/** Stable pseudo-random "already booked" seats per show. */
function isSold(seed: string) {
  let h = 2166136261
  for (let i = 0; i < seed.length; i++) {
    h ^= seed.charCodeAt(i)
    h = Math.imul(h, 16777619)
  }
  return (h >>> 0) % 100 < 28
}

const ROW_ORDER: string[] = TIERS.flatMap((t) => [...t.rows])
const bySeat = (a: string, b: string) =>
  ROW_ORDER.indexOf(rowOf(a)) - ROW_ORDER.indexOf(rowOf(b)) || numOf(a) - numOf(b)

/* ------------------------------------------------------------------ */
/* Small pieces                                                        */
/* ------------------------------------------------------------------ */
function Amount({ value, className }: { value: number; className?: string }) {
  const reduce = useReducedMotion()
  const mv = useSpring(value, { stiffness: 220, damping: 30 })
  useEffect(() => {
    if (reduce) mv.jump(value)
    else mv.set(value)
  }, [value, reduce, mv])
  const text = useTransform(mv, (v) => inr.format(Math.round(v)))
  return <motion.span className={cn("tabular-nums", className)}>{text}</motion.span>
}

function Poster({ movie, className }: { movie: Movie; className?: string }) {
  const initials = movie.title
    .split(" ")
    .map((w) => w[0])
    .join("")
    .slice(0, 2)
  return (
    <span
      aria-hidden
      className={cn(
        "grid shrink-0 place-items-center rounded-lg text-xs font-semibold text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.25),0_2px_6px_-2px_rgb(0_0_0/0.35)]",
        className,
      )}
      style={{ background: movie.poster }}
    >
      {initials}
    </span>
  )
}

/* Plain button + CSS transitions (no per-seat motion component), and memoised so
   hovering one seat doesn't re-render the other ~140. */
const Seat = memo(function Seat({
  id,
  tier,
  sold,
  on,
  locked,
  onToggle,
  onHover,
}: {
  id: string
  tier: Tier
  sold: boolean
  on: boolean
  locked: boolean
  onToggle: (id: string) => void
  onHover: (id: string | null) => void
}) {
  const dim = !sold && !on && locked
  return (
    <button
      type="button"
      disabled={sold || dim}
      aria-pressed={on}
      aria-label={`Row ${rowOf(id)}, seat ${numOf(id)}, ${tier.name}${sold ? ", sold" : ""}`}
      onClick={() => onToggle(id)}
      onMouseEnter={() => onHover(id)}
      onMouseLeave={() => onHover(null)}
      onFocus={() => onHover(id)}
      onBlur={() => onHover(null)}
      style={{ "--t": tier.color } as CSSProperties}
      className={cn(
        "relative grid size-6 place-items-center rounded-md ring-1 ring-inset outline-none",
        "transition-[transform,background-color,box-shadow] duration-150 ease-out will-change-transform",
        "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/70",
        "enabled:hover:scale-110 enabled:active:scale-90",
        sold && "cursor-not-allowed bg-foreground/[0.06] ring-transparent",
        dim &&
          "cursor-not-allowed bg-[color-mix(in_srgb,var(--t)_6%,transparent)] ring-[color-mix(in_srgb,var(--t)_14%,transparent)]",
        on &&
          "bg-[var(--t)] text-white ring-[var(--t)] shadow-[0_4px_10px_-2px_color-mix(in_srgb,var(--t)_70%,transparent)]",
        !sold &&
          !on &&
          !dim &&
          "bg-[color-mix(in_srgb,var(--t)_12%,transparent)] ring-[color-mix(in_srgb,var(--t)_40%,transparent)] hover:bg-[color-mix(in_srgb,var(--t)_28%,transparent)] hover:ring-[var(--t)]",
      )}
    >
      {sold ? (
        <X aria-hidden strokeWidth={2.5} className="size-3 text-foreground/20" />
      ) : (
        <Check
          aria-hidden
          strokeWidth={3}
          className={cn(
            "size-3.5 transition-[opacity,transform] duration-150 ease-out",
            on ? "scale-100 opacity-100" : "scale-50 opacity-0",
          )}
        />
      )}
    </button>
  )
})

function CitySelect({
  value,
  options,
  onChange,
}: {
  value: string
  options: string[]
  onChange: (v: string) => void
}) {
  const [open, setOpen] = useState(false)
  const ref = useRef<HTMLDivElement>(null)

  useEffect(() => {
    if (!open) return
    const down = (e: PointerEvent) => {
      if (!ref.current?.contains(e.target as Node)) setOpen(false)
    }
    const key = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false)
    document.addEventListener("pointerdown", down)
    document.addEventListener("keydown", key)
    return () => {
      document.removeEventListener("pointerdown", down)
      document.removeEventListener("keydown", key)
    }
  }, [open])

  return (
    <div ref={ref} className="relative">
      <button
        type="button"
        aria-haspopup="listbox"
        aria-expanded={open}
        onClick={() => setOpen((o) => !o)}
        style={lineStyle}
        className="flex h-8 items-center gap-1.5 rounded-lg border bg-background pl-2.5 pr-2 text-sm text-foreground outline-none transition-colors hover:bg-foreground/[0.04] focus-visible:ring-2 focus-visible:ring-foreground/20"
      >
        <MapPin className="size-3.5 text-muted-foreground" aria-hidden />
        {value}
        <ChevronDown
          aria-hidden
          className={cn(
            "size-4 text-muted-foreground transition-transform duration-200",
            open && "rotate-180",
          )}
        />
      </button>

      <AnimatePresence>
        {open && (
          <motion.ul
            role="listbox"
            initial={{ opacity: 0, y: -4, scale: 0.97 }}
            animate={{ opacity: 1, y: 0, scale: 1 }}
            exit={{ opacity: 0, y: -4, scale: 0.97 }}
            transition={{ duration: 0.15, ease: "easeOut" }}
            style={lineStyle}
            className="absolute right-0 top-full z-20 mt-1.5 w-max min-w-full origin-top-right overflow-hidden rounded-xl border bg-card p-1 shadow-[0_12px_32px_-8px_rgb(0_0_0/0.35)]"
          >
            {options.map((o) => {
              const selected = o === value
              return (
                <li key={o} role="option" aria-selected={selected}>
                  <button
                    type="button"
                    onClick={() => {
                      onChange(o)
                      setOpen(false)
                    }}
                    className={cn(
                      "flex w-full items-center justify-between gap-6 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors focus-visible:bg-foreground/[0.07]",
                      selected
                        ? "bg-foreground/[0.07] font-medium text-foreground"
                        : "text-muted-foreground hover:bg-foreground/[0.05] hover:text-foreground",
                    )}
                  >
                    {o}
                    {selected && <Check aria-hidden className="size-3.5" strokeWidth={2.5} />}
                  </button>
                </li>
              )
            })}
          </motion.ul>
        )}
      </AnimatePresence>
    </div>
  )
}
/* ------------------------------------------------------------------ */
/* Main                                                                */
/* ------------------------------------------------------------------ */
export default function SeatPicker({
  movies = MOVIES,
  theaters = THEATERS,
  defaultCity,
  onBook,
  className,
}: SeatPickerProps) {
  const cities = useMemo(() => [...new Set(theaters.map((t) => t.city))], [theaters])
  const [movieId, setMovieId] = useState(movies[0]?.id)
  const [city, setCity] = useState(
    defaultCity && cities.includes(defaultCity) ? defaultCity : cities[0],
  )
  const [showKey, setShowKey] = useState<string | null>(null)
  const [seats, setSeats] = useState<string[]>([])
  const [hover, setHover] = useState<string | null>(null)
  const [booking, setBooking] = useState<Booking | null>(null)
  /** seats the user has booked this session, per show — they stay sold afterwards */
  const [booked, setBooked] = useState<Record<string, string[]>>({})

  const movie = movies.find((m) => m.id === movieId) ?? movies[0]

  const groups = useMemo(
    () =>
      theaters
        .filter((t) => t.city === city)
        .map((theater) => ({
          theater,
          shows: (movie.shows[theater.id] ?? []).map(([time, format]) => ({
            key: `${theater.id}|${time}`,
            time,
            format,
          })),
        }))
        .filter((g) => g.shows.length),
    [theaters, city, movie],
  )
  const flat = groups.flatMap((g) => g.shows.map((s) => ({ ...s, theater: g.theater })))
  const active = flat.find((s) => s.key === showKey) ?? flat[0] ?? null

  const reset = () => {
    setSeats([])
    setBooking(null)
    setHover(null)
  }
  const pickMovie = (id: string) => {
    setMovieId(id)
    setShowKey(null)
    reset()
  }
  const pickCity = (c: string) => {
    setCity(c)
    setShowKey(null)
    reset()
  }
  const pickShow = (key: string) => {
    if (key === active?.key) return
    setShowKey(key)
    reset()
  }
  const toggle = useCallback(
    (id: string) =>
      setSeats((s) =>
        s.includes(id) ? s.filter((x) => x !== id) : s.length < MAX_SEATS ? [...s, id] : s,
      ),
    [],
  )

  // which seats are already booked for this show, computed once per show
  const showId = active ? `${movie.id}|${active.key}` : null
  const totalSeats = ROW_ORDER.length * COLS
  const mine = showId ? booked[showId] : undefined
  const soldSet = useMemo(() => {
    const set = new Set<string>()
    if (!showId) return set
    for (const row of ROW_ORDER)
      for (let n = 1; n <= COLS; n++) if (isSold(`${showId}|${row}${n}`)) set.add(`${row}${n}`)
    mine?.forEach((id) => set.add(id))
    return set
  }, [showId, mine])

  const rate = active?.theater.rate ?? 1
  const sorted = [...seats].sort(bySeat)
  const tickets = sorted.reduce((sum, id) => sum + priceOf(tierOf(rowOf(id)), rate), 0)
  const fee = FEE * sorted.length
  const total = tickets + fee
  const locked = seats.length >= MAX_SEATS

  const book = () => {
    if (!active || !showId || !sorted.length) return
    const b: Booking = {
      id: Math.random().toString(36).slice(2, 8).toUpperCase(),
      movie,
      theater: active.theater,
      time: active.time,
      format: active.format,
      seats: sorted,
      total,
    }
    setBooked((prev) => ({ ...prev, [showId]: [...(prev[showId] ?? []), ...sorted] }))
    setSeats([])
    setBooking(b)
    onBook?.(b)
  }

  const hoverInfo = (() => {
    if (!hover || !active) return null
    const t = tierOf(rowOf(hover))
    const sold = soldSet.has(hover)
    return `Row ${rowOf(hover)}, seat ${numOf(hover)} · ${t.name} · ${
      sold ? "Sold" : inr.format(priceOf(t, rate))
    }`
  })()

  return (
    <div
      style={lineStyle}
      className={cn(
        "@container w-full max-w-4xl overflow-hidden rounded-3xl border bg-card text-foreground",
        "shadow-[0_1px_2px_rgb(0_0_0/0.04),0_16px_40px_-16px_rgb(0_0_0/0.14)]",
        className,
      )}
    >
      {/* movie + city */}
      <div style={lineStyle} className="flex flex-col gap-4 border-b p-4 @lg:p-5">
        <div className="flex items-center justify-between gap-3">
          <h3 className="text-base font-semibold tracking-tight">Book tickets</h3>
         <CitySelect value={city} options={cities} onChange={pickCity} />
        </div>

        <div className="flex gap-1 overflow-x-auto rounded-2xl bg-foreground/[0.04] p-1">
          {movies.map((m) => (
            <button
              key={m.id}
              type="button"
              aria-pressed={m.id === movie.id}
              onClick={() => pickMovie(m.id)}
              className={cn(
                "flex shrink-0 items-center gap-2.5 rounded-xl px-2.5 py-2 text-left outline-none transition-[background-color,box-shadow] duration-200 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-[color-mix(in_srgb,currentColor_30%,transparent)]",
                m.id === movie.id ? GLASS : "hover:bg-foreground/[0.05]",
              )}
            >
              <Poster movie={m} className="size-10" />
              <span className="min-w-0">
                <span className="block text-sm font-medium leading-tight">{m.title}</span>
                <span className="block text-xs text-muted-foreground">
                  {m.language} · {m.certificate} · {m.runtime}
                </span>
              </span>
            </button>
          ))}
        </div>
      </div>

      <div className="grid @3xl:grid-cols-[minmax(0,1fr)_300px]">
        {/* left: theaters + seats */}
        <div className="flex min-w-0 flex-col gap-5 p-4 @lg:p-5">
          {/* theaters & shows */}
          <section aria-label="Theaters and showtimes">
            {groups.length === 0 ? (
              <p
                style={lineStyle}
                className="rounded-xl border border-dashed px-4 py-6 text-center text-sm text-muted-foreground"
              >
                {movie.title} isn’t showing in {city} today. Try another city.
              </p>
            ) : (
              <ul className="flex flex-col">
                {groups.map(({ theater, shows }, i) => (
                  <li
                    key={theater.id}
                    style={lineStyle}
                    className={cn(
                      "flex flex-col gap-2 py-3 @lg:flex-row @lg:items-center @lg:justify-between @lg:gap-4",
                      i === 0 ? "pt-0" : "border-t",
                      i === groups.length - 1 && "pb-0",
                    )}
                  >
                    <div className="min-w-0">
                      <p className="truncate text-sm font-medium">{theater.name}</p>
                      <p className="truncate text-xs text-muted-foreground">{theater.area}</p>
                    </div>
                    <div className="flex flex-wrap gap-1.5 @lg:justify-end">
                      {shows.map((s) => {
                        const on = active?.key === s.key
                        return (
                          <button
                            key={s.key}
                            type="button"
                            aria-pressed={on}
                            onClick={() => pickShow(s.key)}
                            className={cn(
                              "rounded-lg px-2.5 py-1.5 text-xs outline-none transition-[background-color,box-shadow,color] duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/50",
                              on
                                ? SOLID_ACTIVE
                                : "bg-foreground/[0.04] hover:bg-foreground/[0.08]",
                            )}
                          >
                            <span className="font-medium tabular-nums">{s.time}</span>
                            <span className={cn("ml-1.5", on ? "text-background/70" : "text-muted-foreground")}>
                              {s.format}
                            </span>
                          </button>
                        )
                      })}
                    </div>
                  </li>
                ))}
              </ul>
            )}
          </section>

          {/* seat map */}
          {active && (
            <section aria-label="Choose seats" className="flex flex-col gap-4">
              <div className="flex items-baseline justify-between gap-3">
                <h4 className="text-sm font-semibold">Choose seats</h4>
                <p className="text-xs text-muted-foreground">Up to {MAX_SEATS} seats</p>
              </div>

              <div aria-hidden className="mx-auto w-[70%]">
                <div
                  style={{ borderColor: "color-mix(in srgb, currentColor 28%, transparent)" }}
                  className="h-3 rounded-t-[100%] border-t-[3px] shadow-[0_-8px_18px_-8px_rgb(0_0_0/0.18)]"
                />
                <div className="mx-auto -mt-px h-6 w-[92%] bg-gradient-to-b from-foreground/[0.06] to-transparent [clip-path:polygon(4%_0,96%_0,100%_100%,0_100%)]" />
                <p className="-mt-1 text-center text-[10px] uppercase tracking-[0.2em] text-muted-foreground">
                  Screen this way
                </p>
              </div>

              <motion.div
                key={active.key}
                className="overflow-x-auto pb-1"
                initial={{ opacity: 0 }}
                animate={{ opacity: 1 }}
                transition={{ duration: 0.25, ease: "easeOut" }}
              >
                <div className="mx-auto flex w-max flex-col gap-3 px-1">
                  {TIERS.map((tier) => (
                    <div key={tier.id} className="flex flex-col gap-1.5">
                      <div className="flex items-center gap-2 text-[10px] font-medium uppercase tracking-wider text-muted-foreground">
                        <span
                          className="size-1.5 rounded-full"
                          style={{ background: tier.color }}
                        />
                        {tier.name} · {inr.format(priceOf(tier, rate))}
                        <span className="h-px flex-1" style={{ background: LINE }} />
                      </div>
                      {tier.rows.map((row) => {
                        let n = 0
                        return (
                          <div key={row} className="flex items-center gap-4">
                            <span className="w-3 text-center text-[11px] text-muted-foreground">
                              {row}
                            </span>
                            {GROUPS.map((size, g) => (
                              <div key={g} className="flex gap-1.5">
                                {Array.from({ length: size }).map(() => {
                                  const id = `${row}${++n}`
                                  return (
                                    <Seat
                                      key={id}
                                      id={id}
                                      tier={tier}
                                      sold={soldSet.has(id)}
                                      on={seats.includes(id)}
                                      locked={locked}
                                      onToggle={toggle}
                                      onHover={setHover}
                                    />
                                  )
                                })}
                              </div>
                            ))}
                            <span className="w-3 text-center text-[11px] text-muted-foreground">
                              {row}
                            </span>
                          </div>
                        )
                      })}
                    </div>
                  ))}
                </div>
              </motion.div>

              <p aria-live="polite" className="h-4 text-center text-xs text-muted-foreground">
                {hoverInfo ?? (locked ? `Seat limit reached (${MAX_SEATS})` : "Tap a seat to select it")}
              </p>

              <div
                style={lineStyle}
                className="flex flex-wrap items-center gap-x-4 gap-y-1.5 border-t pt-3 text-xs text-muted-foreground"
              >
                <span className="flex items-center gap-1.5">
                  <span className="size-4 rounded bg-foreground/[0.08] ring-1 ring-inset ring-foreground/25" />
                  Available
                  <b className="font-medium tabular-nums text-foreground">{totalSeats - soldSet.size}</b>
                </span>
                <span className="flex items-center gap-1.5">
                  <span className="grid size-4 place-items-center rounded bg-foreground text-background">
                    <Check className="size-3" strokeWidth={3} />
                  </span>
                  Selected
                  <b className="font-medium tabular-nums text-foreground">{seats.length}</b>
                </span>
                <span className="flex items-center gap-1.5">
                  <span className="grid size-4 place-items-center rounded bg-foreground/[0.06]">
                    <X className="size-2.5 text-foreground/25" strokeWidth={2.5} />
                  </span>
                  Sold
                  <b className="font-medium tabular-nums text-foreground">{soldSet.size}</b>
                </span>
              </div>
            </section>
          )}
        </div>

        {/* right: summary */}
        <aside
          style={lineStyle}
          className="border-t p-4 @lg:p-5 @3xl:border-l @3xl:border-t-0"
        >
          <div className="flex flex-col gap-4 @3xl:sticky @3xl:top-4">
            <div className="flex items-center gap-3">
              <Poster movie={movie} className="size-12" />
              <div className="min-w-0">
                <p className="truncate text-sm font-semibold">{movie.title}</p>
                <p className="truncate text-xs text-muted-foreground">
                  {movie.language} · {movie.genre}
                </p>
              </div>
            </div>

            {active && (
              <div className="rounded-xl bg-foreground/[0.04] px-3 py-2.5 text-xs">
                <p className="text-sm font-medium">{active.theater.name}</p>
                <p className="mt-0.5 text-muted-foreground">
                  Today · <span className="tabular-nums">{active.time}</span> · {active.format}
                </p>
              </div>
            )}

            <AnimatePresence mode="wait" initial={false}>
              {booking ? (
                <motion.div
                  key="done"
                  className="flex flex-col items-center gap-3 py-4 text-center"
                  initial={{ opacity: 0, y: 8 }}
                  animate={{ opacity: 1, y: 0 }}
                  exit={{ opacity: 0 }}
                  transition={{ duration: 0.25 }}
                >
                  <span className="grid size-11 place-items-center rounded-full bg-foreground text-background shadow-[0_6px_16px_-4px_rgb(0_0_0/0.4)]">
                    <Check className="size-5" strokeWidth={3} />
                  </span>
                  <div>
                    <p className="text-sm font-semibold">Booking confirmed</p>
                    <p className="mt-0.5 text-xs text-muted-foreground">
                      ID {booking.id} · {booking.seats.join(", ")}
                    </p>
                  </div>
                  <p className="text-sm font-semibold">
                    <Amount value={booking.total} />
                  </p>
                  <button
                    type="button"
                    onClick={reset}
                    style={lineStyle}
                    className="h-9 rounded-lg border px-3 text-sm font-medium outline-none transition-colors hover:bg-foreground/[0.05] focus-visible:ring-2 focus-visible:ring-foreground/30"
                  >
                    Book another
                  </button>
                </motion.div>
              ) : (
                <motion.div
                  key="cart"
                  className="flex flex-col gap-4"
                  initial={{ opacity: 0 }}
                  animate={{ opacity: 1 }}
                  exit={{ opacity: 0 }}
                  transition={{ duration: 0.18 }}
                >
                  <div>
                    <div className="mb-2 flex items-baseline justify-between">
                      <h4 className="text-sm font-semibold">Your seats</h4>
                      <span className="text-xs tabular-nums text-muted-foreground">
                        {sorted.length} of {MAX_SEATS}
                      </span>
                    </div>
                    {sorted.length === 0 ? (
                      <p
                        style={lineStyle}
                        className="rounded-xl border border-dashed px-3 py-5 text-center text-xs text-muted-foreground"
                      >
                        No seats picked yet.
                      </p>
                    ) : (
                      <ul className="flex max-h-52 flex-col overflow-y-auto">
                        <AnimatePresence initial={false}>
                          {sorted.map((id) => {
                            const t = tierOf(rowOf(id))
                            return (
                              <motion.li
                                key={id}
                                initial={{ opacity: 0, height: 0 }}
                                animate={{ opacity: 1, height: "auto" }}
                                exit={{ opacity: 0, height: 0 }}
                                transition={{ duration: 0.22, ease: [0.22, 1, 0.36, 1] }}
                                className="flex items-center gap-2.5 overflow-hidden py-1.5"
                              >
                                <span
                                  className="size-2.5 shrink-0 rounded-full"
                                  style={{ background: t.color }}
                                />
                                <span className="min-w-0 flex-1">
                                  <span className="block text-sm font-medium leading-tight">
                                    Row {rowOf(id)}, seat {numOf(id)}
                                  </span>
                                  <span className="block text-xs text-muted-foreground">
                                    {t.name}
                                  </span>
                                </span>
                                <span className="text-sm tabular-nums">
                                  {inr.format(priceOf(t, rate))}
                                </span>
                                <button
                                  type="button"
                                  aria-label={`Remove ${id}`}
                                  onClick={() => toggle(id)}
                                  className="grid size-6 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-foreground/[0.07] hover:text-foreground focus-visible:ring-2 focus-visible:ring-foreground/30"
                                >
                                  <X className="size-3.5" />
                                </button>
                              </motion.li>
                            )
                          })}
                        </AnimatePresence>
                      </ul>
                    )}
                  </div>

                  <dl
                    style={lineStyle}
                    className="flex flex-col gap-1.5 border-t pt-3 text-sm"
                  >
                    <div className="flex justify-between text-muted-foreground">
                      <dt>Tickets</dt>
                      <dd><Amount value={tickets} /></dd>
                    </div>
                    <div className="flex justify-between text-muted-foreground">
                      <dt>Convenience fee</dt>
                      <dd><Amount value={fee} /></dd>
                    </div>
                    <div className="flex justify-between text-base font-semibold">
                      <dt>Total</dt>
                      <dd><Amount value={total} /></dd>
                    </div>
                  </dl>

                  <button
                    type="button"
                    disabled={!sorted.length || !active}
                    onClick={book}
                    className="h-11 w-full rounded-xl bg-foreground text-sm font-medium text-background shadow-[0_6px_16px_-6px_rgb(0_0_0/0.45)] outline-none transition-[opacity,transform] hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/60 enabled:active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none"
                  >
                    {sorted.length
                      ? `Pay ${inr.format(total)} · ${sorted.length} ${sorted.length === 1 ? "seat" : "seats"}`
                      : "Select seats"}
                  </button>
                  <p className="-mt-2 text-center text-xs text-muted-foreground">
                    {inr.format(FEE)} convenience fee per ticket, incl. GST
                  </p>
                </motion.div>
              )}
            </AnimatePresence>
          </div>
        </aside>
      </div>
    </div>
  )
}