:root {
  --bg: #f4f1ec;
  --bg-soft: #efe9e2;
  --card: #ffffff;
  --ink: #2e2a28;
  --muted: #6d6661;
  --accent: #4bb3ff;
  --accent-dark: #2b2b2b;
  --border: #e2dbd4;
  --shadow: 0 14px 40px rgba(28, 21, 16, 0.15);
  --radius: 26px;
  --font-title: "Bebas Neue", "Impact", "Arial Black", sans-serif;
  --font-body: "Alegreya Sans", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(circle at top, #fff9f0 0%, var(--bg) 55%, #e9e2da 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(0px);
  z-index: -1;
}

body::before {
  width: 320px;
  height: 320px;
  background: rgba(255, 224, 165, 0.5);
  top: -80px;
  left: max(-60px, -12vw);
}

body::after {
  width: 260px;
  height: 260px;
  background: rgba(170, 199, 255, 0.35);
  bottom: -80px;
  right: max(-30px, -10vw);
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  border: none;
  background: transparent;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
}

.icon-btn.rounded {
  background: #e6e2dd;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(30, 27, 25, 0.08);
}

.icon-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.icon-gear {
  font-size: 22px;
  line-height: 1;
}

.icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  border: 2px solid var(--ink);
}

.title-block {
  text-align: center;
}

.title-block h1 {
  font-family: var(--font-title);
  letter-spacing: 0.1em;
  font-size: 48px;
  margin: 0;
}

.title-block p {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--muted);
}

.intro {
  text-align: center;
  margin: 18px 0 32px;
}

.intro h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.intro p {
  margin: 0;
  color: var(--muted);
}

.cards {
  display: grid;
  gap: 18px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: float-in 0.7s ease;
  user-select: none;
}

.card.primary {
  background: linear-gradient(135deg, #d9f1ff 0%, #7fc8ff 100%);
  border: none;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

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

.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.hint-card .hint-title {
  justify-content: space-between;
  gap: 12px;
}

.hint-card .hint-title h3 {
  flex: 1;
}

.hint-card .hint-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.card-title h3 {
  margin: 0;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.icon {
  font-size: 24px;
}

.mode-toggle {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.pill {
  flex: 1;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 16px;
  background: var(--bg-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pill.active,
.pill.selected {
  background: var(--accent-dark);
  color: #fff;
  border-color: var(--accent-dark);
}

.pill.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mode-description {
  margin: 0;
  color: var(--muted);
}

.player-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.player-controls input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 15px;
}

.ghost {
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid rgba(48, 43, 39, 0.18);
  background: linear-gradient(135deg, #fff8e9 0%, #f3eadf 100%);
  box-shadow: 0 8px 18px rgba(60, 50, 40, 0.12);
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(60, 50, 40, 0.16);
}

.ghost:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(60, 50, 40, 0.12);
}

.chips {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-soft);
  border-radius: 16px;
  padding: 10px 14px;
}

.chips-inline {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chips-inline .chip {
  justify-content: center;
  padding: 10px 16px;
  font-weight: 700;
}

.players-summary {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(40, 35, 30, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.players-summary:hover {
  transform: translateY(-1px);
}

.players-chevron {
  margin-left: auto;
  font-size: 28px;
  color: var(--muted);
}

.players-modal-card {
  max-width: 520px;
}

.categories-modal-card {
  max-width: 520px;
}

.players-modal-meta {
  text-align: center;
  color: var(--muted);
  margin-bottom: 18px;
}

.players-modal-meta p {
  margin: 4px 0;
}

.players-edit-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 18px;
}

.player-edit-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 10px 22px rgba(40, 35, 30, 0.12);
}

.player-edit-icon {
  font-size: 18px;
  opacity: 0.55;
}

.player-edit-row input {
  border: none;
  background: transparent;
  font-size: 17px;
  font-weight: 700;
}

.player-edit-row input:focus {
  outline: none;
}

.player-remove-btn {
  border: none;
  background: transparent;
  font-size: 26px;
  color: #e11d48;
  cursor: pointer;
}

.player-remove-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.players-add-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 10px 12px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(40, 35, 30, 0.12);
}

.players-add-row input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
}

.players-add-row input:focus {
  outline: none;
}

.players-add-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: none;
  background: var(--accent);
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
}

.categories-edit-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 18px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 6px;
}

.category-option {
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 18px rgba(40, 35, 30, 0.1);
  color: var(--ink);
}

.category-option.selected {
  border-color: var(--accent);
  background: #d9ecff;
  color: var(--ink);
}

.undercover-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 12px 0 18px;
}

.undercover-option {
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 18px rgba(40, 35, 30, 0.1);
  color: var(--ink);
}

.undercover-option.selected {
  border-color: var(--accent);
  background: #d9ecff;
  color: var(--ink);
}

.category-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.chip-controls {
  display: flex;
  gap: 6px;
}

