:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --ink: #15211d;
  --muted: #6a766f;
  --border: #d9e2df;
  --green: #147d64;
  --green-dark: #0e5e4b;
  --yellow: #f3c846;
  --danger: #bd3f32;
  --shadow: 0 18px 48px rgba(27, 44, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 18px;
}

.topbar h1,
.topbar p,
.stage h2,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p,
.stage-head p {
  margin-top: 6px;
  color: var(--muted);
}

.top-actions,
.draw-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 16px;
  padding: 0 20px 20px;
  height: calc(100vh - 109px);
  min-height: 620px;
}

.panel,
.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  overflow: auto;
}

.panel section {
  display: grid;
  gap: 10px;
}

.panel h2,
.stage h2 {
  font-size: 18px;
  line-height: 1.2;
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
  border-radius: 8px;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.number-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 190px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12);
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

.primary-button {
  min-width: 132px;
  background: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: var(--ink);
  color: white;
}

.ghost-button {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  background: var(--yellow);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.check-list,
.fixed-list,
.history-list {
  display: grid;
  gap: 8px;
}

.check-item,
.fixed-item,
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
}

.check-item {
  justify-content: flex-start;
}

.check-item input {
  width: 18px;
  height: 18px;
}

.fixed-row {
  display: grid;
  grid-template-columns: 58px 1fr 40px;
  gap: 8px;
}

.fixed-item button {
  min-height: 28px;
  padding: 0 8px;
  background: #f0d7d3;
  color: var(--danger);
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary span {
  display: grid;
  place-items: center;
  min-height: 58px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 22px;
  font-weight: 900;
}

.seat-grid {
  flex: 1;
  display: grid;
  gap: 10px;
  min-height: 480px;
}

.seat {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 78px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.seat::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(20, 125, 100, 0.1), transparent 48%);
  opacity: 0;
  pointer-events: none;
}

.seat.filled {
  border-color: rgba(20, 125, 100, 0.38);
}

.seat.fixed {
  border-color: var(--yellow);
  background: #fff9de;
}

.seat.empty {
  color: var(--muted);
  background: #f9fafb;
}

.seat.spinning::before {
  opacity: 1;
  animation: sweep 0.7s ease-in-out infinite;
}

.seat.pending {
  color: var(--muted);
  border-color: #cfd9d6;
  background: #f7f9f8;
}

.seat.revealed {
  animation: reveal-pop 0.34s ease-out both;
}

.seat.final-hold {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(243, 200, 70, 0.2), 0 14px 32px rgba(21, 33, 29, 0.14);
}

.seat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.seat-name {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-align: center;
  font-size: clamp(17px, 1.7vw, 28px);
  font-weight: 900;
  line-height: 1.16;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.history-item {
  display: grid;
  align-items: start;
  justify-content: stretch;
}

.history-item strong {
  font-size: 14px;
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
}

.suspense-overlay {
  position: absolute;
  inset: 72px 18px 18px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(245, 247, 250, 0.72);
  backdrop-filter: blur(3px);
  z-index: 5;
}

.suspense-overlay[hidden] {
  display: none;
}

.suspense-card {
  display: grid;
  gap: 8px;
  min-width: min(320px, 86%);
  padding: 22px;
  border: 1px solid rgba(20, 125, 100, 0.24);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 52px rgba(21, 33, 29, 0.18);
  text-align: center;
}

.suspense-mode {
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
}

.suspense-card strong {
  color: var(--ink);
  font-size: clamp(48px, 8vw, 86px);
  line-height: 0.95;
}

.suspense-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

@keyframes sweep {
  0% {
    transform: translateX(-30%);
  }
  100% {
    transform: translateX(30%);
  }
}

@keyframes reveal-pop {
  0% {
    transform: scale(0.94);
    opacity: 0.35;
  }
  70% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 280px 1fr;
    height: auto;
  }

  .results {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .stage-head {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .results {
    display: flex;
  }

  .seat-grid {
    min-height: 360px;
    gap: 6px;
  }

  .seat {
    min-width: 0;
    min-height: 58px;
    padding: 7px;
  }

  .seat-label {
    font-size: 11px;
  }

  .seat-name {
    font-size: clamp(12px, 3.8vw, 18px);
  }
}
