.game_status_filters {
  position: sticky;
  top: 50px;
  z-index: 10;
  display: flex;
  gap: 4px;
  border-top: 1px solid #cbd7e0;
  border-bottom: 1px solid #cbd7e0;
  background: #e5edf3;
}

.game_status_filter {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px 7px;
  border-bottom: 3px solid transparent;
  color: #526171;
  font: 16px/1.2 'Acme';
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;

  &:hover, &:focus-visible {
    background: #eaf4fb;
    color: #176b96;
  }

  &[aria-current='page'] {
    border-bottom-color: var(--btn-primary);
    background: #f8fbfd;
    color: #176b96;
  }

  &:focus-visible {
    outline: 2px solid var(--btn-primary);
    outline-offset: -2px;
  }
}

@media (max-width: 600px) {
  .game_status_filters {
    gap: 0;
  }

  .game_status_filter {
    flex: 1;
    padding-inline: 8px;
  }
}

.list_items {
  font-family: 'Acme';

  .list_item_wrap {
    position: relative;
    outline: 0;
  }

  .game_line_item_link {
    position: absolute;
    inset: 0;
    z-index: 1;

    &:hover + .game_line_item {
      background: whitesmoke;
    }

    &:active + .game_line_item {
      background: white;
    }

    &:focus-visible {
      outline: 2px solid var(--btn-primary);
      outline-offset: -2px;
    }
  }

  .buttons {
    position: absolute;
    bottom: 10px;
    right: 10px;
    overflow: hidden;
    z-index: 2;

    &.nudge .btn_link, .nudge .btn_link {
      min-height: 28px;
      font-size: 14px;
      padding: 4px 7px;
    }

    &.nudge {
      bottom: 6px;

      a.btn_link {
        background-color: #ffca28;
      }
    }
  }
}

.line_item {
  box-sizing: border-box;
  color: #333;
  position: relative;
  overflow: hidden;
  height: var(--list-row-height);
  border-bottom: 1px solid silver;

  &:hover {
    background: whitesmoke;
  }

  &:active {
    background: white;
  }

  .title_text {
    display: block;
  }

  &.hilight {
    background: aliceblue;

    &:active {
      background: white;
    }
  }

  .avatar_frame {
    width: var(--list-avatar-size);
    height: var(--list-avatar-size);
    float: left;
    margin-right: 10px;
  }

  .message_waiting {
    position: absolute;
    left: 52px;
    top: 1px;
  }

  .score {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    margin-top: 1px;
    color: #7b8793;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;

    .username {
      box-sizing: border-box;
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 5px;
      min-width: 0;
      max-width: 190px;
      padding: 3px 6px 3px 5px;
      border: 1px solid transparent;
      border-left-width: 3px;
      border-radius: 6px;
      background-image: none;
      color: #263746;
      font-size: 15px;
      box-shadow: 0 1px 2px rgba(25, 48, 68, 0.08);

      &.player_1 {
        border-color: #9ddcf8;
        border-left-color: var(--player-1);
        background: #e8f7fd;
      }

      &.player_2 {
        border-color: #f0b4ae;
        border-left-color: var(--player-2);
        background: #fcecea;
      }

      .player_name {
        overflow: hidden;
        min-width: 0;
        text-overflow: ellipsis;
      }

      .points {
        flex: none;
        min-width: 20px;
        padding: 2px 4px;
        border: 1px solid #c7d2dc;
        border-radius: 4px;
        background: #fff;
        color: #263746;
        font-size: 13px;
        font-weight: 700;
        text-align: center;
        box-shadow: 0 1px 1px rgba(25, 48, 68, 0.08);
      }
    }

    .opponent {
      max-width: min(48%, 190px);
    }
  }

  .game_icons {
    display: inline-block;
    vertical-align: text-top;

    .icon {
      margin-right: -20px;
    }
  }

  .title {
    font-size: 18px;
    display: inline-block;
    margin-top: 12px;
  }

  .created_at {
    color: #888;
    position: absolute;
    top: 10px;
    right: 10px;
  }

  .last_move {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 400px;
    line-height: 20px;
    display: inline-block;
    margin-top: 2px;

    .total_points {
      font-size: 18px;
      font-weight: 700;
    }

    .words_made {
      font-weight: 700;
    }

    .point_gain {
      color: #888;
    }
  }
}

