@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&display=swap");

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

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background-color: #121213;
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  max-width: 500px;
  width: 100%;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 1px solid #3a3a3c;
  padding-bottom: 20px;
}

h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: "DM Serif Display", serif;
  font-weight: 400;
  font-style: normal;
}

.subtitle {
  color: #d1d1d1;
  font-size: 1rem;
  font-weight: 500;
}

.game-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
  text-align: center;
  gap: 15px;
}

.category-display h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.2;
}

.category-display p {
  color: #a0a0a2;
  font-size: 0.95rem;
  font-weight: 500;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  padding: 15px 20px;
  background-color: #1e1e1f;
  border-radius: 12px;
  border: 1px solid #3a3a3c;
  width: 100%;
}

.main-stats-line {
  font-family: "Inter", monospace;
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  line-height: 1.4;
  letter-spacing: 1px;
}

.round-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  width: 100%;
}

.round-detail {
  font-size: 0.85rem;
  color: #a0a0a2;
  font-weight: 500;
  text-align: center;
}

.round-detail.current {
  color: #f5c842;
  font-weight: 600;
}

.stat {
  text-align: center;
  min-width: 80px;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: bold;
  color: #6aaa64;
  transition: color 0.3s ease;
}

.stat-value.warning {
  color: #f5c842;
}

.stat-value.danger {
  color: #f87171;
}

.stat-label {
  font-size: 0.7rem;
  color: #818384;
  text-transform: uppercase;
}

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}

.card {
  background-color: #3a3a3c;
  border: 2px solid #3a3a3c;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  position: relative;
}

.card:hover {
  border-color: #565758;
}

.card:active {
  cursor: grabbing;
}

/* Drag and drop states */
.card.sortable-ghost {
  opacity: 0.4;
  background-color: #565758 !important;
  border-color: #6aaa64 !important;
}

