:root {
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --accent: #d63384;
  --success: #198754;
  --text: #1a1a2e;
  --muted: #6c757d;
}

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

.hidden { display: none !important; }

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem;
  overflow-x: hidden;
}

/* ===== Selection Screen ===== */
#selection-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.selection-box {
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.selection-box h1 {
  font-size: 2.2rem;
  letter-spacing: 1px;
  margin-bottom: 0.2rem;
}

.selection-box h2 {
  font-size: 1.5rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.subtitle {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.mode-btn {
  background: var(--card-bg);
  border: 2px solid #dee2e6;
  border-radius: 14px;
  padding: 1.2rem 2rem;
  width: 320px;
  max-width: 90vw;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mode-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(214, 51, 132, 0.2);
  transform: translateY(-2px);
}

.mode-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.mode-lang {
  font-size: 0.9rem;
  color: var(--muted);
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 2.2rem;
  letter-spacing: 1px;
}

#progress {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1.1rem;
}

#game {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
}

section h2 {
  margin-bottom: 0.5rem;
  font-size: 1.3rem;
  color: var(--text);
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* Hand / Deck of flashcards */
.card-zone {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 140px;
  position: relative;
}

.card {
  background: var(--card-bg);
  border: 2px solid #dee2e6;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  width: 280px;
  max-width: 90vw;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  user-select: none;
  pointer-events: none;
}

.card .title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.card .desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.3;
}

/* The actively draggable card */
.card.active {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(214, 51, 132, 0.3);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  z-index: 10;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.card.active:active {
  cursor: grabbing;
}

.card.dragging {
  position: fixed;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25), 0 0 15px rgba(214, 51, 132, 0.4);
  transform: scale(1.05);
  z-index: 1000;
  transition: none;
}

.card-line {
  padding: 0.4rem 0;
  font-size: 0.95rem;
  color: var(--text);
}

.card-desc {
  color: var(--muted);
  font-size: 0.85rem;
}

.reveal-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  pointer-events: auto;
}

.reveal-btn:hover {
  background: var(--accent);
  color: white;
}

/* Timeline Layout */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.08);
  min-height: 200px;
}

/* Dropzones between events */
.dropzone {
  height: 40px;
  margin: 4px 0;
  border: 2px dashed #dee2e6;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  user-select: none;
}

.dropzone.hovered {
  height: 90px;
  background: rgba(214, 51, 132, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(214, 51, 132, 0.2);
  color: var(--accent);
  font-size: 1.05rem;
}

/* Placed Slot */
.slot {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  border: 2px solid var(--success);
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transform: scale(1);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slot .year {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--success);
  min-width: 90px;
}

.show-year-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: normal;
  min-width: 50px;
  width: 50px;
  text-align: center;
  line-height: 1.2;
  flex-shrink: 0;
}

.show-year-btn:hover {
  background: var(--accent);
  color: white;
}

.learn-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  margin-left: 0.3rem;
  white-space: nowrap;
}

.learn-link:hover {
  opacity: 0.7;
}

.learn-modal-content {
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

#learn-body {
  text-align: left;
  white-space: pre-line;
  overflow-y: auto;
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
}

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

.slot .event-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.slot .event-desc {
  font-size: 0.85rem;
  color: var(--muted);
}

.slot.placeholder {
  border: 2px dashed #dee2e6;
  background: transparent;
  color: var(--muted);
  justify-content: center;
  font-style: italic;
  min-height: 70px;
  box-shadow: none;
  animation: none;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card-bg);
  border: 2px solid #dee2e6;
  border-radius: 16px;
  padding: 2.2rem;
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h2 {
  margin-bottom: 1rem;
  font-size: 1.7rem;
}

.modal-content p {
  margin-bottom: 1.5rem;
  color: var(--text);
  line-height: 1.4;
  font-size: 1.05rem;
}

.modal-content button,
#play-again {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
}

.modal-content button:hover,
#play-again:hover {
  background: #b02a6e;
}

.secondary-btn {
  background: transparent !important;
  color: var(--muted) !important;
  border: 1px solid var(--muted) !important;
  margin-top: 0.5rem;
}

.secondary-btn:hover {
  color: var(--text) !important;
  border-color: var(--text) !important;
  background: rgba(0, 0, 0, 0.04) !important;
}

#stats {
  text-align: left;
  margin-bottom: 1.5rem;
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 10px;
}

#stats p {
  margin: 0.5rem 0;
  color: var(--text);
}

#stats .num {
  font-weight: 700;
  color: var(--accent);
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
