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

:root {
  --color-bg: #f0f6fa;
  --color-card-back: #00b0f0;
  --color-card-back-dark: #0090c8;
  --color-text: #1a2b3c;
  --color-text-light: #5a6b7c;
  --card-width: min(280px, 70vw);
  --card-height: calc(var(--card-width) * 1.41);
  --card-radius: 16px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Header */
.header {
  text-align: center;
  padding: 24px 20px 8px;
}

.title {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.title-ai {
  color: var(--color-card-back);
  font-size: 1.6rem;
}

.title-rest {
  color: var(--color-text);
}

.subtitle {
  color: var(--color-text-light);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 8px 20px 16px;
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.site-footer a {
  color: var(--color-card-back);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
}

/* Deck */
.deck {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    4px 4px 0 rgba(0, 80, 140, 0.25),
    8px 8px 0 rgba(0, 80, 140, 0.15),
    12px 12px 0 rgba(0, 80, 140, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.deck-back {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--card-radius);
}

.deck-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 12px 24px;
  border-radius: 12px;
}

.deck:hover {
  transform: translateY(-4px);
  box-shadow:
    4px 4px 0 rgba(0, 80, 140, 0.25),
    8px 8px 0 rgba(0, 80, 140, 0.15),
    12px 12px 0 rgba(0, 80, 140, 0.08),
    0 28px 70px rgba(0, 0, 0, 0.2);
}

.deck:active {
  transform: translateY(0) scale(0.98);
}

.deck-count {
  font-size: 3rem;
  font-weight: 800;
  color: white;
  line-height: 1;
}

.deck-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  margin-top: 2px;
}

.deck-hint {
  display: none;
}

.deck.empty {
  opacity: 0.4;
  cursor: default;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.deck.empty:hover {
  transform: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.deck.empty .deck-hint { display: none; }
.deck.empty .deck-info { display: none; }

.deck.shuffling {
  animation: shuffle 0.5s ease;
}

@keyframes shuffle {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-8px) rotate(-2deg); }
  30% { transform: translateX(8px) rotate(2deg); }
  45% { transform: translateX(-6px) rotate(-1deg); }
  60% { transform: translateX(6px) rotate(1deg); }
  75% { transform: translateX(-3px) rotate(0); }
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay.for-panel {
  z-index: 150;
}

/* Card modal */
.card-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card-modal.visible {
  pointer-events: auto;
  opacity: 1;
}

.card-modal-img {
  width: var(--card-width);
  height: auto;
  border-radius: var(--card-radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
  animation: cardEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardEnter {
  0% {
    transform: scale(0.5) translateY(60px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Controls */
.controls {
  display: flex;
  gap: 8px;
  padding: 12px 20px 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-draw {
  background: var(--color-card-back);
  color: white;
}

.btn-draw:hover {
  background: var(--color-card-back-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: var(--color-text);
  border: 2px solid #e0e6ec;
}

.btn-secondary:hover {
  border-color: var(--color-card-back);
  color: var(--color-card-back);
}

.btn-apply {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

/* Category panel */
.category-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-height: 80vh;
  overflow-y: auto;
}

.category-panel.open {
  transform: translateY(0);
}

.category-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.category-panel-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.category-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  padding: 4px 8px;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.category-item:hover {
  background: #f5f7fa;
}

.category-item input[type="checkbox"] { display: none; }

.category-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #d0d6dc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.category-item.active .category-check {
  background: var(--color-card-back);
  border-color: var(--color-card-back);
}

.category-item.active .category-check::after {
  content: '\2713';
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-name {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.category-count {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* History bar */
.history-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 20px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.history-bar.visible {
  display: flex;
}

.history-label {
  font-size: 0.75rem;
  color: var(--color-text-light);
  font-weight: 600;
  white-space: nowrap;
}

.history-cards {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
}

.history-thumb {
  width: 36px;
  height: 51px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}

.history-thumb:hover {
  transform: scale(1.1);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Category colors */
.cat-vakmanschap { background: #0099d6; }
.cat-tijd-vrijheid { background: #0099d6; }
.cat-vertrouwen { background: #2eab6f; }
.cat-mens { background: #0099d6; }
.cat-creativiteit { background: #2eab6f; }
.cat-macht-geld { background: #e8a317; }
.cat-werk-waarde { background: #e87a17; }
.cat-waarheid { background: #2eab6f; }
.cat-relaties { background: #7b61d4; }
.cat-toekomst { background: #e87a17; }

/* Responsive */
@media (min-width: 600px) {
  :root {
    --card-width: 320px;
  }
  .header { padding: 32px 20px 12px; }
  .title { font-size: 1.8rem; }
  .title-ai { font-size: 2rem; }
  .controls { padding: 16px 20px 32px; }
}

@media (min-width: 900px) {
  :root {
    --card-width: 340px;
  }
}
