* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f0ece3;
  padding: 16px;
  padding-top: env(safe-area-inset-top, 16px);
  padding-bottom: env(safe-area-inset-bottom, 16px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  touch-action: manipulation;
}

/* Language selector */
.lang-selector {
  display: flex;
  gap: 6px;
  margin: 12px 0;
  flex-shrink: 0;
}

.lang-btn {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1.5px solid #ccc;
  background: transparent;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn.active {
  background: #555;
  color: #fff;
  border-color: #555;
}

.lang-btn:active {
  transform: scale(0.95);
}

h1 {
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.card-container {
  position: relative;
  width: min(360px, calc(100vw - 40px));
  flex: 1 1 auto;
  max-height: 500px;
  min-height: 280px;
}

.card-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: #fff;
}

.card-bg:nth-child(1) {
  transform: rotate(3.5deg) translateY(8px);
  opacity: 0.3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.card-bg:nth-child(2) {
  transform: rotate(-1.8deg) translateY(4px);
  opacity: 0.55;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.card {
  --accent: #bbb;
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background: linear-gradient(165deg, #ffffff 0%, #fdfcfa 100%);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 12px 40px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px 32px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
  border-radius: 24px 24px 0 0;
}

.card:active {
  transform: scale(0.97);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 6px 20px rgba(0, 0, 0, 0.06);
}

.card.exit-left {
  transform: translateX(-120%) rotate(-12deg);
  opacity: 0;
}

.card.enter-right {
  transform: translateX(120%) rotate(12deg);
  opacity: 0;
}

.card.exit-right {
  transform: translateX(120%) rotate(12deg);
  opacity: 0;
}

.card.enter-left {
  transform: translateX(-120%) rotate(-12deg);
  opacity: 0;
}

.category {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 28px;
  flex-shrink: 0;
}

.question-wrapper {
  position: relative;
  padding: 16px 20px;
}

.question-wrapper::before {
  content: "\00ab";
  position: absolute;
  top: -8px;
  left: -4px;
  font-size: 2.8rem;
  font-weight: 300;
  color: var(--accent);
  opacity: 0.2;
  line-height: 1;
  font-style: italic;
  pointer-events: none;
}

.question-wrapper::after {
  content: "\00bb";
  position: absolute;
  bottom: -14px;
  right: -4px;
  font-size: 2.8rem;
  font-weight: 300;
  color: var(--accent);
  opacity: 0.2;
  line-height: 1;
  font-style: italic;
  pointer-events: none;
}

.question {
  font-size: 1.2rem;
  line-height: 1.7;
  color: #2c2c2c;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.counter {
  margin-top: 28px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #c4beb4;
  flex-shrink: 0;
  letter-spacing: 0.06em;
}

.hint {
  margin-top: 14px;
  font-size: 0.8rem;
  color: #bbb;
  flex-shrink: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 2em;
  flex-shrink: 0;
  max-width: min(380px, calc(100vw - 32px));
}

.filter-btn {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 100px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
}

.filter-btn.off {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.toggle-all-btn {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 100px;
  border: 1.5px solid #ccc;
  background: transparent;
  color: #888;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.toggle-all-btn:active {
  border-color: #999;
  color: #555;
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.mode-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #999;
  transition: color 0.25s;
}

.mode-label.active {
  color: #555;
}

.mode-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #d4c5a9;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.25s;
  flex-shrink: 0;
}

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

.mode-switch.advanced {
  background: #8b6fb0;
}

.mode-switch.advanced::after {
  transform: translateX(20px);
}

.empty-msg {
  font-size: 1.1rem;
  color: #999;
  display: none;
}

/* Small phones (SE, mini) */
@media (max-height: 600px) {
  .lang-selector { margin-bottom: 6px; }
  .lang-btn { font-size: 0.65rem; padding: 4px 10px; }
  h1 { font-size: 1rem; margin-bottom: 8px; }
  .filters { gap: 6px; margin-bottom: 10px; }
  .filter-btn { font-size: 0.65rem; padding: 5px 10px; }
  .card { padding: 24px 20px 20px; }
  .category { margin-bottom: 16px; }
  .question { font-size: 1.05rem; line-height: 1.5; }
  .question-wrapper::before { font-size: 2rem; top: -10px; }
  .question-wrapper::after { font-size: 2rem; bottom: -16px; }
  .counter { padding-top: 16px; }
  .hint { margin-top: 10px; }
}

/* Dark mode toggle button */
.dark-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s;
  padding: 0;
  line-height: 1;
}

.dark-toggle:active {
  background: rgba(0, 0, 0, 0.12);
}

.dark-toggle-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dark mode */
body.dark {
  background: #1a1a2e;
}

body.dark h1 {
  color: #aaa;
}

body.dark .card-bg {
  background: #2a2a40;
}

body.dark .card {
  background: linear-gradient(165deg, #2a2a40 0%, #252538 100%);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.3);
}

body.dark .card:active {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 6px 20px rgba(0, 0, 0, 0.2);
}

body.dark .card-bg:nth-child(1) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark .card-bg:nth-child(2) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark .question {
  color: #e8e8e8;
}

body.dark .counter {
  color: #666;
}

body.dark .hint {
  color: #555;
}

body.dark .empty-msg {
  color: #666;
}

body.dark .mode-label {
  color: #666;
}

body.dark .mode-label.active {
  color: #ccc;
}

body.dark .mode-switch {
  background: #444;
}

body.dark .mode-switch.advanced {
  background: #7b5fa0;
}

body.dark .toggle-all-btn {
  border-color: #555;
  color: #888;
}

body.dark .toggle-all-btn:active {
  border-color: #777;
  color: #bbb;
}

body.dark .lang-btn {
  border-color: #555;
  color: #888;
}

body.dark .lang-btn.active {
  background: #ccc;
  color: #1a1a2e;
  border-color: #ccc;
}

body.dark .dark-toggle {
  background: rgba(255, 255, 255, 0.08);
}

body.dark .dark-toggle:active {
  background: rgba(255, 255, 255, 0.15);
}

body.dark .cat-decouverte { background: #3a2a50; color: #c4a0f0; }
body.dark .cat-leger      { background: #4a2a1a; color: #f0a878; }
body.dark .cat-reves      { background: #1a3048; color: #78b8e8; }
body.dark .cat-perso      { background: #1a3828; color: #78d0a0; }
body.dark .cat-valeurs    { background: #3a2e10; color: #e8c870; }
body.dark .cat-intimite   { background: #3a1a18; color: #e88880; }

/* Category colors */
.cat-decouverte { background: #e8dff0; color: #6b3fa0; }
.cat-leger      { background: #fce4d6; color: #c0592b; }
.cat-reves      { background: #d6eaf8; color: #2471a3; }
.cat-perso      { background: #d5f5e3; color: #1e8449; }
.cat-valeurs    { background: #fdebd0; color: #b9770e; }
.cat-intimite   { background: #fadbd8; color: #a93226; }