.card.sortable-drag {
  opacity: 0.8;
  transform: rotate(5deg);
  z-index: 1000;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.card.sortable-chosen {
  transform: scale(1.02);
}

.card.sortable-fallback {
  opacity: 0.8;
  background-color: #4a4a4c !important;
  border-color: #6aaa64 !important;
  transform: rotate(3deg);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Drag states for correct (green) cards */
.card.correct.sortable-ghost {
  background-color: #5a9a54 !important;
  border-color: #4a8a44 !important;
}

.card.correct.sortable-drag {
  background-color: #6aaa64 !important;
  border-color: #5a9a54 !important;
}

.card.correct.sortable-fallback {
  background-color: #5a9a54 !important;
  border-color: #4a8a44 !important;
}

/* Drag states for wrong (yellow) cards */
.card.wrong.sortable-ghost {
  background-color: #b9a448 !important;
  border-color: #a99438 !important;
}

.card.wrong.sortable-drag {
  background-color: #c9b458 !important;
  border-color: #b9a448 !important;
}

.card.wrong.sortable-fallback {
  background-color: #b9a448 !important;
  border-color: #a99438 !important;
}

.card.correct {
  background-color: #6aaa64;
  border-color: #6aaa64;
}

.card.correct .card-position {
  color: #1a2e18;
}

.card.correct .card-name {
  color: #1a2e18;
}

.card.correct .drag-handle {
  color: #1a2e18;
}

.card.wrong {
  background-color: #c9b458;
  border-color: #c9b458;
}

.card.wrong .card-position {
  color: #2d2a1a;
}

.card.wrong .card-name {
  color: #1a1814;
}

.card.wrong .drag-handle {
  color: #2d2a1a;
}

.card-content {
  flex: 1;
  padding: 15px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.card-name {
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.3;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.card-position {
  color: #a0a0a2;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 4px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Enhanced styling when showing values */
.card.correct .card-position {
  color: #1a2e18;
  font-weight: 600;
}

.card.wrong .card-position {
  color: #2d2a1a;
  font-weight: 600;
}

.drag-handle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 15px;
  color: #a0a0a2;
  cursor: grab;
  user-select: none;
  transition: color 0.2s ease;
  min-width: 50px;
}

.drag-handle:hover {
  color: #ffffff;
}

.card.correct .drag-handle:hover {
  color: #0a1e08;
}

.card.wrong .drag-handle:hover {
  color: #1d1a0a;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle::before {
  content: "⋮ ⋮";
  font-size: 24px;
  line-height: 0.6;
  letter-spacing: -3px;
  font-weight: bold;
}

/* Controls */
.controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 30px;
}

/* Row for the two share buttons */
.share-actions {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

/* Make them equal width and same height; remove vertical margins */
.share-actions .copy-btn,
.share-actions .share-x-btn {
  flex: 1;
  width: auto;
  margin: 0;
  white-space: nowrap; /* avoid wrapping "Share on X" */
}

/* Mobile: ensure Share on X gets the same larger padding as Copy Result */
@media (max-width: 600px) {
  .share-actions .copy-btn,
  .share-actions .share-x-btn {
    padding: 16px;
    font-size: 1.1rem;
  }
}

.submit-btn,
.reset-btn,
.copy-btn,
.close-btn,
.share-x-btn {
  padding: 14px 28px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.share-x-btn {
  width: 100%;
}

.submit-btn {
  background-color: #6aaa64;
  color: white;
}

.submit-btn:disabled {
  background-color: #3a3a3c;
  color: #818384;
  cursor: not-allowed;
}

.submit-btn:hover:not(:disabled) {
  background-color: #5a9a54;
}

.reset-btn {
  background-color: #818384;
  color: white;
}

.reset-btn:hover {
  background-color: #6a7a74;
}

.results {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.round-result {
  display: flex;
  align-items: center;
  justify-content: center;
}

.round-label {
  background-color: #3a3a3c;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 20px;
  min-width: 40px;
  text-align: center;
  position: relative;
  transition: all 0.3s ease;
  border: 2px solid #3a3a3c;
}

.round-label.success {
  background-color: #6aaa64;
  border-color: #6aaa64;
  color: #ffffff;
}

.round-label.completed-with-mistakes {
  background-color: #c9b458;
  border-color: #c9b458;
  color: #1a1814;
}

.round-label.completed-with-many-mistakes {
  background-color: #f87171;
  border-color: #f87171;
  color: #ffffff;
}

.round-label.current {
  background-color: #3f3f41;
  border-color: #3f3f41;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) inset;
}

.round-label.pending {
  background-color: #2a2a2c;
  border-color: #2a2a2c;
  color: #818384;
}

.mistake-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background-color: #f87171;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Legacy styles for compatibility - can be removed */
.attempt-result {
  display: none;
}

.result-tile {
  display: none;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #121213;
  padding: 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  border: 1px solid #3a3a3c;
}

.final-stats {
  margin: 15px 0;
  padding: 15px;
  background-color: #1e1e1f;
  border-radius: 8px;
}

.share-section {
  margin: 15px 0;
}

.share-section h3 {
  margin-bottom: 15px;
  font-size: 1rem;
}

.share-grid {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 15px;
  padding: 15px;
  background-color: #1e1e1f;
  border-radius: 8px;
  font-family: monospace;
  font-size: 1.2rem;
  line-height: 1.2;
  max-height: 200px;
  overflow-y: auto;
}

.copy-btn {
  background-color: #6aaa64;
  color: white;
  width: 100%;
  margin: 15px 0;
}

.copy-btn:hover {
  background-color: #5a9a54;
}

.close-btn {
  background-color: #818384;
  color: white;
  width: 100%;
}

.close-btn:hover {
  background-color: #6a7a74;
}

/* Improved mobile touch interaction */
@media (pointer: coarse) {
  .card {
    padding: 5px 0;
  }

  .drag-handle {
    padding: 18px 15px;
    min-width: 50px;
  }

  .drag-handle::before {
    font-size: 26px;
    line-height: 0.5;
    letter-spacing: -3px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 15px;
  }

  .game-info {
    margin-bottom: 25px;
  }

  .controls {
    flex-direction: column;
  }

  .submit-btn,
  .reset-btn {
    padding: 16px 32px;
    font-size: 1.1rem;
  }

  .stats {
    gap: 8px;
    padding: 12px 15px;
    margin-bottom: 15px;
  }

  .main-stats-line {
    font-size: 1.1rem;
    line-height: 1.3;
    letter-spacing: 0.5px;
  }

  .round-details {
    gap: 3px;
  }

  .round-detail {
    font-size: 0.8rem;
  }

  .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #2a2a2c;
    border-radius: 6px;
    width: 100%;
  }

  .stat-value {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .card-content {
    padding: 12px;
  }

  .card-name {
    font-size: 1rem;
  }

  .card-position {
    font-size: 0.85rem;
  }

  .category-display h2 {
    font-size: 1.25rem;
  }

  .category-display p {
    font-size: 0.9rem;
  }

  .drag-handle {
    padding: 18px 15px;
    min-width: 50px;
  }

  .drag-handle::before {
    font-size: 26px;
    line-height: 0.5;
    letter-spacing: -3px;
  }

  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .share-grid {
    max-height: 150px;
    font-size: 1rem;
  }

  .copy-btn,
  .close-btn {
    padding: 16px 32px;
    font-size: 1.1rem;
  }
}

/* Feedback animations */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

.card.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.card.pulse {
  animation: pulse 0.3s ease-in-out;
}

.card.highlight {
  animation: fadeHighlight 0.8s ease-out forwards;
}

.card.correct.highlight {
  animation: fadeHighlightGreen 0.8s ease-out forwards;
}

.card.wrong.highlight {
  animation: fadeHighlightYellow 0.8s ease-out forwards;
}

@keyframes fadeHighlight {
  0% {
    background-color: #4a4a4c;
  }

  100% {
    background-color: #3a3a3c;
  }
}

@keyframes fadeHighlightGreen {
  0% {
    background-color: #7aba74;
  }

  100% {
    background-color: #6aaa64;
  }
}

@keyframes fadeHighlightYellow {
  0% {
    background-color: #d9c468;
  }

  100% {
    background-color: #c9b458;
  }
}

/* Footer: place all <p> inline and add separators between them */
footer {
  margin-top: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center; /* or flex-start */
  flex-wrap: wrap; /* allow wrap on small screens */
  gap: 0; /* spacing comes from the separator margins */
}

footer p {
  margin: 0; /* remove default margins */
  display: inline-flex;
  align-items: center;
}

/* Add a "|" before every <p> that follows another <p> (i.e., between items) */
footer p + p::before {
  content: "|";
  margin-inline: 0.5rem; /* space around the separator */
  color: currentColor;
  opacity: 0.6; /* optional: subtle separator */
}

footer a {
  color: #6aaa64;
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #5a9a54;
  text-decoration: underline;
}

