* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #000;
  --bg-card: #111;
  --accent: #e94560;
  --accent-dim: #c23152;
  --text: #eee;
  --text-sec: #999;
  --text-muted: #555;
  --border: #222;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Screens ──────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

.container {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ─── Menu Layout ──────────────────────────── */
.menu-layout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 24px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.menu-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  flex: 1;
  justify-content: center;
}

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

.setting-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.setting-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.btn-arrow {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.btn-arrow:active {
  opacity: 0.5;
}

.setting-value {
  min-width: 120px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

/* Tappable set value */
.setting-value-tap {
  min-width: 120px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
}

.setting-value-tap:active {
  border-color: var(--accent);
}

/* ─── Menu Bottom ──────────────────────────── */
.menu-bottom {
  width: 100%;
  padding-top: 24px;
  padding-bottom: 20px;
}

.btn-start {
  display: block;
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s;
}

.btn-start:active {
  background: var(--accent-dim);
  transform: scale(0.98);
}

.menu-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-menu-action {
  flex: 1;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-sec);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-menu-action:active {
  border-color: var(--accent);
  color: var(--text);
}

/* Language toggle */
.btn-lang {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sec);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  z-index: 50;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition: all 0.15s;
}

.btn-lang:active {
  border-color: var(--accent);
  color: var(--text);
}

/* ─── Set Picker Screen ───────────────────── */
.set-picker-layout {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 0 24px;
}

.set-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 30px;
}

.set-pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.set-pick-item.active {
  border-color: var(--accent);
}

.set-pick-item:active {
  background: #1a1a1a;
}

.set-pick-name {
  font-weight: 600;
  font-size: 1rem;
}

.set-pick-meta {
  font-size: 0.75rem;
  color: var(--text-sec);
}

/* ─── Sets List (management page) ──────────── */
.sets-list-full {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.set-item {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  gap: 10px;
}

.set-item-info {
  flex: 1;
  min-width: 0;
}

.set-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.set-item-meta {
  font-size: 0.75rem;
  color: var(--text-sec);
  margin-top: 1px;
}

.set-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-sec);
  font-size: 0.75rem;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-icon:active {
  background: var(--border);
}

.btn-icon.edit {
  color: var(--accent);
  border-color: var(--accent);
}

/* ─── Buttons (shared) ─────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary:active {
  background: var(--accent-dim);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-large {
  padding: 20px;
  font-size: 1.15rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 30px;
}

/* ─── Header row ───────────────────────────── */
.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-top: 24px;
}

.header-row h2 {
  font-size: 1.2rem;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
}

/* ─── Form ─────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-sec);
  margin-bottom: 6px;
}

.input, .textarea {
  width: 100%;
  padding: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus, .textarea:focus {
  border-color: var(--accent);
}

.textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.5;
}

.editor-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-bottom: 30px;
}

/* ─── Card Screen ──────────────────────────── */
.card-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  padding: 24px;
}

.card-prompt, .card-reveal {
  width: 100%;
  max-width: 400px;
}

.player-number {
  font-size: 1.1rem;
  color: var(--text-sec);
  margin-bottom: 40px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-instruction {
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 0.95rem;
}

.card-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px 24px;
  margin-bottom: 30px;
}

.card-role {
  font-size: 1rem;
  color: var(--text-sec);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-word {
  font-size: 1.8rem;
  font-weight: 700;
}

.card-content.spy {
  border: 2px solid var(--accent);
  background: linear-gradient(135deg, rgba(233,69,96,0.08), var(--bg-card));
}

.card-content.spy .card-word {
  color: var(--accent);
}

/* ─── Timer Screen ─────────────────────────── */
.timer-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  padding: 24px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.timer-display {
  font-size: 5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 40px;
  letter-spacing: 0.05em;
}

.timer-display.warning {
  color: #ffa502;
}

.timer-display.critical {
  color: var(--accent);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.timer-buttons {
  display: flex;
  gap: 10px;
  width: 100%;
}

.timer-buttons .btn {
  flex: 1;
}

/* ─── Results Screen ───────────────────────── */
.results-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  text-align: center;
  padding: 24px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.results-title {
  font-size: 1.5rem;
  margin-bottom: 30px;
}

.results-section {
  margin-bottom: 30px;
  width: 100%;
}

.results-spy-card {
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 8px;
}

.results-spy-label {
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.results-spy-name {
  font-size: 1.25rem;
  font-weight: 700;
}

.results-word-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 40px;
  width: 100%;
}

.results-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.results-word {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
}

.results-screen .menu-buttons {
  width: 100%;
}

/* ─── Modal ────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #111;
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.rules-text {
  color: var(--text-sec);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.rules-text p {
  margin-bottom: 12px;
}

.rules-text ol {
  padding-left: 20px;
}

.rules-text li {
  margin-bottom: 8px;
}

/* ─── Toast ────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: var(--text);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.9rem;
  z-index: 200;
  border: 1px solid var(--border);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ─── Utility ──────────────────────────────── */
.hidden {
  display: none !important;
}