.chip-controls button {
  border: none;
  background: #fff;
  border-radius: 12px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 16px;
}

.select.small {
  width: auto;
  min-width: 140px;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.undercover-controls {
  display: flex;
  gap: 12px;
}

.start-btn {
  width: 100%;
  padding: 18px;
  border-radius: 20px;
  border: none;
  font-size: 18px;
  font-weight: 700;
  background: var(--accent);
  color: #1d1d1d;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(50, 50, 50, 0.2);
  touch-action: manipulation;
}

.start-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.game-screen {
  position: fixed;
  inset: 0;
  background: #f6f1ea;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 40px;
  overflow-y: auto;
  z-index: 20;
}

.game-screen.open {
  display: flex;
}

.game-header {
  width: min(520px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 0 8px;
}

.game-header h2 {
  font-family: var(--font-title);
  letter-spacing: 0.08em;
  margin: 0;
  width: 100%;
  text-align: center;
}

.game-header .icon-btn {
  position: absolute;
  right: 0;
}

.game-subtitle {
  width: min(520px, 100%);
  margin: 10px 0 28px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  font-size: 18px;
}

.deal-card,
.started-card {
  width: min(520px, 92vw);
  background: linear-gradient(135deg, #dff1ff 0%, #bfe4ff 100%);
  border-radius: 28px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.started-card {
  background: #ffffff;
  border: 1px solid var(--border);
  font-size: 18px;
}

.deal-card h3 {
  margin: 0 0 12px;
  font-size: 30px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.deal-instruction {
  margin: 0 0 20px;
  color: #4a4340;
  font-size: 18px;
}

.deal-reveal {
  border: 2px dashed rgba(30, 27, 25, 0.35);
  border-radius: 18px;
  padding: 26px 20px;
  min-height: 110px;
  font-size: 24px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 10px;
  align-items: center;
  justify-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  white-space: pre-line;
}

.deal-reveal .hint-line {
  font-style: italic;
  font-weight: 400;
}

.deal-reveal.revealed {
  border-style: solid;
  background: #fff;
}

.deal-reveal .hold-icon {
  font-size: 36px;
}

.deal-reveal .hold-text {
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.deal-card.attention {
  animation: ring 1.2s ease-in-out infinite;
}

.next-btn.attention {
  animation: ring 1.2s ease-in-out infinite;
}

@keyframes ring {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(1deg); }
  20% { transform: rotate(-1deg); }
  30% { transform: rotate(1.2deg); }
  40% { transform: rotate(-1.2deg); }
  50% { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

.next-btn {
  margin-top: 24px;
  width: fit-content;
  min-width: 220px;
  background: #2b2b2b;
  color: #fff;
}

.next-btn[hidden] {
  display: none !important;
}

.reveal-btn {
  margin-top: 24px;
  width: fit-content;
  min-width: 240px;
}

.reveal-panel {
  width: min(520px, 88vw);
  margin: 16px 0 22px;
  background: #ffffff;
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  text-align: center;
  font-size: 18px;
  user-select: none;
}

.starting-player {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #8fd0ff;
  font-weight: 800;
}

#startedView .start-btn {
  width: fit-content;
  min-width: 220px;
  margin-top: 16px;
}

.start-icon {
  font-size: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 12, 10, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #1d1c1a;
  color: #f1ede7;
  border-radius: 24px;
  padding: 24px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.online-share-card {
  background: #ffffff;
  color: var(--ink);
}

.online-share-card .share-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 0 16px;
}

.online-share-card .share-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.qr-row {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
}

.qr-img {
  width: 140px;
  height: 140px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  object-fit: contain;
}

#settingsModal .modal-card {
  background: #f6f2ed;
  color: var(--ink);
}

#settingsModal .modal-card .icon-btn {
  color: var(--ink);
}

.modal-card .icon-btn {
  color: var(--ink);
}

#howToModal .icon-btn.rounded {
  background: transparent;
  box-shadow: none;
}

#howToModal .icon-btn.rounded {
  color: #f1ede7;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header .icon-btn {
  width: 44px;
  height: 44px;
}

.steps {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 14px;
}

.footnote {
  margin-top: 20px;
  font-size: 14px;
  color: #bdb6ae;
}

.settings-group,
.settings-footer {
  background: #f7f3ee;
  color: var(--ink);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 6px 0;
  color: inherit;
}

.settings-row.link {
  cursor: pointer;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle-ui {
  width: 42px;
  height: 24px;
  background: #cfc8c1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.toggle input:checked + .toggle-ui {
  background: linear-gradient(180deg, #4bb3ff, #2f83ea);
  box-shadow: 0 6px 14px rgba(47, 131, 234, 0.35);
}

.footer-text {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 720px) {
  .title-block h1 {
    font-size: 36px;
  }

  .mode-toggle {
    flex-direction: column;
  }

  .card {
    padding: 18px;
  }
}
