/* Ranking activity. Create-page styles follow the gap fill creator. */

[hidden] {
  display: none !important;
}

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

.success-message {
  text-align: center;
  padding: 40px 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #dee2e6;
  margin-bottom: 30px;
}

.success-message h2 {
  color: #28a745;
  font-size: 28px;
  margin-bottom: 15px;
  font-weight: 600;
}

.success-message p {
  font-size: 16px;
  color: #666;
  margin-bottom: 20px;
}

.url-display {
  margin: 20px 0;
  padding: 15px;
  background: #fff;
  border: 2px solid #28a745;
  border-radius: 6px;
  display: inline-block;
  max-width: 100%;
}

.activity-url {
  color: #007bff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 500;
  word-break: break-all;
}

.activity-url:hover {
  color: #0056b3;
  text-decoration: underline;
}

.action-buttons {
  margin-top: 25px;
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-buttons .create_button,
.action-buttons button.create_button,
.action-buttons a.create_button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  box-sizing: border-box !important;
  width: 250px;
  height: 48px !important;
  min-height: 48px;
  margin: 0 !important;
  padding: 0 16px !important;
  text-decoration: none;
  border-radius: 6px;
  font-family: "Open Sans", sans-serif !important;
  font-weight: 600 !important;
  font-size: 16px !important;
  line-height: 1.2 !important;
  white-space: nowrap;
  color: white;
  border: 2px solid #007bff;
  background: #007bff;
  cursor: pointer;
}

.action-buttons .create_button.secondary,
.action-buttons a.create_button.secondary {
  background: #6c757d;
  border-color: #6c757d;
  color: white;
}

.action-buttons .create_button:hover,
.action-buttons button.create_button:hover {
  background: #0056b3;
  border-color: #0056b3;
  color: white;
}

.action-buttons .create_button.secondary:hover,
.action-buttons a.create_button.secondary:hover {
  background: #5a6268;
  border-color: #5a6268;
  color: white;
}

.page-header {
  padding: 30px 0;
  margin-bottom: 30px;
}

.page-header h1 {
  color: #495057;
  margin-bottom: 25px;
  font-size: 2.2em;
  text-align: center;
}

.buttonBar {
  margin-bottom: 20px;
}

.nav-button {
  display: inline-block;
  padding: 10px 20px;
  margin-right: 10px;
  background: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  transition: background 0.3s;
}

.nav-button:hover {
  background: #0056b3;
  text-decoration: underline;
}

.version-notice {
  background: #e7f3ff;
  padding: 15px;
  border-radius: 5px;
  margin: 20px 0;
  border-left: 4px solid #007bff;
}

.user-status {
  padding: 15px;
  border-radius: 5px;
  margin: 20px 0;
  display: flex;
  align-items: flex-start;
}

.logged-in {
  background: #d4edda;
  border-left: 4px solid #28a745;
}

.logged-out {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
}

.status-icon {
  font-weight: bold;
  margin-right: 10px;
}

.exercise-creator {
  max-width: 800px;
  margin: 0 auto;
}

.form-section {
  background: white;
  padding: 25px;
  border-radius: 8px;
  margin-bottom: 25px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-section h2 {
  margin-bottom: 20px;
  color: #333;
  border-bottom: 2px solid #007bff;
  padding-bottom: 10px;
}

.instruction-text {
  color: #666;
  margin-bottom: 20px;
  font-style: italic;
}

.create_formhead {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #555;
}

.create_textinput,
.create_textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  margin-bottom: 15px;
  box-sizing: border-box;
  font-family: inherit;
}

.create_textarea {
  min-height: 180px;
  resize: vertical;
}

.create_textinput:focus,
.create_textarea:focus {
  border-color: #007bff;
  outline: 3px solid rgba(0, 123, 255, 0.35);
  outline-offset: 1px;
}

.create_option {
  margin: 8px 0 14px;
}

.create_option label {
  margin-left: 6px;
}

.create_button {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 15px 30px;
  border-radius: 5px;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

a.create_button,
a.create_button:visited {
  color: #fff;
  text-decoration: none;
}

.create_button:hover,
a.create_button:hover,
a.create_button:focus {
  background: #0056b3;
  color: #fff;
  text-decoration: none;
}

.create-section {
  text-align: center;
  margin: 20px 0 40px;
}

.error {
  color: #dc3545;
  text-align: center;
  margin: 15px 0;
  font-weight: bold;
}

.ai-api-hint {
  margin: 16px 0 0;
  font-size: 0.8em;
  line-height: 1.4;
  color: #6c757d;
}

.ai-api-hint a {
  color: #6c757d;
}

.api-docs h3 {
  margin-top: 22px;
  color: #333;
}

.ai-help-pre,
.api-docs pre {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.bulk-format-list {
  padding-left: 1.2em;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
  margin: 40px 0;
  width: 100%;
}

.game-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 25px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4a90e2, #357abd);
}

.game-card h3 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 1.3em;
}

