:root {
  --color-primary: #ce0f69;
  --color-secondary-teal: #009ca6;
  --color-secondary-purple: #68478d;
  --color-tertiary-gold: #ffb81c;
  --color-tertiary-black: #000000;
}

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: var(--color-tertiary-black);
}

.card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  border-top: 6px solid transparent;
  border-image: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary-teal),
    var(--color-secondary-purple),
    var(--color-tertiary-gold)
  );
  border-image-slice: 1;
}

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  line-height: 1.4;
}

.status {
  font-size: 0.9rem;
  color: #6b7280;
  text-align: center;
  padding: 40px 0;
}

.status.error {
  color: var(--color-primary);
}

.timer {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

.timer.stopped {
  color: var(--color-primary);
}

.board {
  --board-size: min(76vw, 360px);
  width: var(--board-size);
  height: var(--board-size);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 1px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.board.solved {
  box-shadow: 0 0 0 3px var(--color-tertiary-gold);
}

.tile {
  position: relative;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.tile.dragging {
  cursor: grabbing;
  z-index: 10;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.tile.selected {
  outline: 3px solid var(--color-primary);
  outline-offset: -3px;
}

.tile.swap-target {
  outline: 3px solid var(--color-tertiary-gold);
  outline-offset: -3px;
}

.board.solved .tile {
  cursor: default;
}

.solved-banner {
  margin-top: 24px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  background: rgba(206, 15, 105, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.btn-primary:hover {
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.shuffle-btn {
  width: auto;
  margin: 24px auto 0;
}

.btn-text {
  display: block;
  margin: 10px auto 0;
  padding: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}

.btn-text:hover {
  color: var(--color-tertiary-black);
}

.save-section {
  margin-top: 24px;
  text-align: center;
}

.save-status {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
}

.save-status.success {
  color: var(--color-secondary-teal);
}

.save-status.error {
  color: var(--color-primary);
}

.panel {
  margin-top: 24px;
  padding: 18px;
  background: #f9fafb;
  border-radius: 10px;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.panel-hint {
  font-size: 0.85rem;
  color: #6b7280;
  line-height: 1.4;
  margin-bottom: 12px;
}

.panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.text-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-tertiary-black);
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.form-error {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.leaderboard-card {
  padding: 24px 32px;
}

.leaderboard-title {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.leaderboard-status {
  font-size: 0.85rem;
  color: #6b7280;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f9fafb;
}

.leaderboard-rank {
  flex-shrink: 0;
  width: 22px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #6b7280;
  text-align: center;
}

.leaderboard-row:nth-child(1) .leaderboard-rank {
  color: var(--color-tertiary-gold);
}

.leaderboard-handle {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-time {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.powered-by a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #6b7280;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.powered-by a:hover {
  color: var(--color-tertiary-black);
}

.powered-by-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.powered-by strong {
  color: var(--color-primary);
  font-weight: 700;
}
