:root {
  --bg: #0b0f14;
  --bg-soft: #121824;
  --card: #151b26;
  --panel: #101722;
  --panel-2: #1a2230;
  --ink: #eef4fb;
  --muted: #9aa7b7;
  --accent: #39d0c2;
  --accent-strong: #00c4ff;
  --border: #2a3342;
  --shadow: 0 16px 40px rgba(4, 8, 12, 0.5);
  --radius: 22px;
  --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, #1b2433 0%, #0b0f14 60%, #070a10 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

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

body::before {
  width: 380px;
  height: 220px;
  background: linear-gradient(135deg, rgba(57, 208, 194, 0.18), transparent 70%);
  top: 40px;
  left: max(-20px, -6vw);
}

body::after {
  width: 420px;
  height: 280px;
  background: linear-gradient(135deg, rgba(0, 196, 255, 0.16), transparent 70%);
  bottom: 40px;
  right: max(-40px, -8vw);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 22px 80px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wordmark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1c2a3a, #0f1824);
  border: 1px solid #243244;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-size: 20px;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  box-shadow: 0 10px 24px rgba(4, 8, 12, 0.4);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.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: #151c28;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(80, 96, 118, 0.35);
}

.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(--accent);
}

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

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

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

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

.lobby-head {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(18, 24, 36, 0.95), rgba(14, 19, 28, 0.7));
  border: 1px solid #1f2a3c;
  border-radius: 18px;
}

.lobby-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.06em;
}

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

.lobby-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.tile {
  background: linear-gradient(145deg, #151b26 0%, #101722 100%);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(5, 10, 16, 0.5);
  animation: float-in 0.7s ease;
  user-select: none;
}

.tile-action {
  background: linear-gradient(145deg, #14253b 0%, #0f1f31 100%);
  border-color: rgba(57, 208, 194, 0.35);
}

.tile-action .start-btn {
  width: fit-content;
  min-width: 180px;
  align-self: center;
}

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

.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, #1d2a3b 0%, #0f1f31 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 #2b3443;
  padding: 12px 16px;
  font-size: 16px;
  background: #121a27;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pill.active,
.pill.selected {
  background: #1b2a3a;
  color: #fff;
  border-color: rgba(57, 208, 194, 0.5);
  box-shadow: inset 0 0 0 1px rgba(57, 208, 194, 0.2);
}

.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: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(76, 98, 126, 0.4);
  background: #121a26;
  box-shadow: 0 10px 20px rgba(4, 8, 12, 0.35);
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: var(--ink);
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.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);
}

button:focus-visible,
.players-summary:focus-visible,
.pill:focus-visible,
.ghost:focus-visible,
.start-btn:focus-visible,
.reveal-btn:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.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: #121a26;
  border-radius: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(76, 98, 126, 0.35);
  color: var(--ink);
}

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

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

.credentials .chip {
  padding: 8px 12px;
  border-radius: 14px;
  background: #0f1622;
  border: 1px solid rgba(76, 98, 126, 0.45);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.credential-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(57, 208, 194, 0.35), rgba(0, 196, 255, 0.35));
  border: 1px solid rgba(57, 208, 194, 0.4);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #e9fbff;
  text-transform: uppercase;
}

.credential-name {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.players-summary {
  width: 100%;
  border: 1px solid rgba(76, 98, 126, 0.5);
  border-radius: 18px;
  padding: 14px;
  background: #0f1622;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(4, 8, 12, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: var(--ink);
}

.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: #0f1622;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 10px 22px rgba(4, 8, 12, 0.35);
}

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

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

.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 rgba(57, 208, 194, 0.6);
  border-radius: 20px;
  padding: 10px 12px;
  background: #0f1622;
  box-shadow: 0 10px 22px rgba(4, 8, 12, 0.35);
}

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

.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;
  color: #031016;
}

.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 rgba(76, 98, 126, 0.5);
  border-radius: 18px;
  padding: 14px 16px;
  background: #0f1622;
  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(4, 8, 12, 0.35);
  color: var(--ink);
}

.category-option.selected {
  border-color: rgba(57, 208, 194, 0.7);
  background: rgba(15, 34, 46, 0.9);
  color: var(--ink);
}

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

.shadow-option {
  border: 2px solid rgba(76, 98, 126, 0.5);
  border-radius: 18px;
  padding: 14px 16px;
  background: #0f1622;
  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(4, 8, 12, 0.35);
  color: var(--ink);
}

.shadow-option.selected {
  border-color: rgba(57, 208, 194, 0.7);
  background: rgba(15, 34, 46, 0.9);
  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;
}

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

.start-btn {
  width: 100%;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(57, 208, 194, 0.5);
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(135deg, #39d0c2, #00c4ff);
  color: #031016;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(4, 8, 12, 0.45);
  touch-action: manipulation;
  height: 44px;
  margin-top: 24px;
}

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

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

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

.game-screen .start-btn,
.game-screen .ghost {
  width: auto;
  min-width: 180px;
}

.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, #172234 0%, #0f1a28 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: #0f1622;
  border: 1px solid var(--border);
  font-size: 18px;
}

.briefing-card,
.turn-card,
.judgment-card,
.result-card,
.credential-card {
  width: min(560px, 94vw);
  background: #0f1622;
  border-radius: 24px;
  padding: 28px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.briefing-card h3,
.turn-card h3,
.judgment-card h3,
.result-card h3,
.credential-card h3 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0.04em;
}

#briefingList {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 10px;
  text-align: left;
  color: var(--muted);
}

.credential-reveal {
  margin-top: 16px;
  border: 1px dashed rgba(76, 98, 126, 0.6);
  border-radius: 18px;
  padding: 18px;
  min-height: 92px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  background: #0b111b;
}

.credential-actions {
  width: min(560px, 94vw);
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  min-height: 44px;
}

.credential-actions .ghost {
  min-width: 200px;
  border-color: rgba(57, 208, 194, 0.5);
}

.credential-actions .start-btn {
  min-width: 200px;
}


.turn-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.turn-option {
  border: 1px solid rgba(76, 98, 126, 0.5);
  background: #0f1622;
  color: var(--ink);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.turn-option.selected {
  border-color: rgba(57, 208, 194, 0.7);
  box-shadow: inset 0 0 0 1px rgba(57, 208, 194, 0.25);
}

.turn-hint,
.turn-progress {
  margin-top: 12px;
  color: var(--muted);
}

.result-card {
  display: grid;
  gap: 12px;
}

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

.deal-instruction {
  margin: 0 0 20px;
  color: var(--muted);
  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(9, 14, 22, 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: #0f1622;
}

.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 {
  width: fit-content;
  min-width: 220px;
  background: #101722;
  color: var(--ink);
}

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

.reveal-btn {
  margin-top: 24px;
  width: fit-content;
  min-width: 240px;
  border-color: rgba(57, 208, 194, 0.5);
}

.reveal-panel {
  width: min(520px, 88vw);
  margin: 16px 0 22px;
  background: #0f1622;
  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: rgba(57, 208, 194, 0.2);
  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(5, 8, 12, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #0f1622;
  color: #e9f0f8;
  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: #0f1622;
  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: #0f1622;
  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: var(--muted);
}

.settings-group,
.settings-footer {
  background: #101722;
  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: #243144;
  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, #39d0c2, #00c4ff);
  box-shadow: 0 6px 14px rgba(0, 196, 255, 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;
  }
}