.game-card p {
  color: #6c757d;
  line-height: 1.6;
  margin-bottom: 20px;
}

.game-link {
  display: inline-block;
  background: #e3f2fd;
  color: #4a90e2 !important;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
}

.game-link:hover {
  background: #4a90e2;
  color: white !important;
}

.ad-container {
  margin: 30px 0;
  text-align: center;
}

.ranking-index .page-header h1 {
  text-align: left;
}

.ranking-index-intro {
  text-align: left;
  color: #444;
  font-size: 1.02rem;
  line-height: 1.55;
}

.ranking-index-intro a {
  color: #1875d0;
  font-weight: 600;
}

/* Student play */
.rank-play {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 12px 40px;
}

.rank-play h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 8px 0 10px;
  text-align: left;
  color: #212529;
}

.rank-instruction {
  margin: 0 0 18px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: #333;
}

.rank-missing {
  color: #842029;
  background: #f8d7da;
  border-radius: 8px;
  padding: 12px 14px;
}

.rank-board {
  display: block;
  background: #f7f9fb;
  border: 2px dashed #b7c3ce;
  border-radius: 14px;
  padding: 12px;
}

.rank-numbers {
  display: none;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
  counter-reset: rank;
}

.rank-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  background: #fff;
  border: 2px solid #c5ced6;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color: #243140;
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.rank-card::before {
  counter-increment: rank;
  content: counter(rank);
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #1875d0;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
}

.rank-card:active,
.rank-chosen {
  cursor: grabbing;
}

.rank-handle {
  flex: 0 0 14px;
  width: 14px;
  height: 20px;
  background-image: radial-gradient(circle, #243140 1.7px, transparent 1.8px);
  background-size: 7px 7px;
  background-repeat: repeat;
  background-position: center;
}

.rank-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.05rem;
  line-height: 1.3;
  text-align: left;
  overflow-wrap: anywhere;
}

.rank-arrows {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex: 0 0 auto;
}

.rank-up,
.rank-down,
.rank-action {
  font-family: inherit;
}

.rank-up,
.rank-down {
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 2px solid #1875d0;
  border-radius: 8px;
  background: #fff;
  color: #1875d0;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.rank-up:hover,
.rank-down:hover {
  background: #e7f1ff;
}

.rank-up:disabled,
.rank-down:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: #adb5bd;
  color: #6c757d;
  background: #f8f9fa;
}

.rank-up:focus,
.rank-down:focus,
.rank-action:focus,
.create_button:focus {
  outline: 3px solid #0b5ed7;
  outline-offset: 2px;
}

.rank-locked .rank-card {
  cursor: default;
  background: #fff;
}

.rank-locked .rank-arrows,
.rank-locked .rank-handle {
  display: none;
}

.rank-ghost {
  opacity: 0.45;
}

.rank-chosen {
  border-color: #007bff;
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
  cursor: grabbing;
}

.rank-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.rank-action {
  flex: 1 1 140px;
  min-height: 48px;
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  border: 2px solid #007bff;
  background: #007bff;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.rank-action-secondary {
  background: #fff;
  color: #007bff;
}

.rank-action:hover {
  background: #0056b3;
  border-color: #0056b3;
  color: #fff;
}

.rank-action-secondary:hover {
  background: #e7f1ff;
  color: #0056b3;
}

#rankChange {
  flex: 0 0 auto;
}

.rank-compare {
  margin: 16px 0 0;
  padding: 14px 16px;
  background: #e7f3ff;
  border-left: 4px solid #007bff;
  border-radius: 8px;
  font-size: 1.05rem;
  line-height: 1.45;
}

.rank-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 480px) {
  .success-message {
    padding: 20px 15px;
  }

  .success-message h2,
  .page-header h1 {
    font-size: 1.6rem;
  }

  .action-buttons {
    flex-direction: column;
    align-items: center;
  }

  .action-buttons .create_button,
  .action-buttons button.create_button,
  .action-buttons a.create_button {
    width: 100%;
    max-width: 300px;
  }

  .form-section {
    padding: 16px;
  }
}
