:root {
  --bg: #0f1728;
  --panel: #162238;
  --accent: #f4b942;
  --accent-dark: #c98616;
  --text: #e8eef8;
  --muted: #94a3b8;
  --success: #4ade80;
  --danger: #fb7185;
  --slot: #334155;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #1e3a5f 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 20%, #123047 0%, transparent 50%), var(--bg);
  color: var(--text);
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.top-bar {
  text-align: center;
  margin-bottom: 1rem;
}

.screen {
  display: none;
  animation: fade 0.35s ease;
}

.screen.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cover-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0 1.25rem;
}

/* width + height auto preserve intrinsic aspect (matches PDF page proportions) */
.cover-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(560px, 100%);
  max-height: min(92vh, 1200px);
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  border: 3px solid rgba(244, 185, 66, 0.35);
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.btn-hard-title {
  background: linear-gradient(180deg, #2a4a7a, #1e3a5f);
  color: var(--text);
  border: 2px solid var(--accent);
  box-shadow: 0 6px 20px rgba(244, 185, 66, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.btn-hard-title:hover {
  background: linear-gradient(180deg, #355a8f, #243d66);
  box-shadow: 0 8px 24px rgba(244, 185, 66, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.hint {
  text-align: center;
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.5;
  font-size: 0.92rem;
}

.hint-start p {
  margin: 0 0 0.55rem;
}

.hint-start p:last-child {
  margin-bottom: 0;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.35rem;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #ffd478, var(--accent));
  color: #1a1204;
  box-shadow: 0 8px 22px rgba(244, 185, 66, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 26px rgba(244, 185, 66, 0.45);
}

.btn-secondary {
  background: #243654;
  color: var(--text);
  border: 1px solid rgba(244, 185, 66, 0.35);
}

.btn-secondary:hover {
  background: #2c4066;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(244, 185, 66, 0.45);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 1rem auto;
  max-width: 360px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: var(--panel);
  color: var(--text);
}

.player-names {
  display: grid;
  gap: 0.5rem;
  max-width: 420px;
  margin: 0.75rem auto 1rem;
}

.player-names label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.player-names input {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #0b1220;
  color: var(--text);
}

.setup-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.play-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.turn-banner {
  flex: 1 1 260px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.18), rgba(30, 58, 95, 0.65));
  border: 1px solid rgba(244, 185, 66, 0.35);
  font-size: 1.05rem;
}

.turn-banner strong {
  color: var(--accent);
}

.play-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.privacy-panel {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.25);
  margin-bottom: 1rem;
}

.privacy-msg {
  margin: 0;
  line-height: 1.45;
}

.hand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.timeline-section,
.hand-section {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(15, 23, 40, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.timeline-section h3,
.hand-section h3 {
  margin: 0 0 0.25rem;
}

.subtle {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.75rem;
}

.timeline-scroll {
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.timeline {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-height: 148px;
}

.slot {
  flex: 0 0 auto;
  align-self: stretch;
  width: 72px;
  min-width: 56px;
  min-height: 148px;
  border-radius: 10px;
  border: 2px dashed rgba(244, 185, 66, 0.55);
  background: rgba(51, 65, 85, 0.35);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.2s ease;
}

.slot:hover:not(:disabled) {
  background: rgba(244, 185, 66, 0.12);
  border-style: solid;
}

.slot:disabled {
  opacity: 0.4;
  cursor: default;
}

.slot.slot-hover {
  border-style: solid;
  background: rgba(244, 185, 66, 0.22);
  box-shadow: 0 0 0 2px rgba(244, 185, 66, 0.35);
}

.card-frame {
  flex: 0 0 auto;
  width: 100px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(15, 23, 40, 0.85);
  background: #0b1220;
  transition: transform 0.22s ease;
}

.card-frame.card-slide-preview {
  transform: translateX(12px);
}

.card-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.hand-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.hand .card-tile {
  width: min(200px, 42vw);
  max-width: 220px;
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  border: 3px solid transparent;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, border-color 0.12s ease;
  background: #0b1220;
  -webkit-user-drag: element;
  user-select: none;
  touch-action: none;
}

.hand .card-tile:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hand .card-tile:active {
  cursor: grabbing;
}

.hand .card-tile:hover:not(.locked) {
  transform: translateY(-3px);
}

.hand .card-tile.selected {
  border-color: var(--accent);
}

.hand .card-tile.locked {
  cursor: not-allowed;
  opacity: 0.55;
}

.hand .card-tile img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.placement-hint {
  min-height: 1.25rem;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 2rem));
  padding: 0.85rem 1.1rem;
  border-radius: 999px;
  background: rgba(15, 23, 40, 0.92);
  border: 1px solid rgba(244, 185, 66, 0.35);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 50;
  text-align: center;
}

.wrong-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(6px);
}

.wrong-modal[hidden] {
  display: none;
}

.wrong-modal__panel {
  max-width: 420px;
  width: 100%;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(244, 185, 66, 0.45);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.wrong-modal__title {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 1.35rem;
}

.wrong-modal__text {
  margin: 0 0 1rem;
  line-height: 1.5;
  color: var(--text);
  text-align: left;
  font-size: 0.98rem;
}

.wrong-modal__card {
  margin: 0 auto 1rem;
  max-width: 220px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(244, 185, 66, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  background: #0b1220;
}

.wrong-modal__card img {
  display: block;
  width: 100%;
  height: auto;
}

.wrong-modal__sub {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: left;
}

.wrong-modal__panel .btn {
  width: 100%;
}

.toast.show {
  opacity: 1;
}

#screen-setup h2,
#screen-over h2 {
  text-align: center;
}

#screen-over {
  text-align: center;
}

#winner-sub {
  color: var(--muted);
}

@media (max-width: 640px) {
  .timeline {
    min-height: 128px;
  }

  .card-frame {
    width: 84px;
  }

  .hand .card-tile {
    width: min(160px, 46vw);
    max-width: 180px;
  }

  .slot {
    width: 56px;
    min-height: 128px;
  }
}