.game_line_item {
  display: flex;
  align-items: center;
  height: var(--list-row-height);

  .status_icon {
    pointer-events: none;
  }

  > .avatar_frame {
    flex: none;
    margin-right: 8px;
  }

  > .online.my_turn, > .online.view_fin {
    left: calc(var(--list-avatar-size) - 22px);
    bottom: calc((var(--list-row-height) - var(--list-avatar-size)) / 2);
  }

  > .message_waiting {
    left: calc(var(--list-avatar-size) - 22px);
    top: calc((var(--list-row-height) - var(--list-avatar-size)) / 2);
  }

  .game_line_content {
    box-sizing: border-box;
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    height: var(--list-row-height);
    overflow: hidden;
    padding: 2px 8px 2px 0;
  }

  .game_title_line {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex: 0 0 19px;
    gap: 6px;
    min-width: 0;
    width: 100%;
    padding-right: 110px;

    .title {
      overflow: hidden;
      min-width: 0;
      margin: 0;
      line-height: 19px;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .game_icons {
      flex: none;
    }
  }

  .score {
    flex: 0 0 auto;
    max-width: 100%;
    margin-top: 0;
  }

  .last_move {
    box-sizing: border-box;
    display: block;
    flex: 0 0 18px;
    width: 100%;
    max-width: 100%;
    height: 18px;
    margin-top: 0;
    padding-right: 70px;

    .dict {
      position: relative;
      z-index: 2;
    }
  }
}

.games_list .line_item {
  font-size: 15px;

  .title, .pending_username, .last_move .total_points {
    font-size: 17px;
  }

  .score .username {
    font-size: 15px;
  }

  .last_move {
    line-height: 18px;
  }
}

.games_list .active_game {
  .title {
    margin-top: 0;
  }

  .score {
    margin-top: 0;
  }

  .last_move {
    margin-top: 0;
  }
}

.finished_game {
  background-color: whitesmoke;

  .result {
    font-size: 18px;
    position: absolute;
    right: 10px;
    bottom: 10px;

    .value {
      .won {
        color: limegreen;
      }

      .lost {
        color: crimson;
      }

      .draw {
        color: dodgerblue;
      }
    }
  }
}

/* The main list and navigation previews render the same game rows. */
.games_list {
  .active_game, .finished_game {
    margin: 8px;
    background: transparent;
  }

  .game_line_item {
    box-sizing: border-box;
    height: var(--list-row-height);
    min-height: 0;
    padding: 8px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    background: var(--ui-surface);
    color: var(--ui-text);

    &.hilight {
      border-color: #abd3e7;
      background: #f3faff;
      box-shadow: inset 3px 0 0 #29b6f6;
    }

    > .avatar_frame { width: var(--list-avatar-size); height: var(--list-avatar-size); }
    .avatar { border-radius: 10px; }
    > .online.my_turn, > .online.view_fin { left: calc(8px + var(--list-avatar-size) - 22px); }
    > .message_waiting { left: calc(8px + var(--list-avatar-size) - 22px); }

    .game_line_content {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-content: center;
      gap: 2px 8px;
      height: 64px;
      min-height: 0;
      padding: 0;
    }

    .game_title_line { grid-column: 1; grid-row: 1; width: auto; padding-right: 0; }
    .game_title_line .game_icons { display: inline-flex; gap: 3px; max-width: 80px; overflow: hidden; }
    .game_icons .icon { flex: none; margin-right: 0; }
    .title { color: var(--ui-text); font-size: 18px; }
    .created_at {
      position: static;
      grid-column: 2;
      grid-row: 1;
      align-self: center;
      max-width: 100px;
      overflow: hidden;
      color: var(--ui-muted);
      font: 11px/1.3 system-ui, sans-serif;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .score { grid-column: 1 / -1; grid-row: 2; }
    .score .username { padding: 2px 5px; font-size: 14px; box-shadow: none; }
    .score .points { padding: 1px 4px; box-shadow: none; }
    .last_move { grid-column: 1 / -1; grid-row: 3; padding-right: 0; color: #526171; font-size: 13px; }
    &:has(.buttons.nudge) .last_move { padding-right: 64px; }
    .buttons.nudge { right: 8px; bottom: 8px; }
    .buttons.nudge a.btn_link { border-color: #d7bb68; background: #fff1bd; color: #755516; }
    .buttons.nudge a.btn_link:hover { background: #ffe79a; }
  }

  .game_line_item_link {
    border-radius: 10px;

    &:hover + .game_line_item { border-color: #aebfcd; background: #f5f9fc; }
    &:focus-visible + .game_line_item { border-color: var(--ui-focus); }
  }

  .finished_game {
    .score { box-sizing: border-box; padding-right: 58px; }
    .result { right: 8px; bottom: 8px; font-size: 14px; }
    .result .value > span { display: inline-block; padding: 4px 8px; border-radius: 6px; }
    .result .won { background: #eaf6ed; color: #247346; }
    .result .lost { background: #fceeed; color: #ad4039; }
    .result .draw { background: #edf2f7; color: #526779; }
  }
}

.friend_item {
  .new_message {
    margin-top: 5px;
    color: dodgerblue;
  }

  .username {
    margin-top: 4px;
  }

  .content {
    margin-top: 5px;
    font-style: italic;
    font-size: 12px;
    color: grey;
  }
}
