:root {
  --bg-1: #6a11cb;
  --bg-2: #2575fc;
  --card-bg: #ffffff;
  --accent: #ff6b6b;
  --accent-dark: #e8503f;
  --text: #2b2d42;
  --muted: #6c757d;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}

header {
  text-align: center;
  color: white;
  flex: 0 0 auto;
}

header h1 {
  margin: 0;
  font-size: 1.8rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 18px;
  min-height: 0;
}

.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 22px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.hint {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 1rem;
}

.word {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.word.pop {
  animation: pop 0.28s ease;
}

@keyframes pop {
  0% { transform: scale(0.85); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

.meta {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 4px;
}

.badge.easy { background: #d1f7dd; color: #1c7a3d; }
.badge.medium { background: #fff3cd; color: #8a6300; }
.badge.cat { background: #e5e9ff; color: #38408a; }

.draw-btn {
  align-self: center;
  width: min(58vw, 220px);
  height: min(58vw, 220px);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.3;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-dark), var(--accent) 70%);
  color: white;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(255,107,107,0.5), inset 0 -4px 0 rgba(0,0,0,0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  flex: 0 0 auto;
}

.draw-btn:hover { transform: scale(1.03); }
.draw-btn:active { transform: scale(0.95); }
.draw-btn:disabled {
  background: #b8b8b8;
  box-shadow: none;
  cursor: not-allowed;
}

.filters {
  background: rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 12px 16px;
  color: white;
  flex: 0 0 auto;
}

.filters[open] { padding-bottom: 16px; }

.filters-summary {
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
}

.filters-summary::-webkit-details-marker { display: none; }

.filters-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.filter-label {
  font-weight: 600;
  font-size: 0.95rem;
  cursor: default;
}

.categories-details summary { cursor: pointer; }
.categories-details summary::-webkit-details-marker { color: white; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.chip input { accent-color: var(--accent); cursor: pointer; }

.cat-actions {
  margin-top: 10px;
  display: flex;
  gap: 16px;
}

.link-btn {
  background: none;
  border: none;
  color: white;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

.link-btn:hover { opacity: 1; }

.stats {
  text-align: center;
  color: white;
  opacity: 0.85;
  font-size: 0.85rem;
  margin: 0;
}

footer {
  text-align: center;
  color: rgba(255,255,255,0.85);
  font-size: 0.8rem;
  flex: 0 0 auto;
}

@media (max-width: 380px) {
  header h1 { font-size: 1.5rem; }
  .word { font-size: 1.3rem; }
  .card { padding: 20px 16px; min-height: 120px; }
}

/* Short / landscape screens: shrink things so everything still fits without scrolling. */
@media (max-height: 700px) {
  .app { gap: 10px; padding: 12px 16px; }
  main { gap: 10px; }
  header h1 { font-size: 1.4rem; }
  .card { padding: 16px; min-height: 100px; }
  .word { font-size: 1.4rem; }
  .draw-btn { width: min(38vw, 150px); height: min(38vw, 150px); font-size: 1.1rem; }
  footer { display: none; }
}
