/* DrawJAL, desktop-only. Flat neutral surfaces, accent used sparsely. */

:root {
  --bg: #f6f9fb;
  --surface: #ffffff;
  --ink: #12222f;
  --muted: #5b7183;
  --border: #e2e9ef;
  --accent: #0369a1;
  --accent-strong: #075985;
  --accent-tint: #e8f4fb;
  --danger: #b42332;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-width: 1120px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-tint);
}

h1,
h2,
p {
  margin: 0;
}

button {
  font-family: inherit;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 32px;
}

/* Header */

.header {
  height: 76px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
}

.brand-sub {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--muted);
  white-space: nowrap;
}

.stats {
  display: flex;
  gap: 12px;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  white-space: nowrap;
}

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

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

/* Main grid */

.main {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 96px;
  align-items: start;
}

.main > * {
  min-width: 0;
}

/* Stage card */

.stage {
  position: sticky;
  top: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
}

.stage-title {
  font-size: 39px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stage-caption {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.slots {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slot {
  position: relative;
  height: 56px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.slot-wait {
  height: 56px;
  line-height: 56px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  will-change: transform;
  transition: transform 1250ms cubic-bezier(0.16, 0.84, 0.28, 1);
}

.reel-cell {
  height: 56px;
  line-height: 56px;
  padding: 0 20px;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot.locked {
  border-color: var(--accent);
  background: var(--surface);
}

.slot.locked .reel-cell:last-child {
  animation: slot-pop 220ms ease;
  transform-origin: left center;
}

@keyframes slot-pop {
  from {
    transform: scale(1.06);
  }
  to {
    transform: scale(1);
  }
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  border-radius: 12px;
  transition: transform 120ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-primary {
  background: var(--accent);
  color: var(--surface);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-primary:disabled {
  background: var(--border);
  color: #8aa0b1;
  cursor: default;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
}

.btn-block {
  width: 100%;
  height: 52px;
  font-size: 16px;
}

.btn-small {
  height: 44px;
  border-radius: 10px;
  padding: 0 20px;
  font-size: 15px;
}

.stage-draw {
  margin-top: 24px;
}

.stage-hint {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

/* Done state */

.done {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.done-badge {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-title {
  margin-top: 24px;
  font-size: 25px;
  font-weight: 700;
}

.done-caption {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.done-actions {
  margin-top: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Results column */

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-title {
  font-size: 20px;
  font-weight: 700;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 120ms ease;
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-ghost:disabled {
  opacity: 0.45;
  cursor: default;
}

.ghost-accent {
  color: var(--accent);
}

.ghost-accent:hover:not(:disabled) {
  background: var(--accent-tint);
}

.ghost-muted {
  color: var(--muted);
}

.ghost-muted:hover:not(:disabled) {
  background: var(--bg);
  color: var(--ink);
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  margin: 16px 0 24px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 400ms ease;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.group-card.enter {
  animation: card-in 350ms ease-out;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.group-meta {
  width: 128px;
  flex: none;
}

.group-name {
  font-size: 16px;
  font-weight: 700;
}

.group-size {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.group-members {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  padding: 64px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-text {
  margin-top: 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}

.empty-caption {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

/* Modal */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 34, 47, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: 560px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(18, 34, 47, 0.14);
  padding: 32px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 25px;
  font-weight: 700;
}

.modal-close {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-caption {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.modal-textarea {
  display: block;
  margin-top: 16px;
  width: 100%;
  height: 320px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--ink);
  resize: vertical;
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-count {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.modal-error {
  color: var(--danger);
}

.modal-foot {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast */

.toast {
  position: fixed;
  right: 32px;
  bottom: 32px;
  z-index: 60;
  background: var(--ink);
  color: var(--surface);
  font-size: 15px;
  font-weight: 500;
  border-radius: 12px;
  padding: 12px 20px;
  animation: toast-in 200ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Confetti canvas */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* Reduced motion */

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reel {
    transition: none;
  }

  .progress-fill {
    transition: none;
  }

  .btn,
  .btn-ghost {
    transition: none;
  }

  .btn:active:not(:disabled),
  .btn-ghost:active:not(:disabled) {
    transform: none;
  }

  .slot.locked .reel-cell:last-child {
    animation: fade-in 200ms ease;
  }

  .group-card.enter {
    animation: fade-in 200ms ease;
  }

  .toast {
    animation: fade-in 200ms ease;
  }
}
